QQ.cpp
资源名称:酒店管理系统源代码.rar [点击查看]
上传用户:czfddz
上传日期:2013-03-20
资源大小:1517k
文件大小:8k
源码类别:
酒店行业
开发平台:
C/C++
- // QQ.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "QQ.h"
- #include "MainFrm.h"
- #include "QQDoc.h"
- #include "QQView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define UNIQE_NAME "{1C6780D1-4078-41fa-8F5F-8FCC82BD15DD}"
- #include ".\SplashWnd\LjxWnd.h"
- /////////////////////////////////////////////////////////////////////////////
- // CQQApp
- BEGIN_MESSAGE_MAP(CQQApp, CWinApp)
- //{{AFX_MSG_MAP(CQQApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- // Standard file based document commands
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- // Standard print setup command
- ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CQQApp construction
- CQQApp::CQQApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CQQApp object
- CQQApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // CQQApp initialization
- BOOL CQQApp::InitInstance()
- {
- /*
- * 自动安装ODBC数据源
- */
- SetupODBCDateSource();
- ///////*************保证当前只有一个实例在运行*********//////////
- m_hOneInstance = ::CreateMutex( NULL,FALSE,UNIQE_NAME);//创建一个互斥体
- if (GetLastError() == ERROR_ALREADY_EXISTS )
- {
- AfxMessageBox( "应用程序已经在运行!" );
- return FALSE;//不实现该实例
- }
- /*------------------------------------------------------------*/
- AfxEnableControlContainer(); //容器支持
- //===================加载皮肤并且设置皮肤窗口================*/
- VERIFY( 1 == InitSkinMagicLib( AfxGetInstanceHandle(), "QQ" ,
- NULL,
- NULL ) );
- VERIFY( 1 == LoadSkinFromResource( AfxGetInstanceHandle() , "SKINMAGIC" ,"SKINMAGIC") );
- VERIFY( 1 == SetDialogSkin( "Dialog" ) );
- /*==========================END==============================*/
- GetCtrlManager().InstallHook();//使所有控件浮动
- //////////////////////////////////////////////////////////////////////////
- //增加的闪屏效果代码
- CLjxWnd *ljxljx=new CLjxWnd; //建立一个新窗口对象
- ljxljx->CreatLjxWnd (); //创建窗口
- ljxljx->CenterWindow (); //在屏幕中央
- ljxljx->ShowWindow (SW_SHOW); //显示窗口
- ljxljx->UpdateWindow (); //更新窗口,激活OnPait函数
- Sleep(100); //等待函数指定秒钟
- if (ljxljx!=NULL) ljxljx->SendMessage (WM_CLOSE); //关闭窗口
- //
- // Standard initialization
- // If you are not using these features and wish to reduce the size
- // of your final executable, you should remove from the following
- // the specific initialization routines you do not need.
- #ifdef _AFXDLL
- Enable3dControls(); // Call this when using MFC in a shared DLL
- #else
- Enable3dControlsStatic(); // Call this when linking to MFC statically
- #endif
- // Change the registry key under which our settings are stored.
- // TODO: You should modify this string to be something appropriate
- // such as the name of your company or organization.
- SetRegistryKey(_T("Local AppWizard-Generated Applications"));
- LoadStdProfileSettings(); // Load standard INI file options (including MRU)
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views.
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(CQQDoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(CQQView));
- AddDocTemplate(pDocTemplate);
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
- // Dispatch commands specified on the command line
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
- // The one and only window has been initialized, so show and update it.
- HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2);
- m_pMainWnd->SetIcon(m_hIcon,true);
- m_pMainWnd->ShowWindow(SW_SHOW);
- m_pMainWnd->CenterWindow();
- m_pMainWnd->UpdateWindow();
- m_pMainWnd->SetWindowText("酒店管理系统2003");
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- #include ".\email\HyperLink.h"
- 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)
- virtual void OnOK();
- virtual BOOL OnInitDialog();
- //}}AFX_MSG
- CHyperLink m_EMailLink;
- DECLARE_MESSAGE_MAP()
- };
- #define IDS_MAILADDR _T("mailto:kuge3907@sina.com")
- 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
- DDX_Control(pDX, IDC_EMAILLINK, m_EMailLink);
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- // App command to run the dialog
- void CQQApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CQQApp message handlers
- void CAboutDlg::OnOK()
- {
- // TODO: Add extra validation here
- new CFaderWnd(this,2000);//实现渐隐效果
- EndDialog(IDOK);//关闭对话框
- // CDialog::OnOK();
- }
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_EMailLink.SetURL(IDS_MAILADDR);
- m_EMailLink.SetUnderline(CHyperLink::ulAlways);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- int CQQApp::ExitInstance()
- {
- // TODO: Add your specialized code here and/or call the base class
- CloseHandle( m_hOneInstance );
- ExitSkinMagicLib();//卸载皮肤库
- return CWinApp::ExitInstance();
- }
- void CQQApp::SetupODBCDateSource()//用编程的方式自动完成ODBC数据库的安装
- {//自动安装ODBC数据源
- //仍然有些问题,数据源没有具体的路径bug!!!!!!!!
- // 需要继续修改 [6/4/2003]
- // CString strDBPath;
- // strDBPath=GetDBPath();//获得数据源的路径
- // CString strAtturbute;//DataDirectory
- // strAtturbute.Format(
- // "DSN=酒店管理系统 "
- // "Description=New Access Data Source "
- // "FileType=Access "
- // "DBQ=%s酒店管理系统.mdb "
- // strDBPath
- // );//设置ODBC的属性
- //修改成下面的样子后问题解决,可以自动在软件启动的时候安装ODBC数据源
- //但是要求"酒店管理系统.mdb"数据库要和应用程序放在通一个目录下
- // [6/4/2003-22:40]
- //主要的修改的地方:
- //相对路径的获取,先前采用的是调用GetDBPath()的方法
- //后面采用直接用相对路径的方式".\"(当前目录)
- //SQLConfigDataSource()的调用方法比较特殊
- /************************************************************************/
- // 函数功能说明:实现ODBC数据源的自动安装;
- /* SQLConfigDataSource()的具体用法说明
- 1. HWND hwndParent:调用ConfigDataSource的窗口句柄
- 若hwndParent取值为:m_pMainWnd->m_hWnd,则在App启动的时候弹出
- 创建数据源的对话框要求用户自己添加数据源
- 若若hwndParent取值为:NULL,则系统自动的创建数据源,
- 不会弹出创建数据源的对话框;
- 2. WORD fRequest:
- ODBC_ADD_DSN :添加用户数据源
- ODBC_ADD_SYS_DSN:添加系统用户数据源
- 3. 第三个参数:驱动程序的描叙
- 4. 数据库的具体属性
- /************************************************************************/
- SQLConfigDataSource(NULL,ODBC_ADD_DSN,
- "Microsoft Access Driver (*.mdb)",
- "DSN=酒店管理系统 "
- "Description=酒店管理系统的数据源 "
- "FileType=Access "
- "DBQ=.\酒店管理系统.mdb "
- );
- }
- CString CQQApp::GetDBPath()
- {//获得数据库的路径
- CString szDBPath;
- TCHAR pathtemp[255];
- ::GetModuleFileName(AfxGetApp()->m_hInstance,pathtemp,255);
- szDBPath=pathtemp;//获得路径名称
- int n=szDBPath.ReverseFind('\');
- return szDBPath.Left(n+1);
- }