获得指定点的窗口
void CBDlg::OnButton3(UINT nFlags,CPoint point)
{
// TODO: Add your control notification handler code here
CWnd* cwnd=WindowFromPoint(point);
if(cwnd!=NULL)
{
if(IsChild(pWnd))
{
CString str=_T("");
cwnd->GetWindowText(str);
SetWindowText(str);
}
}
CDialog::OnMouseMove(nFlags,point);
}
BOOL CBDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_MOUSEMOVE)
{
CPoint point(LOWORD(pMsg->IParam),HIWORD(pMsg->IParam));
OnMouseMove(0,point);
}
return CDialog::PreTranslateMessage(pMsg);
}
这里的例子是跟着数做的,功能是运行时,移动光标将获得光标所在的窗口,要是窗口是子窗口,将获得该窗口的文本并将其设置成主窗口的标题。
调试的时候出错,有3个错误,在不知道哪里错了,请大家指教。