MFC BEGIN_MESSAGE_MAP() ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() <轉>

1 BEGIN_MESSAGE_MAP(CpassApp, CWinApp)
2     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
3 END_MESSAGE_MAP()


這些都是宏定義,不是函數。
在BEGIN_MESSAGE_MAP()和END_MESSAGE_MAP()之間添加你的消息響應函數,爲每一個消息處理函數加入一個入口
函數

 



BEGIN_MESSAGE_MAP( theClass, baseClass )

參數:this

theClass 指定消息映射所屬的類的名字。
baseClass 指定theClass的基類的名字。


說明:
使用BEGIN_MESSAGE_MAP宏開始你的消息映射的定義。
在你的類的成員函數的實現文件(.CPP)中,使用BEGIN_MESSAGE_MAP宏開始消息映射,而後爲每一個消息處理函數加入一個入口,最後用END_MESSAGE_MAP宏結束消息映射。spa


每一個消息映射入口的格式以下:
  ON_Notification(id, memberFxn)
  其中id指定了發送通知的控件的子窗口的ID,而memberFxn指定了處理該通知的父對象中的成員函數名
  父對象的函數原型格式以下:
  afx_msg void memberFxn( );

  可能的消息映射入口以下:對象

映射入口 什麼時候向父對象發送消息
ON_BN_CLICKED   用戶單擊按鈕時
ON_BN_DOUBLECLICKED 用戶雙擊按鈕時


例如:ci

1 BEGIN_MESSAGE_MAP(CpassDlg, CDialog)
2     ON_WM_SYSCOMMAND()
3     ON_WM_PAINT()
4     ON_WM_QUERYDRAGICON()
5      // }}AFX_MSG_MAP
6     ON_BN_CLICKED(IDOK, OnOK)
7     ON_BN_CLICKED(IDCANCEL, OnExit)
8 END_MESSAGE_MAP()

void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam)原型

這個函數響應系統控制菜單的命令.(即左上角圖標處)。it

OnSysCommand:The framework calls this member function when the user selects a command from the Control menu, or when the user selects the Maximize or the Minimize button. io

另外:table

DoDataExchange:當UpdateData時候function

OnInitDialog:對話框類已經構造,可是對話框尚未顯示出來的時候

OnQueryDragIcon:The framework calls this member function by a minimized (iconic) window that does not have an icon defined for its class. The system makes this call to obtain the cursor to display while the user drags the minimized window.

相關文章
相關標籤/搜索