16,466
社区成员
发帖
与我相关
我的任务
分享
switch (GetDlgCtrlID())
case IDC_BUTTON1:
break;
.........
BOOL CXXXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
HWND hWnd = pMsg->hwnd;
TCHAR szClassName[MAX_PATH] = {0};
GetClassName(hWnd, szClassName, MAX_PATH);
if(0 == _tcscmp(szClassName, _T("Button")))
{
CDialog::PreTranslateMessage(pMsg);
CString str;
UINT nID = ::GetDlgCtrlID(hWnd);
str.Format(_T("ID: %d"), nID);
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
{
str += _T("DOWN");
::SetWindowText(hWnd, str);
}
break;
case WM_LBUTTONUP:
{
str += _T("UP");
::SetWindowText(hWnd, str);
}
break;
default:
break;
}
return TRUE;
}
else
{
return CDialog::PreTranslateMessage(pMsg);
}
}