Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
4.7 KiB

  1. // host.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdinc.h"
  4. #include "host.h"
  5. #include "MainFrm.h"
  6. #include "ChildFrm.h"
  7. #include "hostDoc.h"
  8. #include "hostView.h"
  9. #include "SxApwHandle.h"
  10. #include "SxApwCreate.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. static ATL::CComModule Module;
  17. BEGIN_OBJECT_MAP(ObjectMap)
  18. /*
  19. OBJECT_ENTRY(__uuidof(CSxApwHostThunk), CSxApwHostThunk)
  20. OBJECT_ENTRY(__uuidof(CSxApwDataSourceThunk), CSxApwDataSourceThunk)
  21. OBJECT_ENTRY(__uuidof(CSxApwUiViewThunk), CSxApwUiViewThunk)
  22. OBJECT_ENTRY(__uuidof(CSxApwHostThunk), CSxApwHostThunk)
  23. */
  24. END_OBJECT_MAP()
  25. ATL::CComModule* GetModule() { return &Module; }
  26. ATL::_ATL_OBJMAP_ENTRY* GetObjectMap() { return ObjectMap; }
  27. const CLSID* GetTypeLibraryId() { return NULL; }
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CHostApp
  30. BEGIN_MESSAGE_MAP(CHostApp, CWinApp)
  31. //{{AFX_MSG_MAP(CHostApp)
  32. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  33. // NOTE - the ClassWizard will add and remove mapping macros here.
  34. // DO NOT EDIT what you see in these blocks of generated code!
  35. //}}AFX_MSG_MAP
  36. // Standard file based document commands
  37. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  38. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CHostApp construction
  42. CHostApp::CHostApp()
  43. {
  44. // TODO: add construction code here,
  45. // Place all significant initialization in InitInstance
  46. }
  47. /////////////////////////////////////////////////////////////////////////////
  48. // The one and only CHostApp object
  49. CHostApp theApp;
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CHostApp initialization
  52. BOOL CHostApp::InitInstance()
  53. {
  54. CoInitialize(NULL);
  55. _Module.Init(ObjectMap, GetModuleHandleW(NULL));
  56. AfxEnableControlContainer();
  57. // Standard initialization
  58. // If you are not using these features and wish to reduce the size
  59. // of your final executable, you should remove from the following
  60. // the specific initialization routines you do not need.
  61. #ifdef _AFXDLL
  62. Enable3dControls(); // Call this when using MFC in a shared DLL
  63. #else
  64. Enable3dControlsStatic(); // Call this when linking to MFC statically
  65. #endif
  66. // Change the registry key under which our settings are stored.
  67. // TODO: You should modify this string to be something appropriate
  68. // such as the name of your company or organization.
  69. SetRegistryKey(L"Local AppWizard-Generated Applications");
  70. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  71. // Register the application's document templates. Document templates
  72. // serve as the connection between documents, frame windows and views.
  73. CMultiDocTemplate* pDocTemplate;
  74. pDocTemplate = new CMultiDocTemplate(
  75. IDR_HOSTTYPE,
  76. RUNTIME_CLASS(CHostDoc),
  77. RUNTIME_CLASS(CChildFrame), // custom MDI child frame
  78. RUNTIME_CLASS(CHostView));
  79. AddDocTemplate(pDocTemplate);
  80. // create main MDI Frame window
  81. CMainFrame* pMainFrame = new CMainFrame;
  82. if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  83. return FALSE;
  84. m_pMainWnd = pMainFrame;
  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
  94. if (!ProcessShellCommand(cmdInfo))
  95. return FALSE;
  96. // The main window has been initialized, so show and update it.
  97. pMainFrame->ShowWindow(m_nCmdShow);
  98. pMainFrame->UpdateWindow();
  99. return TRUE;
  100. }
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CAboutDlg dialog used for App About
  103. class CAboutDlg : public CDialog
  104. {
  105. public:
  106. CAboutDlg();
  107. // Dialog Data
  108. //{{AFX_DATA(CAboutDlg)
  109. enum { IDD = IDD_ABOUTBOX };
  110. //}}AFX_DATA
  111. // ClassWizard generated virtual function overrides
  112. //{{AFX_VIRTUAL(CAboutDlg)
  113. protected:
  114. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  115. //}}AFX_VIRTUAL
  116. // Implementation
  117. protected:
  118. //{{AFX_MSG(CAboutDlg)
  119. // No message handlers
  120. //}}AFX_MSG
  121. DECLARE_MESSAGE_MAP()
  122. };
  123. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  124. {
  125. //{{AFX_DATA_INIT(CAboutDlg)
  126. //}}AFX_DATA_INIT
  127. }
  128. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  129. {
  130. CDialog::DoDataExchange(pDX);
  131. //{{AFX_DATA_MAP(CAboutDlg)
  132. //}}AFX_DATA_MAP
  133. }
  134. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  135. //{{AFX_MSG_MAP(CAboutDlg)
  136. // No message handlers
  137. //}}AFX_MSG_MAP
  138. END_MESSAGE_MAP()
  139. // App command to run the dialog
  140. void CHostApp::OnAppAbout()
  141. {
  142. CAboutDlg aboutDlg;
  143. aboutDlg.DoModal();
  144. }
  145. /////////////////////////////////////////////////////////////////////////////
  146. // CHostApp message handlers