获得指定点的窗口

yuan0716 2009-08-28 08:25:38
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个错误,在不知道哪里错了,请大家指教。
...全文
101 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yhn353232494 2012-09-02
  • 打赏
  • 举报
回复

BOOL CDemo1Dlg::PreTranslateMessage(MSG *pMsg)
{
if(pMsg->message==WM_MOUSEMOVE)
{
CPoint point(LOWORD(pMsg->lParam),HIWORD(pMsg->lParam));
::ClientToScreen(pMsg->hwnd, &point);//客户坐标转换屏幕坐标

OnMouseMove(0,point);
}
return CDialog::PreTranslateMessage(pMsg);

}
并且删掉CDialog::OnMouseMove(nFlags,point);
你这里没有OnMouseMove
只有OnButton3
yuan0716 2009-08-28
  • 打赏
  • 举报
回复
谢谢帮忙,仔细查一下
youyifang 2009-08-28
  • 打赏
  • 举报
回复
第一个,OnButton3没有定义或者定义的参数类型和实现的参数类型不同,检查下
第二个,'IParam' 改成lParam,要注意大小写.
LZ转个开发工具吧,Visual.Assist.X,可以方便你编写代码.
yuan0716 2009-08-28
  • 打赏
  • 举报
回复
去了也不行,我跟着书做的,这书错误太多了。
feilinhe 2009-08-28
  • 打赏
  • 举报
回复
跟着做的,那就是要注意变电副哈偶的全角于半角了,等等的
出错了最好把错误代码贴出来~
shihaojie1219 2009-08-28
  • 打赏
  • 举报
回复
错误代码a
yuan0716 2009-08-28
  • 打赏
  • 举报
回复
error C2511: 'OnButton3' : overloaded member function 'void (unsigned int,class CPoint)' not found in 'CBDlg'
c:\documents and settings\administrator\桌面\b\bdlg.h(14) : see declaration of 'CBDlg'
error C2039: 'IParam' : is not a member of 'tagMSG'
c:\program files\microsoft visual studio\vc98\include\winuser.h(1226) : see declaration of 'tagMSG'
error C2039: 'IParam' : is not a member of 'tagMSG'
c:\program files\microsoft visual studio\vc98\include\winuser.h(1226) : see declaration of 'tagMSG'
fishion 2009-08-28
  • 打赏
  • 举报
回复
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); //去掉
}

在一个button事件中还有WM_MOUSEMOVE消息,这是什么回事
youyifang 2009-08-28
  • 打赏
  • 举报
回复
把错误贴出来.

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧