功能:在界面上,光标移动到某个控件(如按钮Button)上,则在Static文本控件上提示相关信息。
1. 利用消息捕获实现。 BOOL C**Dlg::PreTranslateMessage(MSG* pMSG) { // TODO: Add your specialized code here and/or call the base class if (pMSG->message == WM_MOUSEMOVE) { POINT Point; GetCursorPos(&Point); CRect rect; GetDlgItem(IDC_BUTTON_INFO)->GetWindowRect(&rect); if (rect.PtInRect(Point)) GetDlgItem(IDC_STATIC_INFO)->SetWindowTextW(_T("你终于移到我身上了,哈哈!")); else GetDlgItem(IDC_STATIC_INFO)->SetWindowTextW(_T("提示信息:......")); } return CDialog::PreTranslateMessage(pMSG); }
2. 结果截图