获取WNDPROC的Windows句柄 [英] Get the WNDPROC for windows handle

查看:535
本文介绍了获取WNDPROC的Windows句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存在任何Windows api函数以检索Windows处理程序的 WNDPROC

Exist any Windows api function to retrieve the WNDPROC for a Windows Handle?

/ p>

Thanks in advance.

推荐答案

使用

Use GetWindowLongPtr(hwnd, GWLP_WNDPROC).

小心:GetWindowLongPtr实际上是 #define d为GetWindowLong 32位系统,所以为了导入它在Delphi,你可能需要使用GetWindowLong代替。此外,GetWindowLongPtr本身 #define d为GetWindowLongPtrA或GetWindowLongPtrW(非unicode和unicode目标),所以再次你可能需要手动选择正确的名称为德尔福如果导入系统不是很聪明。

Caution: GetWindowLongPtr is actually #defined to GetWindowLong for 32-bit systems, so in order to import it in Delphi you might need to use GetWindowLong instead. As well, GetWindowLongPtr itself is #defined to either GetWindowLongPtrA or GetWindowLongPtrW (for non-unicode and unicode targets), so again you might need to choose the right name manually for Delphi if the import system there is not really smart.

记住,如果你打算调用获取的窗口proc,应该使用 CallWindowProc 。感谢@In silico的提示。

Remember that if you are going to call the obtained window proc, you should do it using CallWindowProc. Thanks to @In silico for the hint.

请注意,返回的值并不总是真正的指针窗口过程。有时它只是一种句柄,它被 CallWindowProc 识别并正确处理。例如,如果您的应用程序是ANSI,但是该窗口属于Unicode组件(反之亦然),则不会获得真正的函数指针。请参阅此发布在旧新事物 em> 了解详情。

Please note that the value which is returned is not always the real pointer to the window procedure. Sometimes it's just a kind of handle which is recognized and correctly processed by CallWindowProc. For example, you'll not get the real function pointer if your application is ANSI, but the window belongs to a Unicode component (or vice versa). See this posting in The Old New Thing for more details.

这篇关于获取WNDPROC的Windows句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆