Get the WNDPROC for windows handle

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

Thanks in advance.


Use GetWindowLongPtr(hwnd, GWLP_WNDPROC).

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.

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.

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.

Need Your Help

How to Program for Leap Motion with Java

java leap-motion

I have downloaded everything for leap motion. The software, airspace store, and SDK. I unzipped the SDK folder, but don't know what to do next. Is there a separate SDK or do I import the libraries ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.