| 1 |
// mfc1.cpp : Defines the class behaviors for the application. |
| 2 |
// |
| 3 |
|
| 4 |
// clang-format off |
| 5 |
#include "stdafx.h" |
| 6 |
|
| 7 |
#include "MainFrm.h" |
| 8 |
#include "mfc1.h" |
| 9 |
|
| 10 |
#include "ChildFrm.h" |
| 11 |
#include "mfc1Doc.h" |
| 12 |
#include "mfc1View.h" |
| 13 |
// clang-format on |
| 14 |
|
| 15 |
#ifdef _DEBUG |
| 16 |
# define new DEBUG_NEW |
| 17 |
#endif |
| 18 |
|
| 19 |
// Cmfc1App |
| 20 |
|
| 21 |
BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp) |
| 22 |
ON_COMMAND(ID_APP_ABOUT, OnAppAbout) |
| 23 |
// Standard file based document commands |
| 24 |
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) |
| 25 |
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) |
| 26 |
// Standard print setup command |
| 27 |
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) |
| 28 |
END_MESSAGE_MAP() |
| 29 |
|
| 30 |
// Cmfc1App construction |
| 31 |
|
| 32 |
Cmfc1App::Cmfc1App() |
| 33 |
{ |
| 34 |
// TODO: add construction code here, |
| 35 |
// Place all significant initialization in InitInstance |
| 36 |
} |
| 37 |
|
| 38 |
// The one and only Cmfc1App object |
| 39 |
|
| 40 |
Cmfc1App theApp; |
| 41 |
|
| 42 |
// Cmfc1App initialization |
| 43 |
|
| 44 |
BOOL Cmfc1App::InitInstance() |
| 45 |
{ |
| 46 |
// InitCommonControls() is required on Windows XP if an application |
| 47 |
// manifest specifies use of ComCtl32.dll version 6 or later to enable |
| 48 |
// visual styles. Otherwise, any window creation will fail. |
| 49 |
InitCommonControls(); |
| 50 |
|
| 51 |
CWinApp::InitInstance(); |
| 52 |
|
| 53 |
// Initialize OLE libraries |
| 54 |
if (!AfxOleInit()) { |
| 55 |
AfxMessageBox(IDP_OLE_INIT_FAILED); |
| 56 |
return FALSE; |
| 57 |
} |
| 58 |
AfxEnableControlContainer(); |
| 59 |
// Standard initialization |
| 60 |
// If you are not using these features and wish to reduce the size |
| 61 |
// of your final executable, you should remove from the following |
| 62 |
// the specific initialization routines you do not need |
| 63 |
// Change the registry key under which our settings are stored |
| 64 |
// TODO: You should modify this string to be something appropriate |
| 65 |
// such as the name of your company or organization |
| 66 |
SetRegistryKey(_T("Local AppWizard-Generated Applications")); |
| 67 |
LoadStdProfileSettings(4); // Load standard INI file options (including MRU) |
| 68 |
// Register the application's document templates. Document templates |
| 69 |
// serve as the connection between documents, frame windows and views |
| 70 |
CMultiDocTemplate* pDocTemplate; |
| 71 |
pDocTemplate = |
| 72 |
new CMultiDocTemplate(IDR_mfc1TYPE, RUNTIME_CLASS(Cmfc1Doc), |
| 73 |
RUNTIME_CLASS(CChildFrame), // custom MDI child frame |
| 74 |
RUNTIME_CLASS(Cmfc1View)); |
| 75 |
if (!pDocTemplate) |
| 76 |
return FALSE; |
| 77 |
AddDocTemplate(pDocTemplate); |
| 78 |
// create main MDI Frame window |
| 79 |
CMainFrame* pMainFrame = new CMainFrame; |
| 80 |
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) |
| 81 |
return FALSE; |
| 82 |
m_pMainWnd = pMainFrame; |
| 83 |
// call DragAcceptFiles only if there's a suffix |
| 84 |
// In an MDI app, this should occur immediately after setting m_pMainWnd |
| 85 |
// Enable drag/drop open |
| 86 |
m_pMainWnd->DragAcceptFiles(); |
| 87 |
// Enable DDE Execute open |
| 88 |
EnableShellOpen(); |
| 89 |
RegisterShellFileTypes(TRUE); |
| 90 |
// Parse command line for standard shell commands, DDE, file open |
| 91 |
CCommandLineInfo cmdInfo; |
| 92 |
ParseCommandLine(cmdInfo); |
| 93 |
// Dispatch commands specified on the command line. Will return FALSE if |
| 94 |
// app was launched with /RegServer, /Register, /Unregserver or /Unregister. |
| 95 |
if (!ProcessShellCommand(cmdInfo)) |
| 96 |
return FALSE; |
| 97 |
// The main window has been initialized, so show and update it |
| 98 |
pMainFrame->ShowWindow(m_nCmdShow); |
| 99 |
pMainFrame->UpdateWindow(); |
| 100 |
return TRUE; |
| 101 |
} |
| 102 |
|
| 103 |
// CAboutDlg dialog used for App About |
| 104 |
|
| 105 |
class CAboutDlg : public CDialog |
| 106 |
{ |
| 107 |
public: |
| 108 |
CAboutDlg(); |
| 109 |
|
| 110 |
// Dialog Data |
| 111 |
enum |
| 112 |
{ |
| 113 |
IDD = IDD_ABOUTBOX |
| 114 |
}; |
| 115 |
|
| 116 |
protected: |
| 117 |
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support |
| 118 |
|
| 119 |
// Implementation |
| 120 |
protected: |
| 121 |
DECLARE_MESSAGE_MAP() |
| 122 |
}; |
| 123 |
|
| 124 |
CAboutDlg::CAboutDlg() |
| 125 |
: CDialog(CAboutDlg::IDD) |
| 126 |
{ |
| 127 |
} |
| 128 |
|
| 129 |
void CAboutDlg::DoDataExchange(CDataExchange* pDX) |
| 130 |
{ |
| 131 |
CDialog::DoDataExchange(pDX); |
| 132 |
} |
| 133 |
|
| 134 |
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) |
| 135 |
END_MESSAGE_MAP() |
| 136 |
|
| 137 |
// App command to run the dialog |
| 138 |
void Cmfc1App::OnAppAbout() |
| 139 |
{ |
| 140 |
CAboutDlg aboutDlg; |
| 141 |
aboutDlg.DoModal(); |
| 142 |
} |
| 143 |
|
| 144 |
// Cmfc1App message handlers |