【VC开源代码栏目提醒】:网学会员VC开源代码为您提供BaseTabCtrl1.cpp参考,解决您在BaseTabCtrl1.cpp学习中工作中的难题,参考学习。
// BaseTabCtrl1.cpp : implementation file
//
#include "stdafx.h"
#include "BaseTabCtrl1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBaseTabCtrl
CBaseTabCtrl::CBaseTabCtrl(int nfield)
:mc_iNumber(nfield)
{
this->m_statics=new CStatic[mc_iNumber];
this->m_edits=new CEdit[mc_iNumber];
m_list=new CListCtrl;
m_btn=new CButton[5];
}
CBaseTabCtrl::~CBaseTabCtrl()
{
}
BEGIN_MESSAGE_MAP(CBaseTabCtrl, CTabCtrl)
//{{AFX_MSG_MAP(CBaseTabCtrl)
ON_NOTIFY_REFLECT(TCN_SELCHANGE, OnSelchange)//NM_DBLCLK
ON_NOTIFY(NM_DBLCLK, ID_TABLIST, OnDblclkList)
ON_CBN_SELENDOK(ID_COMBOFIELDS, OnSelendokComboFields)
ON_BN_CLICKED(ID_BUTTONS_1+3,OnBaoCunClick)
ON_BN_CLICKED(ID_BUTTONS_1,OnZengJiaClick)
ON_BN_CLICKED(ID_BUTTONS_1+2,OnShanChuClick)
ON_BN_CLICKED(ID_BUTTONS_1+1,OnXiuGaiClick)
ON_BN_CLICKED(ID_BUTTONS_1+4,OnCancelClick)
ON_BN_CLICKED(ID_CHECK,OnCheckClick)
ON_BN_CLICKED(ID_BUTTONCHAXUN,OnChaXun)// ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBaseTabCtrl message handlers
void CBaseTabCtrl::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
this->OnListReturn();
*pResult = 0;
}
bool CBaseTabCtrl::InitBaseInfo()
{/*
//初始化基本信息页
TRACE("InitBaseInfo\n");
//确定statics edits显示位置:rect1,rect2,rect3,rect4;
CRect rect;
this->GetClientRect(&rect);
int height=25;
int top=60;
int wid=rect.Width()/4;
CRect rect1,rect2,rect3,rect4;
rect1.top=top;
rect1.bottom=top+20;
rect1.left=10;
rect1.right=(long)rect.Width()/8;
rect2.top=top;
rect2.bottom=top+20;
rect2.left=(long)rect.Width()/8+10;
rect2.right=(long)rect.Width()/2-10;
rect3.top=top;
rect3.bottom=top+20;
rect3.left=rect.Width()/2+10;
rect3.right=(long)rect.Width()*5/8;
rect4.top=top;
rect4.bottom=top+20;
rect4.left=(long)rect.Width()*5/8+10;
rect4.right=(long)rect.Width()-10;
int n=this->mc_iNumber/2;
int yu=this->mc_iNumber%2;
for(int i=0;i<n;i++)
{
this->m_statics[i*2].Create(m_ss[i*2]+":",WS_CHILD,rect1,this,ID_STATICS_1+i*2);
this->m_statics[i*2+1].Create(m_ss[i*2+1]+":",WS_CHILD,rect3,this,ID_STATICS_1+i*2+1);
this->m_edits[i*2].Create(WS_CHILD|ES_AUTOHSCROLL|WS_BORDER,rect2,this,ID_EDITS_1+i*2);
this->m_edits[i*2+1].Create(WS_CHILD|ES_AUTOHSCROLL|WS_BORDER,rect4,this,ID_EDITS_1+i*2+1);
rect1.OffsetRect(0,height);
rect2.OffsetRect(0,height);
rect3.OffsetRect(0,height);
rect4.OffsetRect(0,height);
}
if(yu)
{
this->m_statics[i*2].Create(m_ss[i*2]+":",WS_CHILD,rect1,this,ID_STATICS_1+i*2);
this->m_edits[i*2].Create(WS_CHILD|ES_AUTOHSCROLL|WS_BORDER,rect2,this,ID_EDITS_1+i*2);
}
baseinfo_state=NORMAL;*/
return true;
}
bool CBaseTabCtrl::EnableBaseInfo(bool enabled)
{
for(int i=0;i<this->mc_iNumber;i++)
{
m_edits[i].SetReadOnly(!enabled);
}
return enabled;
}
int CBaseTabCtrl::ShowBaseInfo(int show)
{
for(int i=0;i<this->mc_iNumber;i++)
{
this->m_edits[i].ShowWindow(show);
}
for(int j=0;j<this->mc_iNumber;j++)
{
this->m_statics[j].ShowWindow(show);
}
for(int k=0;k<5;k++)
{
this->m_btn[k].ShowWindow(show);
}
return show;
}
bool CBaseTabCtrl::InitList()
{
//初始化列表框页
CRect rect_nlist;
this->GetClientRect(&rect_nlist);
rect_nlist.top+=100;
// m_list=new CListCtrl;
m_list->Create(WS_CHILD|LVS_REPORT|WS_BORDER|LVS_SINGLESEL,rect_nlist,this,ID_TABLIST);
this->m_list->ModifyStyle(LVS_EDITLABELS, 0L); //禁止标题编辑
m_list->ModifyStyle(0L, LVS_REPORT); //设为Report类型
m_list->ModifyStyle(0L, LVS_SHOWSELALWAYS); //始终高亮度被选中的表项
m_list->ModifyStyle(0L, LVS_NOSORTHEADER);
m_list->SetBkColor(RGB(0,200,200));
m_list->SetTextBkColor(RGB(0,200,200));
m_list->ModifyStyle(LVS_OWNERDRAWFIXED ,0L);
m_list->SetExtendedStyle( LVS_EX_FULLROWSELECT | //允许整行选中
LVS_EX_HEADERDRAGDROP | //允许整列拖动
LVS_EX_GRIDLINES | //画出网格线
LVS_EX_FLATSB //扁平风格的滚动条
);
rect_nlist.top=70;
rect_nlist.bottom=rect_nlist.top+20;
rect_nlist.left=20;
rect_nlist.right=rect_nlist.left+180;
this->m_check.Create("是否在查询结果中查询",0x00010003|WS_CHILD,rect_nlist,this,ID_CHECK);
rect_nlist.top=30;
rect_nlist.bottom=rect_nlist.top+120;
rect_nlist.left=20;
rect_nlist.right=rect_nlist.left+150;
m_combofields.Create(0x00010203|WS_CHILD|CBS_AUTOHSCROLL|WS_VSCROLL ,rect_nlist,this,ID_COMBOFIELDS);
rect_nlist.OffsetRect(200,0);
rect_nlist.right-=90;
m_combofuhao.Create(0x00010203|WS_CHILD|CBS_AUTOHSCROLL|WS_VSCROLL ,rect_nlist,this,ID_COMBOFUHAO);
rect_nlist.OffsetRect(100,0);
rect_nlist.right+=140;
rect_nlist.bottom=rect_nlist.top+21;
this->m_editvalue.Create(WS_CHILD|ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP,rect_nlist,this,ID_EDITVALUE);
rect_nlist.bottom=rect_nlist.top+22;
rect_nlist.right=rect_nlist.left+100;
m_tcvalue.Create(WS_CHILD,rect_nlist,this,233);
rect_nlist.OffsetRect(10,40);
rect_nlist.right=rect_nlist.left+80;
rect_nlist.bottom=rect_nlist.top+25;
this->m_btnchaxun.Create("查询",WS_CHILD,rect_nlist,this,ID_BUTTONCHAXUN);
return true;
}
bool CBaseTabCtrl::InitSelf()
{
SetItemSize(CSize(50,20));
return true;
}
BOOL CBaseTabCtrl::Create(DWORD dwStyle, const RECT &rect, CWnd *pParentWnd, UINT nID)
{
this->InitValues();
if(!CTabCtrl::Create(dwStyle,rect,pParentWnd,nID))return false;
this->InitBaseInfo();
this->InitBtn();
this->InitList();
this->InitSelf();
this->ShowListChaXun(SW_SHOW);
this->ShowBaseInfo(SW_HIDE);
//this->m_list->SetFocus();
return true;
}
void CBaseTabCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult)
{
int i=this->GetCurSel();
switch(i)
{
case 0:
// this->RefreshListView(PrepareSQL());
this->ShowBaseInfo(SW_HIDE);
this->ShowListChaXun(SW_SHOW);
break;
case 1:
this->ShowBaseInfo(SW_SHOW);
this->ShowListChaXun(SW_HIDE);
if(!this->baseinfo_state)
this->SetKey(this->m_list->GetSelectionMark());
break;
}
*pResult = 0;
}
bool CBaseTabCtrl::InitBtn()
{
CRect rect;
this->GetClientRect(rect);
rect.top=rect.bottom-35;
rect.left=r
上一篇:
BaseStatic.cpp
下一篇:
计算机网络毕业论文