ON_NOTIFY的创建及使用

1.定义NOTIFY消息

#define NM_MOUSEUP              (NM_FIRST-25)

2.定义结构(任意结构)

typedef struct tagNMLVSELFDEFINEDATA
{
 NMHDR   hdr;
 int     iStatus;
 PVOID myData;
} NMLVSELFDEFINEDATA, *LPNMLVSELFDEFINEDATA;

3.发送NOTIFY消息

NMLVSELFDEFINEDATA dispinfo = {0};
 dispinfo.hdr.code = NM_MOUSEUP;
 dispinfo.hdr.hwndFrom = m_hWnd;
 dispinfo.hdr.idFrom = GetDlgCtrlID();
 dispinfo.iStatus = -1;
 dispinfo.myData = NULL;
 ::SendMessage(this->GetParent()->m_hWnd, WM_NOTIFY, GetDlgCtrlID(), (LPARAM) &dispinfo);

 

4.接收控件ON_NOTIFY消息

BEGIN_MESSAGE_MAP(TF_PhotoGroupDlg, CDialog)
 //{{AFX_MSG_MAP(TF_PhotoGroupDlg)
   ON_NOTIFY(NM_MOUSEUP, IDC_LIST_PHOTO, OnMouseUpListPhoto)
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

 

5..h中设置OnMouseUpListPhoto

//{{AFX_MSG(TF_PhotoGroupDlg)

  afx_msg void OnMouseUpListPhoto(NMHDR* pNMHDR, LRESULT* pResult);
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()

 

6.CPP中设置消息

void TF_PhotoGroupDlg::OnMouseUpListPhoto(NMHDR* pNMHDR, LRESULT* pResult)
{

}

 

结束。

posted on 2011-03-24 15:59  carekee  阅读(6351)  评论(0)    收藏  举报