📄 accounttabs.cpp
字号:
// AccountTabs.cpp : implementation file
//
#include "stdafx.h"
#include "account.h"
#include "AccountTabs.h" //tabctrl控件类
#include "TabPageDlg.h" //tabpage基类
#include "MainPageDlg.h" //主窗口tabpage
#include "MonthPageDlg.h" //月消费统计tabpage
#include "AccountAdo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAccountTabs
CAccountTabs::CAccountTabs()
{
m_tabPages[0]=new CMainPageDlg;
m_tabPages[1]=new CMonthPageDlg;
m_nNumberOfPages=2;
}
CAccountTabs::~CAccountTabs()
{
for(int nCount=0; nCount < m_nNumberOfPages; nCount++)
{
delete m_tabPages[nCount];
m_tabPages[nCount]=NULL;
}
}
/////////////////////////////////////////////////////////////////////////////
// CAccountTabs message handlers
void CAccountTabs::Initialize()
{
//1、初始化数据库部分
m_pAccountAdo = new CAccountAdo;
ASSERT(m_pAccountAdo!=NULL);
m_pAccountAdo->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Account.mdb");
//2、------------------------------------
TC_ITEM tc;
tc.mask = TCIF_TEXT;
int iPage = 0;
{
tc.pszText = (LPTSTR)(LPCTSTR) "帐务维护";
InsertItem (iPage ++, &tc);
tc.pszText = (LPTSTR)(LPCTSTR) "月消费统计";
InsertItem (iPage ++, &tc);
}
//3、------------------------------------
m_tabCurrent = 0;
m_tabPages[0]->Create(this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->Create(this);
m_tabPages[1]->ShowWindow(SW_HIDE);
SetRectangle(m_tabCurrent);
m_tabPages[m_tabCurrent]->SetFocus();
}
void CAccountTabs::SetRectangle(WORD wTabCurrent)
{
CRect tabRect, itemRect;
int nX, nY, nXc, nYc;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
nX=itemRect.left;
nY=itemRect.bottom+1;
nXc=tabRect.right-itemRect.left-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[wTabCurrent]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
//for(int nCount=1; nCount < m_nNumberOfPages; nCount++){
// m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
//}
}
BEGIN_MESSAGE_MAP(CAccountTabs, CTabCtrl)
//{{AFX_MSG_MAP(CAccountTabs)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAccountTabs::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTabCtrl::OnLButtonDown(nFlags, point);
if(m_tabCurrent != GetCurFocus()){
m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
m_tabCurrent=GetCurFocus();
//TRACE("选中的tabpage: %d \n",m_tabCurrent);
m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
m_tabPages[m_tabCurrent]->SetFocus();
SetRectangle(m_tabCurrent);
}
}
void CAccountTabs::Release()
{
if(m_pAccountAdo!=NULL)
{
delete m_pAccountAdo;
m_pAccountAdo=NULL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -