A simple example of building an MFC form

  • 2020-04-02 02:18:49
  • OfStack


#include<afxwin.h>//Contains the MFC header file
//Derive the user form class from the main framework form of MFC
class CMyWnd:public CFrameWnd
{
public:
 CMyWnd(LPCTSTR szTitle)
 {
  //Call the parent Create function to Create the form
  Create(NULL,szTitle);
 }
};
//Derived user program classes from MFC applications
class CMyApp:public CWinApp
{
public:
 virtual BOOL InitInstance();
};
//An application that overrides inheritance initializes virtual functions
BOOL CMyApp::InitInstance()
{
 //Create the form and save it to m_pMainWnd
 m_pMainWnd = new CMyWnd(_T(" A simple MFC The program "));
 m_pMainWnd->ShowWindow(m_nCmdShow);
 return TRUE;
}
CMyApp myApp;


Related articles: