user.cpp

来自「讲mfc的书」· C++ 代码 · 共 82 行

CPP
82
字号
// User.cpp : Defines the class behaviors
// for the application.
//

#include "stdafx.h"
#include "User.h"
#include "UserDlg.h"
#include "dispatch.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////
// CUserApp

BEGIN_MESSAGE_MAP(CUserApp, CWinApp)
   //{{AFX_MSG_MAP(CUserApp)
   //}}AFX_MSG
   ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

//////////////////////////////////////
// CUserApp construction

CUserApp::CUserApp()
   {
   // TODO: add construction code here,
   // Place all significant initialization in InitInstance
   }

//////////////////////////////////////
// The one and only CUserApp object

CUserApp theApp;

//////////////////////////////////////
// CUserApp initialization

BOOL CUserApp::InitInstance()
   {
   // Initialize OLE libraries
   if (!AfxOleInit())
      {
      AfxMessageBox(IDP_OLE_INIT_FAILED);
      return FALSE;
      }

#ifdef _AFXDLL
   Enable3dControls();
#else
   Enable3dControlsStatic();
#endif

   // Parse the command line
   if (RunEmbedded() || RunAutomated())
      {
      COleTemplateServer::RegisterAll();
      return TRUE;
      }

   COleObjectFactory::UpdateRegistryAll();

   CUserDlg dlg;
   m_pMainWnd = &dlg;
   int nResponse = dlg.DoModal();
   if (nResponse == IDOK)
      {
      IDispatcher disp;
      disp.CreateDispatch("Beeper");  // ProgID
      disp.Beep();
      }
   else if (nResponse == IDCANCEL)
      {
// No action
      }

   return FALSE;
   }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?