RealChildWindowFromPoint为何编译时找不到声明?

galey 2003-12-03 09:33:16
我在自己的程序中用刀函数RealChildWindowFromPoint,但是编译的时候系统总是提示RealChildWindowFromPoint' : undeclared identifier
和cannot convert from 'int' to 'struct HWND__ *'的编译错误。
RealChildWindowFromPoint在Winuser.h中的确有定义,但是为什么找不到呢?我的环境是WIN2000 server +sp4,VC6.0+sp4。
希望哪位大侠指点一二。
...全文
102 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
galey 2003-12-03
  • 打赏
  • 举报
回复
OK,问题解决,在这里感谢所有回帖的大侠们。
结贴,给分。
谢谢!谢谢!谢谢!谢谢!
dxp 2003-12-03
  • 打赏
  • 举报
回复
是的
WINAPI声明决定了函数参数压栈顺序
galey 2003-12-03
  • 打赏
  • 举报
回复
谢谢arvid_gs(west):能把源代码发给我看看吗。
superpenguins@sina.com,结贴一定给分。
flyelf 2003-12-03
  • 打赏
  • 举报
回复
你的代码对RealChildWindowFromPoint声明有问题,应该如 arvid_gs(west) 所说的定义
typedef HWND (WINAPI *REALCHILDWINDOWFROMPOINT)(HWND, POINT);
其中winapi不能少
arvid_gs 2003-12-03
  • 打赏
  • 举报
回复
typedef HWND (WINAPI *REALCHILDWINDOWFROMPOINT)(HWND hwndParent, POINT ptParentClientCoords);
HMODULE hUser32 = ::LoadLibrary("User32.dll");
if (hUser32)
{
REALCHILDWINDOWFROMPOINT fnRealWndFromPoint = (REALCHILDWINDOWFROMPOINT)GetProcAddress(hUser32, "RealChildWindowFromPoint");
}
galey 2003-12-03
  • 打赏
  • 举报
回复
我是这样调用的:
HWND (*ptfnRealChildWindowFromPoint)(HWND hwndParent,POINT ptParentClientCoords);

HMODULE hMdl = LoadLibrary("USER32.DLL");
ptfnRealChildWindowFromPoint = (HWND (*)(HWND hwndParent,POINT ptParentClientCoords))GetProcAddress(hMdl,"RealChildWindowFromPoint");
hWndChild = ptfnRealChildWindowFromPoint(*phWnd, ptCooChild);

但是一执行到上面这一句就报错:
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
真的是我声明错误吗?还是函数的调用转换错误。
arvid_gs 2003-12-03
  • 打赏
  • 举报
回复
这样搞把,好像2000中这个函数看不到了,这是个例子看看,我还有全部代码,如果你要,发消息给我!
typedef HWND (WINAPI *REALCHILDWINDOWFROMPOINT)(HWND hwndParent, POINT ptParentClientCoords);

CWnd* CMiniSpyDlg::RealWindowFromPoint(CPoint ptHitTest)
{
CWnd* pWnd = WindowFromPoint(ptHitTest);

if (pWnd && (pWnd->GetStyle() & WS_CHILD))
{
// now check that another control is not being masked by say a group box
CWnd* pParent = pWnd->GetParent();

if (pParent)
{
// have to call
HMODULE hUser32 = ::LoadLibrary("User32.dll");

if (hUser32)
{
// note this function is not available under win95 so we also have a fallback
REALCHILDWINDOWFROMPOINT fnRealWndFromPoint = (REALCHILDWINDOWFROMPOINT)GetProcAddress(hUser32, "RealChildWindowFromPoint");

if (fnRealWndFromPoint)
{
// convert to parent client coords
pParent->ScreenToClient(&ptHitTest);

HWND hHit = fnRealWndFromPoint(*pParent, ptHitTest);

if (hHit)
pWnd = CWnd::FromHandle(hHit);
}
else
{
// iterate all the child controls of the parent until we hit one which
// does not return HTTRANSPARENT or HTNOWHERE to WM_NCHITTEST
CWnd* pChild = pParent->GetWindow(GW_CHILD);
ASSERT (pChild);

while (pChild)
{
UINT uHitTest = pChild->SendMessage(WM_NCHITTEST, 0, MAKELPARAM(ptHitTest.x, ptHitTest.y));

if ((int)uHitTest > 0)
{
pWnd = pChild;
break;
}

pChild = pChild->GetNextWindow();
}
}
}
}
}

return pWnd;
}
flyelf 2003-12-03
  • 打赏
  • 举报
回复
就用LoadLibrary和GetProcAddr来获取这个地址,然后使用
galey 2003-12-03
  • 打赏
  • 举报
回复
现在的情况是直接用MFC生成框架,只有这么几句代码,最简单的测试:
HWND hwnd;
POINT ptP;

//hwnd,ptP的都有值

RealChildWindowFromPoint(hwnd,ptP);

然后编译在上面这句就不能通过了,提示RealChildWindowFromPoint' : undeclared identifier这样的错误。

而且不管是否包含windows.h 和 winuser.h的结果都是一样的。
dlfour 2003-12-03
  • 打赏
  • 举报
回复
把你的代码贴出来看看
galey 2003-12-03
  • 打赏
  • 举报
回复
我包含了Windows.h,结果还是一样。
好像一般的情况下Windows.h,喝Winuser.h都不需要包含的呀,MFC生成框架文件自己本身就包含了。



FlyYang 2003-12-03
  • 打赏
  • 举报
回复
你包含Windows.h看看

---------
++C++
---------

16,473

社区成员

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

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

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