Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 1999-08

Message Handling in LCL ?? (was Re: More Native Win32 stuff (Pascal, can you help here?)

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Pascal Dutilleul

Hi,

As I understand in GTK, each component has to say for each message that it will handle it, and give GTK a callback function that just handles that message.

In Windows all messages are sent to the windowproc of the active window, and if not handled, it is sent to the application window.

I haven't got the time to look at how messages from GTK are now handled in the LCL.

I have quickly investigated it a bit (during my working hours, so my boss won't be happy if he knew it).
What I think is that the TInterfaceObject (interfaces.pp) handles the core difference between each toolkit. Is there only one instance of TInterfaceObject, or is it created for each component ?

It has something to do with IntSendMessage...

If I declare a
  procedure MyHandler(...); message LM_MYMESSAGE;

How does LCL call MyHandler when it received the message ?

When a control is created, it calls InsertControl or AddControl. Could that be used to attach a windowproc ?

Somehow, we should first find out how messages are handled in the LCL before we could do the windows stuff. Could anybody help us explain this ?

I was thinking of defining a TWindowObject and making the WindowProc a method,

I guess that's the way to go : see TInterfacedObject, that is inherited from TgtkObject, TQTObject and maybe TWindowsObject ?

then creating a new TWindowObject for each control when I recieve the LM_Create message, but I don't think I can assign a method to FWindowProc

Should FWindowProc not be published, so TWindowsObject could call/set this function ?

But it appears I can't create new, unique handlers for each component without them being part of the object to begin with.

Maybe this isn't necessary. If you handle the messages in one global procedure, you can 'perform' the message to the right object (if there is a way to find the link between window-handles and the class. When you create a new window, you can give some pointer to it (in pWinData?).)
To be compatible with Delphi, the Perform function (should) exist ?

Pascal
_____________________________________________________________ Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

Reply by email

Michael A. Hess
to Pascal Dutilleul
Pascal Dutilleul wrote 7 lines
It has something to do with IntSendMessage... If I declare a procedure MyHandler(...); message LM_MYMESSAGE; How does LCL call MyHandler when it received the message ?

Well in a sense the LCL doesn't. The RTL does. When the compiler sees the above declaration it creates a Table for the class object being created. In this table it places a pointer to the defined procedure MyHandler with the key LM_MYMESSAGE.

In the SetCallback routine we pass Self to the gtkcallback routine so that it will be able to indicated exactly which LCL class object should be receiving the callback message. In the callback routine we call the Dispatch routine found with each object passing it the message. It goes through the table looking for the LM_MYMESSAGE and when found calls the associated MyHandler.

So each object does have it's own message handling built in.

I haven't actually looked at the Windows methods of doing messaging so I can't say off the top of my head exactly the way to do it but I can't imageing that it would work very much differently then the way we are already doing it with GTK.

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email