[lazarus] More Native Win32 stuff(Pascal,canyouhelphere?)

Jeff Wormsley daworm at cdc.net
Tue Aug 10 17:28:59 EDT 1999



Followed you fine till here...

>It is in this csForm section where you will to the actual call to the
>Windows API (CreateWindow or CreateWindowEx) to make the window. Now as
>the API states before this returns it sends the WM_CREATE message to the
>Windows Procedure. Well the Windows Procedure is the callback handler
>from Windows. This is what you need to define in the WNDCLASS structure
>for the CLASS (window class) that you are creating. This Window
>Procedure routine will be located within the win32int unit.

Just one, right?  Not one for each component, but only one total?  It was my interpretation of reading the Delphi VCL that every single Delphi component had its own window procedure.

>You will need to have it point to a procedure that matches that which
>Windows expects to be calling. In the API it looks like this:
>
>LRESULT CALLBACK WindowProc(
>
>    HWND  hwnd,	// handle of window
>    UINT  uMsg,	// message identifier
>    WPARAM  wParam,	// first message parameter
>    LPARAM  lParam 	// second message parameter
>   );	
>
>but you will have to adjust the types to match what is setup in Free
>Pascal.

This I don't understand at all.  I will ask more this evening when I get home.
 
>Now when this procedure receives the message which in this case is
>WM_CREATE, you actually want to send:
>
>TObject().Dispatch(LM_CREATE);
>
>Which will call any
>
>    procedure DoCreate(var msg); message LM_CREATE;
>
>that has been setup for the control and that will in turn call a
>OnCreate TNotifyEvents that have been established for this control.
>
>To do this you will need to case the WindowProc callback to determine
>which message is sent and translate it to the appropriate LM_XXX
>message.
>
>OK, now after all of that, here is the only part that you have to get
>cute about. You need to be able to determine WHICH LCL control needs to
>receive the Dispatch. In GTK you are able to pass a pointer to user
>specific data that can be anything you wish. It is in this data, that
>gets passed to the callback, were we placed the pointer to Self. This is
>then how we call the correct Dispatch by doing.
>
>TObject(data).Dispatch(LM_XXX);
>
>were data was the passed value containing "Self".
>
>In Windows it passes back the HWND for the control. That doesn't relate
>to the LCL control at all. You will have to figure out a way to relate
>the HWND value to the control created by the LCL. At this point I'm not
>exactly sure how to do that but it should be possible all the same.
>Either you need to relate HWND or you need to find a way to pass
>additional information, the "Self" value, back to the callback routine.
>
>
>Now have I made things clearer or have I just muddied the water more?

Some things clearer, some muddier.  A trade off.  I am late leaving work.  Will get back on the mail in about an hour.

Jeff.







More information about the Lazarus mailing list