MainFrm.cpp
资源名称:酒店管理系统源代码.rar [点击查看]
上传用户:czfddz
上传日期:2013-03-20
资源大小:1517k
文件大小:14k
源码类别:
酒店行业
开发平台:
C/C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "QQ.h"
- #include "QQView.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #include <mmsystem.h>
- #define WM_ICON_NOTIFY WM_USER+10 //自定义消息的宏定义
- #include "page1.h"
- #include "page2.h"
- #include "page3.h"
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- ON_COMMAND_EX(CG_ID_VIEW_DIALOGBAR, OnBarCheck)
- ON_UPDATE_COMMAND_UI(CG_ID_VIEW_DIALOGBAR, OnUpdateControlBarMenu)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_CLOSE()
- ON_COMMAND(IDC_HELPTEXT, OnHelp)
- ON_COMMAND(IDC_EMAIL, OnEmail)
- ON_COMMAND(IDC_EXIT, OnExit)
- ON_COMMAND(IDC_APPWZD, OnAppWzd)
- ON_COMMAND(IDC_PRE, OnPre)
- ON_COMMAND(IDC_BACK, OnBack)
- ON_WM_SIZING()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- // pView=CQQView::GetView();
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- //创建扩展工具栏
- if (!this->CreateExToolBar())
- return -1;
- /************************************************************************/
- /* 在工具栏上添加数字时钟 */
- /************************************************************************/
- if(!m_clock.Create("",WS_CHILD|WS_VISIBLE,CRect(0,0,135,40),this,IDC_CLOCK))
- {
- return -1;
- }
- m_wndReBar.AddBar(&m_clock,NULL, NULL, RBBS_FIXEDSIZE | RBBS_FIXEDBMP);
- m_clock.SetStyle(CLEDClock::XDC_SECOND);
- /*--------------------------------------------------------------*/
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- //////////////////////////////////////////////////////////////////////////
- /* 创建任务栏图标 */
- //////////////////////////////////////////////////////////////////////////
- //加载系统托盘区程序组
- if (!m_systemIcon.Create(this,//消息通知窗口
- WM_ICON_NOTIFY,//自定义消息
- "酒店管理系统2003", //提示字符串
- AfxGetApp()->LoadIcon(IDR_MAINFRAME),//图标ID号
- IDR_POPUP_MENU //弹出菜单ID号
- ))
- {
- return -1;
- }
- if (!m_wndTabBar.Create(this, CSize(110, 100), WS_CHILD | WS_VISIBLE |
- CBRS_LEFT | CBRS_SIZE_DYNAMIC, AFX_IDW_TOOLBAR + 11))
- {
- TRACE0("Failed to create cool barn");
- return -1; // fail to create
- }
- if (!m_wndListBox1.Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 150, 300), &m_wndTabBar.m_wndTabCtrl, 0))
- {
- TRACE0("Failed to create list barn");
- return -1; // fail to create
- }
- m_wndTabBar.m_wndTabCtrl.SetMode(TABMODE_GROUP);
- m_wndTabBar.m_wndTabCtrl.AddPage(&m_wndListBox1, "管理", NULL);
- m_wndListBox1.AddItem(0, "客房登记",ID_ROOM_REGISTER, "客人住入酒店时进行客房登记");
- m_wndListBox1.AddItem(1, "选房", ID_ROOM_CHOOSE, "给客人分配房间");
- m_wndListBox1.AddItem(2, "房间预定",ID_ROOM_DESTINE, "为客人进行房间预定服务");
- m_wndListBox1.AddItem(3, "餐饮点菜",ID_FOOD_ORDER, "管理客人的餐饮点菜");
- m_wndListBox1.AddItem(4, "帐单付款",ID_MONEY_PAY, "支付某个帐单的费用");
- m_wndListBox1.AddItem(5, "服务点单",ID_SERVER_ORDER, "服务点单");
- m_wndListBox1.AddItem(6, "财务结帐",ID_MONEY_CHECKOUT, "客人离开时进行费用结算");
- m_wndListBox1.SetImagelist(IDB_IMAGE);
- if (!m_wndListBox2.Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 200, 300), &m_wndTabBar.m_wndTabCtrl, 0))
- {
- TRACE0("Failed to create list barn");
- return -1; // fail to create
- }
- m_wndTabBar.m_wndTabCtrl.SetMode(TABMODE_GROUP);
- m_wndTabBar.m_wndTabCtrl.AddPage(&m_wndListBox2, "查询", NULL);
- m_wndListBox2.AddItem(0, "客人信息", ID_INFOLOOK_GUEST, "查看客人在酒店的情况");
- m_wndListBox2.AddItem(1, "客房信息", ID_INFOLOOK_ROOM, "查看客房信息");
- m_wndListBox2.AddItem(2, "帐单信息", ID_INFOLOOK_BILL, "查看帐单信息");
- m_wndListBox2.AddItem(3, "服务项目", ID_INFOLOOK_SERVER, "查看酒店有哪些服务项目");
- m_wndListBox2.AddItem(4, "食物信息", ID_INFOLOOK_FOOD, "查看酒店有哪些食物提供服务");
- m_wndListBox2.AddItem(5, "员工信息", ID_INFOLOOK_EMPLOYER,"查看酒店的员工信息");
- m_wndListBox2.AddItem(6, "消费情况", ID_INFOLOOK_CONSUME, "查看在酒店的消费情况");
- m_wndListBox2.SetImagelist(IDB_IMAGE);
- //////////////////////////////////////////////////////////////////////////
- /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- CoolMenu的安装
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
- m_CoolMenu.Attach(GetMenu()->GetSafeHmenu());//菜单连接
- CCoolMenu::SubClass(this->GetSafeHwnd());//子类化
- CCoolMenu::SetLogoText("hello", RGB(0, 0, 255));
- CCoolMenu::SetLogoImage(IDB_LOGOBAR2,0);
- CCoolMenu::SetBackGroundBmp(IDB_BKBMP);
- // CCoolMenuTheme::SetTheme(MENU_STYLE_XP);
- CCoolMenu::SetStyle(CCoolMenu::GetStyle() & ~CMS_ICONBAR);
- CCoolMenu::SetMenuColor(RGB(255,255,255));//菜单背景色
- CCoolMenu::SetIconBarColor(::GetSysColor(COLOR_3DFACE));
- CCoolMenu::SetLightBarColor(RGB(61, 128, 152));//高亮栏的边框的颜色
- CCoolMenu::SetLightBarStartColor(RGB(255, 255, 255));
- CCoolMenu::SetLightBarEndColor(RGB(77,109, 120));
- CCoolMenu::SetTextColor(RGB(0, 0, 0));
- CCoolMenu::SetHighLightColor(RGB(20, 20, 50));
- CMenuWndHook::m_crFrame[0] = RGB(120, 120, 158);
- CMenuWndHook::m_crFrame[1] = RGB(48, 50, 48);
- CMenuWndHook::m_crFrame[2] = RGB(255, 255, 255);
- CMenuWndHook::m_crFrame[3] = RGB(168, 168, 210);
- /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ // TODO: Change the value of CG_ID_VIEW_DIALOGBAR to an appropriate value: // 1. Open the file resource.h // CG: The following block was inserted by the 'Dialog Bar' component { // Initialize dialog bar m_wndDialogBar//RIGHT if (!m_wndDialogBar.Create(this, CG_IDD_DIALOGBAR, CBRS_RIGHT| CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE, CG_ID_VIEW_DIALOGBAR)) { TRACE0("Failed to create dialog bar m_wndDialogBarn"); return -1; // fail to create } m_wndDialogBar.EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndDialogBar); } //Create our RollupCtrl into DialogBar4,4,187,362
- m_wndRollupCtrl.Create(WS_VISIBLE|WS_CHILD, CRect(4,0,148,1000), &m_wndDialogBar, 2);
- //Add some pages
- //page1
- m_wndRollupCtrl.InsertPage("高级查询",IDD_PAGE1,RUNTIME_CLASS(CPage1), 10);
- //page2
- m_wndRollupCtrl.InsertPage("数据分析",IDD_PAGE2,RUNTIME_CLASS(CPage2));
- //page3
- m_wndRollupCtrl.InsertPage("酒店概况",IDD_PAGE3,RUNTIME_CLASS(CPage3));
- /////
- HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- // new CFaderWnd(this,2000);
- // AfxGetMainWnd()->ShowWindow(SW_HIDE);
- CFrameWnd::OnClose();
- }
- BOOL CMainFrame::CreateExToolBar()
- {
- CImageList img;
- CString str;
- if(!m_wndReBar.Create(this))
- {
- return -1;
- }
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
- {
- return -1;
- }
- //下面的代码是设置按钮的宽度和长度
- m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50,90);
- //下面的代码是设置"热"的位图
- img.Create(25, 25, ILC_COLOR16|ILC_MASK,2,2);
- img.SetBkColor(::GetSysColor(COLOR_BTNFACE));
- img.Add(AfxGetApp()->LoadIcon(IDI_WZD));//应用程序向导
- img.Add(AfxGetApp()->LoadIcon(IDI_PRE));//前台程序
- img.Add(AfxGetApp()->LoadIcon(IDI_BACK));//后台程序
- img.Add(AfxGetApp()->LoadIcon(IDI_HELP));//帮助
- img.Add(AfxGetApp()->LoadIcon(IDI_EMAIL));//邮件
- img.Add(AfxGetApp()->LoadIcon(IDI_EXIT));//退出
- m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
- img.Detach();
- //下面的代码是设置"冷"的位图
- img.Create(23, 23, ILC_COLOR16|ILC_MASK, 2,2);
- img.SetBkColor(::GetSysColor(COLOR_BTNFACE));
- img.Add(AfxGetApp()->LoadIcon(IDI_WZD));//应用程序向导
- img.Add(AfxGetApp()->LoadIcon(IDI_PRE));//前台程序
- img.Add(AfxGetApp()->LoadIcon(IDI_BACK));//后台程序
- img.Add(AfxGetApp()->LoadIcon(IDI_HELP));//帮助
- img.Add(AfxGetApp()->LoadIcon(IDI_EMAIL));//邮件
- img.Add(AfxGetApp()->LoadIcon(IDI_EXIT));//退出
- m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
- img.Detach();
- //改变属性
- m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT |CBRS_TOOLTIPS | TBSTYLE_TRANSPARENT|TBBS_CHECKBOX );
- m_wndToolBar.SetButtons(NULL,6);
- // set up each toolbar button设置文字
- m_wndToolBar.SetButtonInfo(0, IDC_APPWZD, TBSTYLE_BUTTON, 0);
- m_wndToolBar.SetButtonText(0, "向导");
- m_wndToolBar.SetButtonInfo(1, IDC_PRE, TBSTYLE_BUTTON, 1);
- m_wndToolBar.SetButtonText(1, "前台模式");
- m_wndToolBar.SetButtonInfo(2, IDC_BACK, TBSTYLE_BUTTON, 2);
- m_wndToolBar.SetButtonText(2, "后台模式");
- m_wndToolBar.SetButtonInfo(3, IDC_HELPTEXT, TBSTYLE_BUTTON, 3);
- m_wndToolBar.SetButtonText(3, "帮助");
- m_wndToolBar.SetButtonInfo(4, IDC_EMAIL, TBSTYLE_BUTTON, 4);
- m_wndToolBar.SetButtonText(4, "邮件");
- m_wndToolBar.SetButtonInfo(5, IDC_EXIT, TBSTYLE_BUTTON, 5);
- m_wndToolBar.SetButtonText(5,"退出");
- CRect rectToolBar;
- //得到按钮的大小
- m_wndToolBar.GetItemRect(0, &rectToolBar);
- //设置按钮的大小
- m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(20,23));
- //在Rebar中加入ToolBar
- m_wndReBar.AddBar(&m_wndToolBar);
- //改变一些属性
- REBARBANDINFO rbbi;
- rbbi.cbSize = sizeof(rbbi); //这个是必须填
- rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE|RBBIM_BACKGROUND;
- //工具条的宽度
- rbbi.cxMinChild = rectToolBar.Width();
- //高度
- rbbi.cyMinChild = rectToolBar.Height();
- //下面这行代码是为工具条加入背景位图,请注意上rbbi.fMask中RBBIM_BACKGROUND标志
- rbbi.hbmBack = LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_TOOLBARBKGND));
- rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * 10;
- m_wndReBar.GetReBarCtrl().SetBandInfo(0, &rbbi);
- return TRUE;
- }
- void CMainFrame::OnAppWzd()
- {
- PlayResource(IDR_PRESSBTN);
- }
- void CMainFrame::OnPre()
- {
- PlayResource(IDR_PRESSBTN);
- }
- void CMainFrame::OnBack()
- {
- PlayResource(IDR_PRESSBTN);
- }
- void CMainFrame::OnHelp()
- {
- PlayResource(IDR_PRESSBTN);
- }
- void CMainFrame::OnEmail()
- {
- PlayResource(IDR_PRESSBTN);
- }
- void CMainFrame::OnExit()
- {
- PlayResource(IDR_PRESSBTN);
- CFrameWnd::OnClose();
- }
- BOOL CMainFrame::PlayResource(WORD wResourceID)
- {
- // Get the handle to the current instance of the application
- HINSTANCE hInstance = AfxGetInstanceHandle();
- ASSERT (hInstance != NULL);
- // Find the WAVE resource
- HRSRC hResInfo =
- FindResource(hInstance, MAKEINTRESOURCE(wResourceID), _T("WAVE"));
- if(hResInfo == NULL)
- return FALSE;
- // Load the WAVE resource
- HANDLE hRes = LoadResource(hInstance, hResInfo);
- if (hRes == NULL)
- return FALSE;
- // Lock the WAVE resource and play it
- LPSTR lpRes = (LPSTR) LockResource(hRes);
- if(lpRes==NULL)
- return FALSE;
- if (sndPlaySound(lpRes, SND_MEMORY | SND_ASYNC) == NULL)
- return FALSE;
- // Free the WAVE resource and return success or failure.
- FreeResource(hRes);
- return TRUE;
- }
- void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
- {//改变框架的大小处理消息
- CFrameWnd::OnSizing(fwSide, pRect);
- // TODO: Add your message handler code here
- CQQView* pView=CQQView::GetView();
- RestorViewBmp();//改变大小时,视图区重画,
- //显示在视图区的图像也被擦除,应该恢复
- if(pView->nImgTypeInView==12)
- {
- page3.bDrawTreeImage=TRUE;
- }
- if(pView->nImgTypeInView==13)
- {
- page3.bDrawFrameImage=TRUE;
- }
- if(pView->nImgTypeInView==0)
- {
- pView->bFirstRun=TRUE;
- }
- }
- void CMainFrame::RestorViewBmp()
- {//因为如窗口大小改变等原因引起视图区重画,恢复视图区先前显示的图像
- CQQView* pView=CQQView::GetView();
- pView->UpdateData(TRUE);
- CDC* pDC=pView->GetDC();
- CRect rect;
- pView->GetClientRect(&rect);
- // pDC->FillSolidRect(rect,pDC->GetBkColor());
- CBitmap* m_bitmap=CBitmap::FromHandle(pView->m_CurScreenBitmap);
- CDC MemDC;
- MemDC.CreateCompatibleDC(pDC);
- MemDC.SelectObject(m_bitmap);
- pDC->BitBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,SRCCOPY);
- }
- void CMainFrame::DoDataExchange(CDataExchange* pDX)
- {
- // TODO: Add your specialized code here and/or call the base class
- DDX_Control(pDX, IDC_CLOCK, m_clock);
- CFrameWnd::DoDataExchange(pDX);
- }