www.pudn.com > ssproj03.zip > ssproj03Dlg.cpp


// ssproj03Dlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ssproj03.h" 
#include "ssproj03Dlg.h" 
#include "page1.h" 
#include "page2.h" 
#include "page3.h" 
#include "page4.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSsproj03Dlg dialog 
 
CSsproj03Dlg::CSsproj03Dlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CSsproj03Dlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CSsproj03Dlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
	m_IsCtrl=false; 
} 
 
void CSsproj03Dlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSsproj03Dlg) 
	DDX_Control(pDX, IDC_TAB1, m_Tab); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CSsproj03Dlg, CDialog) 
	//{{AFX_MSG_MAP(CSsproj03Dlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_WM_SIZE() 
	ON_WM_CANCELMODE() 
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1) 
	ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, OnSelchangingTab1) 
	ON_WM_KEYDOWN() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSsproj03Dlg message handlers 
 
BOOL CSsproj03Dlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	int cy,cx; 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
	cy=m_Total_cy; 
	m_Tab.SetWindowPos(NULL,10,10,m_Total_cx-20,cy-20,NULL); 
	AddPage(); 
	iTab=0; 
	m_IsCtrl=true; 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CSsproj03Dlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CSsproj03Dlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CSsproj03Dlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
void CSsproj03Dlg::AddPage() 
{ 
	TC_ITEM TabCtrlItem; 
	CRect Rect; 
 
	m_pPage1=new CPage1; 
	TabCtrlItem.mask = TCIF_TEXT; 
	TabCtrlItem.pszText = "订票"; 
	TabCtrlItem.mask=TCIF_PARAM|TCIF_TEXT; 
	TabCtrlItem.lParam=(LPARAM)m_pPage1; 
	VERIFY(m_pPage1->Create(CPage1::IDD,&m_Tab)); 
	m_Tab.InsertItem( 0, &TabCtrlItem ); 
	m_Tab.GetClientRect(&Rect); 
	m_pPage1->SetWindowPos(NULL,5,23,Rect.Width()-10,Rect.Height()-28,NULL/*SWP_NOSIZE|SWP_NOZORDER*/); 
	m_pPage1->ShowWindow(SW_SHOW); 
	m_pPage1->EnableWindow(TRUE); 
 
	m_pPage2=new CPage2; 
	TabCtrlItem.lParam=(LPARAM)m_pPage2; 
	VERIFY(m_pPage2->Create(CPage2::IDD,&m_Tab)); 
	TabCtrlItem.pszText = "取票"; 
	m_Tab.InsertItem( 1, &TabCtrlItem ); 
	m_pPage2->SetWindowPos(NULL,5,23,Rect.Width()-10,Rect.Height()-28,NULL/*SWP_NOSIZE|SWP_NOZORDER*/); 
	m_pPage2->ShowWindow(SW_HIDE); 
 
	m_pPage3=new CPage3; 
	TabCtrlItem.lParam=(LPARAM)m_pPage3; 
	VERIFY(m_pPage3->Create(CPage3::IDD,&m_Tab)); 
	TabCtrlItem.pszText = "查询订单"; 
	m_Tab.InsertItem( 2, &TabCtrlItem ); 
	m_pPage3->SetWindowPos(NULL,5,23,Rect.Width()-10,Rect.Height()-28,NULL/*SWP_NOSIZE|SWP_NOZORDER*/); 
	m_pPage3->ShowWindow(SW_HIDE); 
 
	m_pPage4=new CPage4; 
	TabCtrlItem.lParam=(LPARAM)m_pPage4; 
	VERIFY(m_pPage4->Create(CPage4::IDD,&m_Tab)); 
	TabCtrlItem.pszText = "系统设置"; 
	m_Tab.InsertItem( 3, &TabCtrlItem ); 
	m_pPage4->SetWindowPos(NULL,5,23,Rect.Width()-10,Rect.Height()-28,NULL/*SWP_NOSIZE|SWP_NOZORDER*/); 
	m_pPage4->ShowWindow(SW_HIDE); 
} 
 
void CSsproj03Dlg::OnSize(UINT nType, int cx, int cy)  
{ 
	CDialog::OnSize(nType, cx, cy); 
	 
	// TODO: Add your message handler code here 
	m_Total_cx=cx; 
	m_Total_cy=cy; 
//	m_Tab.GetWindowRect(); 
	if(m_IsCtrl==true) 
		m_Tab.SetWindowPos(NULL,10,10,cx-20,cy-20,NULL); 
	 
} 
 
void CSsproj03Dlg::OnCancelMode()  
{ 
	CDialog::OnCancelMode(); 
	 
	// TODO: Add your message handler code here 
	 
} 
 
void CSsproj03Dlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
	iTab=m_Tab.GetCurSel(); 
	TCITEM	tci; 
	CRect Rect; 
 
	switch(iTab){ 
	case 0: 
		m_pPage1->ClearAll(); 
		m_pPage1->InitAll(); 
		break; 
	case 1: 
		m_pPage2->Clear(); 
		m_pPage2->Ini(); 
		break; 
	case 2: 
		break; 
	case 3: 
		m_pPage4->Clear(); 
		m_pPage4->Ini(); 
		break; 
	default: 
		break; 
	} 
	tci.mask=TCIF_PARAM; 
	m_Tab.GetItem(iTab,&tci); 
	ASSERT(tci.lParam); 
 
	CWnd* pWnd=(CWnd*)tci.lParam; 
	pWnd->ShowWindow(SW_SHOW); 
	pWnd->EnableWindow(true); 
	 
	*pResult = 0; 
} 
 
void CSsproj03Dlg::OnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
	int		iTab=m_Tab.GetCurSel(); 
	TCITEM	tci; 
 
	tci.mask=TCIF_PARAM; 
	m_Tab.GetItem(iTab,&tci); 
	ASSERT(tci.lParam); 
 
	CWnd* pWnd=(CWnd*)tci.lParam; 
	pWnd->ShowWindow(SW_HIDE); 
	pWnd->EnableWindow(false); 
	 
	*pResult = 0; 
} 
 
void CSsproj03Dlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)  
{ 
	// TODO: Add your message handler code here and/or call default 
	 
//	CDialog::OnKeyDown(nChar, nRepCnt, nFlags); 
}