点点滴滴访问量:
 

1.在窗体头文件(如:MyDlg.h)中声明消息处理函数OnButton1                         

protected:

      // Generated message map functions

      //{{AFX_MSG(CMyDlg)

      afx_msg void OnButton1();

      //}}AFX_MSG

2.MyDlg.cpp源文件开头部分的消息映射入口,添加相应的消息映射宏:                 
  
这段代码,表明消息及其处理函数之间的联系。当用户单击按钮控件IDC_BUTTON1 时,
  系统将自动调用
OnButton1函数。

BEGIN_MESSAGE_MAP(CMyDlg, CDialog)

      //{{AFX_MSG_MAP(CMyDlg)

      ON_BN_CLICKED(IDC_BUTTON1, OnButton1)

      //}}AFX_MSG_MAP

END_MESSAGE_MAP()

3.MyDlg.cpp文件中写入一个空的消息处理函数的模板,以便用户填入具体代码,如下面的框架:

      void CMyDlg::OnButton1()

{

      // TODO: Add your control notification handler code here

     

}

在消息映射函数体框架中用户可以添加一些代码,例如:

      void CMyDlg::OnButton1()

{

      // TODO: Add your control notification handler code here

      MessageBox(“消息映射机制!”);

}

posted on 2008-05-22 17:28  sopper  阅读(757)  评论(0编辑  收藏  举报