深入浅出MFC第2版(PDF格式)-第60部分
按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
#0093 EnableShellOpen();
#0094 RegisterShellFileTypes(TRUE);
#0095
#0096 // Parse mand line for standard shell mands; DDE; file open
#0097 CmandLineInfo cmdInfo;
#0098 ParsemandLine(cmdInfo);
#0099
#0100 // Dispatch mands specified on the mand line
#0101 if (!ProcessShellmand(cmdInfo))
#0102 return FALSE;
#0103
#0104 // The main window has been initialized; so show and update it。
#0105 pMainFrame…》ShowWindow(m_nCmdShow);
#0106 pMainFrame…》UpdateWindow();
#0107
#0108 return TRUE;
#0109 }
278
…………………………………………………………Page 341……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0110
#0111 /////////////////////////////////////////////////////////////////
#0112 // CAboutDlg dialog used for App About
#0113
#0114 class CAboutDlg : public CDialog
#0115 {
#0116 public:
#0117 CAboutDlg();
#0118
#0119 // Dialog Data
#0120 //{{AFX_DATA(CAboutDlg)
#0121 enum { IDD = IDD_ABOUTBOX };
#0122 //}}AFX_DATA
#0123
#0124 // ClassWizard generated virtual function overrides
#0125 //{{AFX_VIRTUAL(CAboutDlg)
#0126 protected:
#0127 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
#0128 //}}AFX_VIRTUAL
#0129
#0130 // Implementation
#0131 protected:
#0132 //{{AFX_MSG(CAboutDlg)
#0133 // No message handlers
#0134 //}}AFX_MSG
#0135 DECLARE_MESSAGE_MAP()
#0136 };
#0137
#0138 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
#0139 {
#0140 //{{AFX_DATA_INIT(CAboutDlg)
#0141 //}}AFX_DATA_INIT
#0142 }
#0143
#0144 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
#0145 {
#0146 CDialog::DoDataExchange(pDX);
#0147 //{{AFX_DATA_MAP(CAboutDlg)
#0148 //}}AFX_DATA_MAP
#0149 }
#0150
#0151 BEGIN_MESSAGE_MAP(CAboutDlg; CDialog)
#0152 //{{AFX_MSG_MAP(CAboutDlg)
#0153 // No message handlers
#0154 //}}AFX_MSG_MAP
#0155 END_MESSAGE_MAP()
279
…………………………………………………………Page 342……………………………………………………………
第篇 欲善工事先利其器
#0156
#0157 // App mand to run the dialog
#0158 void CScribbleApp::OnAppAbout()
#0159 {
#0160 CAboutDlg aboutDlg;
#0161 aboutDlg。DoModal();
#0162 }
#0163
#0164 /////////////////////////////////////////////////////////////////
#0165 // CScribbleApp mands
MAINFRM。CPP
#0001 // MainFrm。cpp : implementation of the CMainFrame class
#0002 //
#0003
#0004 #include 〃stdafx。h〃
#0005 #include 〃Scribble。h〃
#0006
#0007 #include 〃MainFrm。h〃
#0008
#0009 #ifdef _DEBUG
#0010 #define new DEBUG_NEW
#0011 #undef THIS_FILE
#0012 static char THIS_FILE'' = __FILE__;
#0013 #endif
#0014
#0015 /////////////////////////////////////////////////////////////////
#0016 // CMainFrame
#0017
#0018 IMPLEMENT_DYNAMIC(CMainFrame; CMDIFrameWnd)
#0019
#0020 BEGIN_MESSAGE_MAP(CMainFrame; CMDIFrameWnd)
#0021 //{{AFX_MSG_MAP(CMainFrame)
#0022 // NOTE the ClassWizard will add and remove mapping macros here。
#0023 // DO NOT EDIT what you see in these blocks of generated code !
#0024 ON_WM_CREATE()
#0025 //}}AFX_MSG_MAP
#0026 END_MESSAGE_MAP()
#0027
#0028 static UINT indicators'' =
#0029 {
#0030 ID_SEPARATOR; // status line indicator
#0031 ID_INDICATOR_CAPS;
#0032 ID_INDICATOR_NUM;
#0033 ID_INDICATOR_SCRL;
280
…………………………………………………………Page 343……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0034 };
#0035
#0036 /////////////////////////////////////////////////////////////////
#0037 // CMainFrame construction/destruction
#0038
#0039 CMainFrame::CMainFrame()
#0040 {
#0041 // TODO: add member initialization code here
#0042
#0043 }
#0044
#0045 CMainFrame::~CMainFrame()
#0046 {
#0047 }
#0048
#0049 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
#0050 {
#0051 if (CMDIFrameWnd::OnCreate(lpCreateStruct) == …1)
#0052 return …1;
#0053
#0054 if (!m_wndToolBar。Create(this) ||
#0055 !m_wndToolBar。LoadToolBar(IDR_MAINFRAME))
#0056 {
#0057 TRACE0(〃Failed to create toolbarn〃);
#0058 return …1; // fail to create
#0059 }
#0060
#0061 if (!m_wndStatusBar。Create(this) ||
#0062 !m_wndStatusBar。SetIndicators(indicators;
#0063 sizeof(indicators)/sizeof(UINT)))
#0064 {
#0065 TRACE0(〃Failed to create status barn〃);
#0066 return …1; // fail to create
#0067 }
#0068
#0069 // TODO: Remove this if you don't want tool tips or a resizeable toolbar
#0070 m_wndToolBar。SetBarStyle(m_wndToolBar。GetBarStyle() |
#0071 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
#0072
#0073 // TODO: Delete these three lines if you don't want the toolbar to
#0074 // be dockable
#0075 m_wndToolBar。EnableDocking(CBRS_ALIGN_ANY);
#0076 EnableDocking(CBRS_ALIGN_ANY);
#0077 DockControlBar(&m_wndToolBar);
#0078
#0079 return 0;
281
…………………………………………………………Page 344……………………………………………………………
第篇 欲善工事先利其器
#0080 }
#0081
#0082 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
#0083 {
#0084 // TODO: Modify the Window class or styles here by modifying
#0085 // the CREATESTRUCT cs
#0086
#0087 return CMDIFrameWnd::PreCreateWindow(cs);
#0088 }
#0089
#0090 /////////////////////////////////////////////////////////////////
#0091 // CMainFrame diagnostics
#0092
#0093 #ifdef _DEBUG
#0094 void CMainFrame::AssertValid() const
#0095 {
#0096 CMDIFrameWnd::AssertValid();
#0097 }
#0098
#0099 void CMainFrame::Dump(CDumpContext& dc) const
#0100 {
#0101 CMDIFrameWnd::Dump(dc);
#0102 }
#0103
#0104 #endif //_DEBUG
#0105
#0106 /////////////////////////////////////////////////////////////////
#0107 // CMainFrame message handlers
CHILDFRM。CPP
#0001 // ChildFrm。cpp : implementation of the CChildFrame class
#0002 //
#0003
#0004 #include 〃stdafx。h〃
#0005 #include 〃Scribble。h〃
#0006
#0007 #include 〃ChildFrm。h〃
#0008
#0009 #ifdef _DEBUG
#0010 #define new DEBUG_NEW
#0011 #undef THIS_FILE
#0012 static char THIS_FILE'' = __FILE__;
#0013 #endif
#0014
#0015 /////////////////////////////////////////////////////////////////
282
…………………………………………………………Page 345……………………………………………………………
第4章 Visual C++ 整合性軟體開發環境
#0016 // CChildFrame
#0017
#0018 IMPLEMENT_DYNCREATE(CChildFrame; CMDIChildWnd)
#0019
#0020 BEGIN_MESSAGE_MAP(CChildFrame; CMDIChildWnd)
#0021 //{{AFX_MSG_MAP(CChildFrame)
#0022 // NOTE the ClassWizard will add and remove mapping macros here。
#0023 // DO NOT EDIT what you see in these blocks of generated code !
#0024 //}}AFX_MSG_MAP
#0025 END_MESSAGE_MAP()
#0026
#0027 /////////////////////////////////////////////////////////////////
#0028 // CChildFrame construction/destruction
#0029
#0030 CChildFrame::CChildFrame()
#0031 {
#0032 // TODO: add member initialization code here
#0033
#0034 }
#0035
#0036 CChildFrame::~CChildFrame()
#0037 {
#0038 }
#0039
#0040 BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
#0041 {
#0042 // TODO: Modify the Window class or styles here by modifying
#0043 // the CREATESTRUCT cs
#0044
#0045 return CMDIChildWnd::PreCreateWindow(cs);
#0046 }
#0047
#0048 /////////////////////////////////////////////////////////////////