www.gusucode.com > VC++宾馆管理系统(Access)程序 > VC++宾馆管理系统(Access)程序\code\HotelManageSysDlg.cpp

    //Download by http://www.NewXing.com
// HotelManageSysDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HotelManageSys.h"
#include "HotelManageSysDlg.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()

/////////////////////////////////////////////////////////////////////////////
// CHotelManageSysDlg dialog

CHotelManageSysDlg::CHotelManageSysDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHotelManageSysDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHotelManageSysDlg)
		// 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);
}

void CHotelManageSysDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHotelManageSysDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CHotelManageSysDlg, CDialog)
	//{{AFX_MSG_MAP(CHotelManageSysDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_COMMAND(ID_SYS_MENU, OnSysMenu)
	ON_COMMAND(ID_STANDARD_MENU, OnStandardMenu)
	ON_COMMAND(ID_ROOM_MENU, OnRoomMenu)
	ON_COMMAND(ID_ORDER_MENU, OnOrderMenu)
	ON_COMMAND(ID_CHECK_MENU, OnCheckMenu)
	ON_COMMAND(IDC_Login, OnLogin)
	ON_COMMAND(IDC_Register, OnRegister)
	ON_COMMAND(IDC_Exit, OnExit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHotelManageSysDlg message handlers

BOOL CHotelManageSysDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 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
	m_pUserDlg = new CUserDlg;
	m_pStandardDlg = new CStandardDlg;
	m_pRoomDlg = new CRoomDlg;
	m_pOrderDlg = new COrderDlg;
	m_pCheckDlg = new CCheckDlg;
    m_pRegisterDlg = new CRegisterDlg;

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CHotelManageSysDlg::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 CHotelManageSysDlg::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 CHotelManageSysDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CHotelManageSysDlg::OnSysMenu() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pUserDlg->Create(IDD_USER_DLG,this) ;
	status[0] = TRUE;
}

void CHotelManageSysDlg::OnStandardMenu() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pStandardDlg->Create(IDD_STANDARD_DLG,this) ;	
	status[1] = TRUE;
}

void CHotelManageSysDlg::OnRoomMenu() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pRoomDlg->Create(IDD_ROOM_DLG,this) ;
	status[2] = TRUE;
}

void CHotelManageSysDlg::OnOrderMenu() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pOrderDlg->Create(IDD_ORDER_DLG,this) ;
	status[3] = TRUE;
}

void CHotelManageSysDlg::OnCheckMenu() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pCheckDlg->Create(IDD_CHECK_DLG,this) ;
	status[4] = TRUE;
}

BOOL CHotelManageSysDlg::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	delete m_pUserDlg;
	delete m_pStandardDlg;
	delete m_pRoomDlg;
	delete m_pOrderDlg;
	delete m_pCheckDlg;	
    delete m_pRegisterDlg;
	return CDialog::DestroyWindow();
}
void CHotelManageSysDlg::SetDlgStatus()
{
	if(status[0])
	{
		m_pUserDlg->DestroyWindow();
		status[0] = FALSE;
	}
	if(status[1])
	{
		m_pStandardDlg->DestroyWindow();
		status[1] = FALSE;
	}
	if(status[2])
	{
		m_pRoomDlg->DestroyWindow();
		status[2] = FALSE;
	}
	if(status[3])
	{
		m_pOrderDlg->DestroyWindow();
		status[3] = FALSE;
	}
	if(status[4])
	{
		m_pCheckDlg->DestroyWindow();
		status[4] = FALSE;
	}
    if(status[5])
	{
		m_pRegisterDlg->DestroyWindow();
		status[5] = FALSE;
	}
}

void CHotelManageSysDlg::OnLogin() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pUserDlg->Create(IDD_USER_DLG,this) ;
	status[0] = TRUE;
}

void CHotelManageSysDlg::OnRegister() 
{
	// TODO: Add your command handler code here
	SetDlgStatus();
	m_pRegisterDlg->Create(IDD_REGISTER_DIALOG,this) ;
	status[5] = TRUE;
}

void CHotelManageSysDlg::OnExit() 
{
	// TODO: Add your command handler code here
	CDialog::OnOK();
}