m_Edit是Edit控件的control变量,判断捕获到的“鼠标按下/抬起”消息中的hwnd成员变量,如果等于控件m_Edit的句柄,就表示鼠标是在这个控件上按下/抬起的。然后全选控件中的text。
BOOL CMyControlDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (WM_LBUTTONUP==pMsg->message)
{
if (m_Edit.m_hWnd==pMsg->hwnd)
{
SendDlgItemMessage(IDC_EDIT, EM_SETSEL, 0, -1);
}
}
return CDialog::PreTranslateMessage(pMsg);
}
第一次写,初学MFC