void a::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CWnd* cwnd=WindowFromPoint(point);
if(cwnd!=NULL)
{
if(IsChild(cwnd))//==0
{
CString str="你好";
SetWindowText(str);
}
else
{
CString st;
cwnd->GetWindowText(st);
AfxMessageBox(st);
}
} CButton::OnMouseMove(nFlags, point);
}a是Cutton的派生类,本来是想鼠标移到按钮就触发事件的,按钮是子窗口啦,但现在它执行第二个选择,也就是说cwnd不是子窗口,好像CWnd* cwnd=WindowFromPoint(point);获取了当前屏幕的窗口了?????实在不懂
{
// TODO: Add your message handler code here and/or call default
CWnd* cwnd=WindowFromPoint(point);
if(cwnd!=NULL)
{
if(IsChild(cwnd))//==0
{
CString str="你好";
SetWindowText(str);
}
else
{
CString st;
cwnd->GetWindowText(st);
AfxMessageBox(st);
}
} CButton::OnMouseMove(nFlags, point);
}a是Cutton的派生类,本来是想鼠标移到按钮就触发事件的,按钮是子窗口啦,但现在它执行第二个选择,也就是说cwnd不是子窗口,好像CWnd* cwnd=WindowFromPoint(point);获取了当前屏幕的窗口了?????实在不懂
至于你的问题,point参数是相对于当前窗口的左上角座标的,而WindowFromPoint需要的是一个针对桌面座标体系的座标,因此你需要ClientToScreen先转换座标才行