分类: WINDOWS
2010-02-01 19:22:08
(1)重载PreTranslateMessage
重载主窗口的PreTranslateMessage函数就可以,判断是发给Edit控件的双击消息后把控件进行处理,如下:
BOOL CYourDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->hwnd == m_Edit.m_hWnd && pMsg->message == WM_LBUTTONDBLCLK) // do something return Cdialog::PreTranslateMessage(pMsg); } (2) 派生类: 从新派生一个CEdit类 在头文件中添加: //{{AFX_MSG(CMyEdit)
//NOTE-the ClassWizard will add and remove memb functions here.
afx_msg void OnLButtonDblClk( UINT nFlags, Cpoint point );
//}}AFX_MSG 在cpp文件中添加: BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_LBUTTONDBLCLK()
//}}AFX_MSG_MAP
END_MESSAGE_MAP() /////////////////////////////////////////////////////////////////////////////
//CmyEdit message handlers
void CmyEdit::OnLButtonDblClk(UINT nFlags, CPoint point)
{
//TODO: Add your message handler code here and/or call default
Cedit::OnLButtonDblClk(nFlags, point);
}