?? tinapp.cpp
字號:
// TinApp.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "TinApp.h"
#include "TinFrm.h"
#include "TinDoc.h"
#include "TinMap.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTinApp
BEGIN_MESSAGE_MAP(CTinApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &CTinApp::OnAppAbout)
// 基于文件的標(biāo)準(zhǔn)文檔命令
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// 標(biāo)準(zhǔn)打印設(shè)置命令
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTinApp construction
CTinApp::CTinApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CTinApp object
CTinApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CTinApp initialization
BOOL CTinApp::InitInstance()
{
// 如果一個(gè)運(yùn)行在 Windows XP 上的應(yīng)用程序清單指定要
// 使用 ComCtl32.dll 版本 6 或更高版本來啟用可視化方式,
//則需要 InitCommonControlsEx()。否則,將無法創(chuàng)建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 將它設(shè)置為包括所有要在應(yīng)用程序中使用的
// 公共控件類。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 初始化 OLE 庫
if (!AfxOleInit())
{
AfxMessageBox("OLE 初始化失敗。請確保 OLE 庫是正確的版本。");
return FALSE;
}
AfxEnableControlContainer();
// 標(biāo)準(zhǔn)初始化
// 如果未使用這些功能并希望減小
// 最終可執(zhí)行文件的大小,則應(yīng)移除下列
// 不需要的特定初始化例程
// 更改用于存儲設(shè)置的注冊表項(xiàng)
// TODO: 應(yīng)適當(dāng)修改該字符串,
// 例如修改為公司或組織名
SetRegistryKey(_T("TinApp"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// 注冊應(yīng)用程序的文檔模板。文檔模板
// 將用作文檔、框架窗口和視圖之間的連接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_TINFRM,
RUNTIME_CLASS(CTinDoc),
RUNTIME_CLASS(CTinFrm),
RUNTIME_CLASS(CTinMap));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析標(biāo)準(zhǔn)外殼命令、DDE、打開文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 調(diào)度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 啟動(dòng)應(yīng)用程序,則返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一個(gè)窗口已初始化,因此顯示它并對其進(jìn)行更新
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// 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)
// No message handlers
//}}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()
// App command to run the dialog
void CTinApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CTinApp message handlers
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -