How i can cast a WNDPROC to a TWndMethod

How i can cast a WNDPROC to a TWndMethod

so far i try this but give me a invalid typecast error.

 TWndMethod(Pointer(GetWindowLong(FHandle, GWL_WNDPROC)));

Answers


If you want to subclass a window handle (using SetWindowLong) to process window messages in TWndMethod function, you should not cast the value returned by GetWindowLong(FHandle, GWL_WNDPROC) to TWndMethod. You should use MakeObjectInstance function to obtain a value that can be passed to SetWindowLong instead. Read Sertac Akuyz answer for a general idea.

Note that the need to subclass a window handle is very rare in Delphi applications. Delphi provides several other ways to interfere into window message processing, they are more simple and safe.


Need Your Help

HTTP POST call from Android

java php android web-services

I'm trying to send data to an PHP webservice trough POST from an Android app... It always returns:

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.