I notice that win64's classes.pp includes stubs for AllocateHWnd and MakeObjectInstance. Perhaps we could hear from the FPC team about whether they plan to add these functions to other platforms.
In Delphi AllocateHWnd calls MakeObjectInstance to convert the object method to a WindowProc callback function. It does this by poking processor instructions into a block of memory similar to this: http://www.swissdelphicenter.ch/en/showcode.php?id=1671 Felipe's implementation, which instead stores the object method's code and data pointers (4 bytes) in the window's user data, which is retrieved by the actual callback function to reconstitute the object method and call it, is cleaner and potentially cross-platform: SetWindowLong(hWnd, GWL_USERDATA, PtrInt(PMethod)); This appporach works fine with Lazarus on Windows, but not at all on other widgetsets. Currently the other widgetsets either do not implement Set/GetWindowLong or, if they do (GTK), the window callback function is never called. This ability to redirect a window's message handling to your own method (MakeObjectInstance) or to create a hidden window that responds to messages is potentially very useful. For example, Orpheus uses MakeObjectInstance for data validation. Adapting Felipe's code I was able to create a workaround that enabled validation in Orpheus's TO32FlexeEdit control, but currently this works only with the win32 widgetset. As another example, Orpheus's TOvcTimerPool uses AllocateHWnd to create a hidden window to catch timer messages. It seems like these two functions would be useful things to have around, even if their usefulness is not always obvious. _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
