Sunday, December 16, 2007

SendMessage LPARAM type casting in Delphi 2007 for .Net

1. Declare an overload function of SendMessage instead of trying to typecast the LParam. The example below shows how to send TWinControl as LParam.
function SendMessage(hWnd: THandle; Msg: Cardinal; wParam: THandle; var LParam: TWincontrol): THandle; stdcall; overload; external 'User32.dll';

2. Using Marshal
Marshal.StructureToPtr(Control, LParam, True);
SendMessage(Control.Handle, CM_MOUSELEAVE, 0, THandle(LParam));



No comments: