比如。当鼠标移到按钮上时候,需要主对话框上显示出鼠标在哪一个按钮上

BOOL CTextbuttonDlg::PreTranslateMessage(MSG* pMsg) 
{

CRect rectb;
GetDlgItem(IDC_BUTTON_B)
->GetWindowRect(&rectb);
if(rectb.PtInRect(pMsg->pt))
{
//SetDlgItemText(IDC_STATIC_TEXT,"");
CString str;
str
="鼠标在按钮B上";
SetDlgItemText(IDC_STATIC_TEXT,str);
}
// TODO: Add your specialized code here and/or call the base class
CRect rect;
GetDlgItem(IDC_BUTTON_A)
->GetWindowRect(&rect);
if(rect.PtInRect(pMsg->pt))
{
CString str;
str
="鼠标在按钮A上";
SetDlgItemText(IDC_STATIC_TEXT,str);
}

return CDialog::PreTranslateMessage(pMsg);
}这里需要在PreTranslateMessage(pMsg)提前捕获鼠标消息。否则的话按钮控件捕获的鼠标消息,对话框是不知道的

相关文章:

  • 2021-07-12
  • 2021-09-15
  • 2022-12-23
  • 2021-11-06
  • 2022-01-24
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2021-11-05
  • 2021-05-29
相关资源
相似解决方案