MFC的消息映射机制

    xiaoxiao2021-12-14  17

    1.头文件中:

    //{{AFX_MSG(CMainFrame)​

    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

    // NOTE - the ClassWizard will add and remove member functions here.

    //    DO NOT EDIT what you see in these blocks of generated code!

    //}}AFX_MSG

    afx_msg void OnHello();

    DECLARE_MESSAGE_MAP()

    2.源文件中

    BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)

    //{{AFX_MSG_MAP(CMainFrame)

    // NOTE - the ClassWizard will add and remove mapping macros here.

    //    DO NOT EDIT what you see in these blocks of generated code !

    ON_WM_CREATE()

    //}}AFX_MSG_MAP

    ON_COMMAND(IDM_HELLO,OnHello)

    END_MESSAGE_MAP()

    3.源文件中

    void CMainFrame::OnHello()

    {

    MessageBox("MainFrame hello");

    }

    转载请注明原文地址: https://ju.6miu.com/read-962959.html

    最新回复(0)