VC 当鼠标移到不同的按钮下时在一个静态文本中显示不同的字
   我知道用WM_MOUSEMOVE    希望得到具体的答案
   最好有代码

解决方案 »

  1.   

    BOOL CXXDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(WM_MOUSEMOVE == pMsg->message)
    {
    CPoint point;
    GetCursorPos(&point);
    CWnd* pWnd = WindowFromPoint(point);
    if(pWnd)
    {
    CString strText(_T(""));
    pWnd->GetWindowText(strText);
    SetDlgItemText(IDC_STATIC1, strText);
    }
    }
    return CDialog::PreTranslateMessage(pMsg);
    }
      

  2.   

    谁说没刷新上一次的内容,除非你设置了CStatic控件的背景为透明,自己去改
      

  3.   

    你想要界面好看你就得自己画
    这个问题你重载CStatic自绘一下就可以了
    VisualEleven已经把你问的问题解决了
    剩下的你自己做不就好了
      

  4.   

    呵呵,小a火气好大:)看你说的情况,莫非你改了对话框的背景色,或有背景图?
    如果是背景色的话,相信你知道方法——对话框响应OnCtlColor,
    返回你自己的画刷就行了。如果是背景图,恐怕得用图案画刷或者
    位图画刷了。另一个办法,在SetDlgItemText之前,调一下
    pWnd->Invalidate();
    pWnd-<UpdateWindow();
    不知道行不行。
      

  5.   

    lz问问题要谦虚一点,不管是谁回答你的问题,不管他说的对不对,你至少要表示起码的尊重,这个是做人的最起码基本原则先用背景色把要显示的CStatic文本区域刷新一下,然后再SetWindowTextBOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(WM_MOUSEMOVE == pMsg->message)
    {
    CPoint point;
    GetCursorPos(&point);
    CWnd* pWnd = WindowFromPoint(point);
    if(pWnd)
    {
    CString strText(_T(""));
    pWnd->GetWindowText(strText);
    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_STATIC1);

    CRect rc;
    pEdit->GetWindowRect(rc);
    ScreenToClient(rc); InvalidateRect(&rc); pEdit->SetWindowText(strText);
    }
    }
    return CDialog::PreTranslateMessage(pMsg);
    }