?? qq.cpp
字號:
// 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=酒店管理系統\0"
// "Description=New Access Data Source\0"
// "FileType=Access\0"
// "DBQ=%s酒店管理系統.mdb\0"
// 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=酒店管理系統\0"
"Description=酒店管理系統的數據源\0"
"FileType=Access\0"
"DBQ=.\\酒店管理系統.mdb\0"
);
}
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);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -