[lazarus] This should get me much closer, but still questions :^(
Michael A. Hess
mhess at miraclec.com
Tue Aug 10 21:30:28 EDT 1999
Jeffrey A. Wormsley wrote:
>
> Steps following LM_CREATE
>
> 1. If I have not yet registered a window class, do so with
> RegisterClass or RegisterClassEx and the WNDCLASS or WNDCLASSEX
> structure.
Correct
> Q. Do I need more than one window class? If so, I will need a unique
> window procedure for each class, correct?
Not sure if you would need a separate one or not. I'm not sure exactly
what information is in the WNDCLASS so I can't say for sure. If you do
then it might be a good idea to have a separate WINDPROC for each just
to keep things neat and clean.
> 2. Create a window handle with CreateWindow or CreateWindowEx, passing
> the initial position, size and style information, translated from
> LCL to Win32, and using the appropriate parent window from the Data
> pointer passed in.
Sound right so far.
> 3. Use SetProp to store Data to the window handle structure.
Oh so that's how you do it. Fine.
> Q. Should this utilize the lpString parameter directly, subverting its
> intention as a pointer to a string, or is there a way to get a unique
> string and use this to index the hData parameter?
I would say subvert it's use as a pointer to a string.
> Q. What do I do with the WM_CREATE message recieved by the window
> procedure? Throw it away? If I pass it on to
> TObject(Data).Dispatch(LM_CREATE), will this cause an infinite loop?
No it will not cause a loop. If you remember the LM_CREATE that win32int
is getting is due to a specific request in the objects .Create. This is
called in the TControl method CreateComponent. It is not responding to
the LM_CREATE message it is generating it. When you send the Dispatch
that is more or less just telling the object that hey a valid LM_CREATE
has been done for you. Is there any specific parameters you want to set
before the window is really, really made?
> Steps following LM_DESTROY
>
> 1. Call RemoveProp to remove the window handle storage of Data
>
> 2. ???
>
> Steps following WM_xxxx in the window procedure
>
> 1. Use GetProp to get the instance of the control as Data
>
> 2. Translate the WM_xxxx messages into LM_xxxx messages
>
> 3. Call TObject(Data).Dispatch(LM_xxxx)
Yep that is all there is to handling a message from Windows.
> Steps following LM_xxxx
>
> 1. ????
>
> Q. Once I get the this far, I am somewhat lost again. For instance,
> what do I do to handle something simple like LM_SETTEXT for a TForm?
> This should change the form title, correct? How do I get the window
> handle for the form, then what message do I send to Windows to do
> this, and with what function?
The CreateWindow returns the HWND. In TControl there is the variable
fComponent. It is defined as a pointer so it can hold a pointer to
anything. In the case of GTK this hold the pointer for the widget
handle. In your case load it up with the HWND and now you have an
association between the TControl and the Windows Object. Then in turn
the HWND has an association to the TControl form the SetProc that you
used. So each knows about each other and can access each other when
needed.
So for the above question the InterfaceObject.IntSendMessage would get
the LM_SETTEXT message with the Self value passed. From the Sender value
you can determine what kind of component it is, a button, a window, etc.
etc. This way you know what kind of component you are trying to set text
for. Then you access the fComponent value from the Sender to determine
the exact HWND value that Windows know it by and call the appropriate
Windows API call with the HWND. That should be it.
--
==== Programming my first best destiny! ====
Michael A. Hess Miracle Concepts, Inc.
mhess at miraclec.com http://www.miraclec.com
More information about the Lazarus
mailing list