summaryrefslogtreecommitdiffstats
path: root/Tests/MFC/mfc1/mfc1.cpp
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-10-24 20:55:52 (GMT)
committerDavid Cole <david.cole@kitware.com>2011-11-01 14:08:58 (GMT)
commit36b0c432cf5804ec45367066e34f4c38165d5c09 (patch)
tree0c318628e7990a2e43b2f8a186f997b537a9f95f /Tests/MFC/mfc1/mfc1.cpp
parent89742d73cc684a78586fad2497048d9329c1160e (diff)
downloadCMake-36b0c432cf5804ec45367066e34f4c38165d5c09.zip
CMake-36b0c432cf5804ec45367066e34f4c38165d5c09.tar.gz
CMake-36b0c432cf5804ec45367066e34f4c38165d5c09.tar.bz2
Tests: Add the MFC test (#11213)
Build a simple, do-nothing VS 7.1 MFC wizard generated app with CMake. Build it two different ways via ExternalProject, one with CMAKE_MFC_FLAG set to 1 for linking to MFC statically, and one with CMAKE_MFC_FLAG set to 2 for linking to the shared MFC dlls. Validate that the install tree of the static build has only one *.exe file in it and nothing else. Also validate that the install tree of the shared library build has multiple files in it (no less than 3) and that they are only of the expected types *.exe, *.dll and *.manifest. This commit does not address the issue reported in #11213, it merely adds a test that may be used to show that the bug report is valid. After this commit, the MFC test should fail on any dashboard machines that have MSVC defined, but cannot build an MFC app. We can then analyze that failure data as input to solving the issue.
Diffstat (limited to 'Tests/MFC/mfc1/mfc1.cpp')
-rw-r--r--Tests/MFC/mfc1/mfc1.cpp144
1 files changed, 144 insertions, 0 deletions
diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp
new file mode 100644
index 0000000..9530cd2
--- /dev/null
+++ b/Tests/MFC/mfc1/mfc1.cpp
@@ -0,0 +1,144 @@
+// mfc1.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "mfc1.h"
+#include "MainFrm.h"
+
+#include "ChildFrm.h"
+#include "mfc1Doc.h"
+#include "mfc1View.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// Cmfc1App
+
+BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp)
+ ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
+ // 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()
+
+
+// Cmfc1App construction
+
+Cmfc1App::Cmfc1App()
+{
+ // TODO: add construction code here,
+ // Place all significant initialization in InitInstance
+}
+
+
+// The one and only Cmfc1App object
+
+Cmfc1App theApp;
+
+// Cmfc1App initialization
+
+BOOL Cmfc1App::InitInstance()
+{
+ // InitCommonControls() is required on Windows XP if an application
+ // manifest specifies use of ComCtl32.dll version 6 or later to enable
+ // visual styles. Otherwise, any window creation will fail.
+ InitCommonControls();
+
+ CWinApp::InitInstance();
+
+ // Initialize OLE libraries
+ if (!AfxOleInit())
+ {
+ AfxMessageBox(IDP_OLE_INIT_FAILED);
+ return FALSE;
+ }
+ AfxEnableControlContainer();
+ // 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
+ // 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(4); // 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
+ CMultiDocTemplate* pDocTemplate;
+ pDocTemplate = new CMultiDocTemplate(IDR_mfc1TYPE,
+ RUNTIME_CLASS(Cmfc1Doc),
+ RUNTIME_CLASS(CChildFrame), // custom MDI child frame
+ RUNTIME_CLASS(Cmfc1View));
+ if (!pDocTemplate)
+ return FALSE;
+ AddDocTemplate(pDocTemplate);
+ // create main MDI Frame window
+ CMainFrame* pMainFrame = new CMainFrame;
+ if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
+ return FALSE;
+ m_pMainWnd = pMainFrame;
+ // call DragAcceptFiles only if there's a suffix
+ // In an MDI app, this should occur immediately after setting m_pMainWnd
+ // Enable drag/drop open
+ m_pMainWnd->DragAcceptFiles();
+ // Enable DDE Execute open
+ EnableShellOpen();
+ RegisterShellFileTypes(TRUE);
+ // Parse command line for standard shell commands, DDE, file open
+ CCommandLineInfo cmdInfo;
+ ParseCommandLine(cmdInfo);
+ // Dispatch commands specified on the command line. Will return FALSE if
+ // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
+ if (!ProcessShellCommand(cmdInfo))
+ return FALSE;
+ // The main window has been initialized, so show and update it
+ pMainFrame->ShowWindow(m_nCmdShow);
+ pMainFrame->UpdateWindow();
+ return TRUE;
+}
+
+
+
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+ CAboutDlg();
+
+// Dialog Data
+ enum { IDD = IDD_ABOUTBOX };
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+
+// Implementation
+protected:
+ DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+END_MESSAGE_MAP()
+
+// App command to run the dialog
+void Cmfc1App::OnAppAbout()
+{
+ CAboutDlg aboutDlg;
+ aboutDlg.DoModal();
+}
+
+
+// Cmfc1App message handlers