C++ dialog based program framework instances

  • 2020-04-02 02:51:37
  • OfStack

This article illustrates the framework of C++ dialog-based programs. Share with you for your reference. The details are as follows:

Resource. CPP source file is as follows:

#include "resource.h"  
 
CMyApp theApp; 
 
BOOL CMyApp::InitInstance() 

    CMainDialog dlg; 
    m_pMainWnd = &dlg;   //M_pMainWnd main window & PI; < br / >     dlg.DoModal(); 
    return FALSE; //Does not enter the message loop & NBSP; < br / > } 
 
 
BEGIN_MESSAGE_MAP(CMainDialog, CDialog) 
ON_BN_CLICKED(IDC_STOP, OnStop) 
ON_MESSAGE(WM_CUTTERSTART, OnCutterStart) //Custom message & NBSP; < br / > END_MESSAGE_MAP() 
//CMainDialog 
CMainDialog::CMainDialog(CWnd* pParentWnd):CDialog(IDD_MAIN, pParentWnd) 

 

BOOL CMainDialog::OnInitDialog( ) 

    CDialog::OnInitDialog(); 
    return TRUE; 

void CMainDialog::OnStop() 

    MessageBox("OnStop"); 

long CMainDialog::OnCutterStart(WPARAM wParam, LPARAM lParam)   // To deal with Custom message & NBSP; < br / > { 
    MessageBox("OnCutterStart"); 
    return 0; 
}

Resource-h header file is as follows:

#include <afxwin.h>  
#define  WM_CUTTERSTART WM_USER+100 
//CMyApp 
class CMyApp:public CWinApp 

public: 
    BOOL InitInstance(); 
}; 
 
//CMyDialog 
class CMainDialog:public CDialog 

public: 
    CMainDialog(CWnd* pParentWnd = NULL); 
 
protected: 
    virtual BOOL OnInitDialog( ); 
    afx_msg void OnStop(); 
    afx_msg long OnCutterStart(WPARAM wParam, LPARAM lParam);  //Processing a custom message declaration & NBSP; < br / >  
    DECLARE_MESSAGE_MAP() 
};

Hope that the article described in the C++ programming to help you.


Related articles: