[lazarus] Latest source is attached.
Michael A. Hess
mhess at miraclec.com
Fri Jul 2 19:26:55 EDT 1999
Shane Miller wrote:
>
Let me throw my hat into this fire. I hope this doesn't confuse the
issue. FPC already has a messaging system built in. I was having
problems getting it working a few weeks ago and due to other commitments
that many of us seemed to have at the same time I didn't get much
further with it. I had planned on doing some this weekend. Any way here
is how I had started trying to do the messaging thing.
If you remember I first started with the GUIapi.pp file. This was
suppose to be the file that was standard as far as access from the FCL
but it would have different version for each type of API (GTK, QT) that
you are using. It relys on the messaging built into the FPC.
I am using the TForm as an example since that is what I was working
with. First you would create the message routines in the class
definition like thus:
++++++++++++++++++++++++++++++++++++++++++++++++++++
TCustomForm = class(TWinControl)
.
.
.
protected
procedure DoDestroy(Self : TCustomForm); message 'destroy';
procedure DoShow(Self : TCustomForm); message 'show';
procedure DoFocus(Self : TCustomForm); message 'focus';
.
.
.
end;
procedure TCustomForm.DoDestroy(Self : TCustomForm);
begin
if Assigned (FOnDestroy) then
FOnDestroy(Self);
end;
{ do the same for DoShow and DoFocus }
constructor TCustomForm.Create(AOwner : TComponent);
begin
.
.
.
GUIAPI_Set_Callback('destroy', Self)
GUIAPI_Set_Callback('show', Self)
GUIAPI_Set_Callback('focus', Self)
.
.
.
end;
destructor TCustomForm.Destroy;
begin
.
.
.
GUIAPI_Remove_Callback(Self);
inherited Destroy
end;
++++++++++++++++++++++++++++++++++++++++++++++++
That is all that is needed in the actual FCL code for any component. If
you write a component that inherits this one it gets these messages plus
any that you add to your new component. When you send a message to a
TControl it will try and find a matching message assigned to the
control. If it can't find one it moves up through the parent chain until
it does find it.
I haven't shown the code that is required in Tcontrol that gets the
signal from GUIAPI but all call backs from the API in this case GTK is
tied to just one routine which then calls DispatchStr(signal) to send
the message off to the control.
Does anyone understand what I am attempting here? I have all of this
already coded in a version of Lazarus that I was working with trying to
make this work. However when I was trying this about 5-6 weeks ago the
compiler was still having problems with all that procedure pointer and
ansistring stuff. I think most of that is fixed now and I have hopes
that this will now work.
What this means is that we can separate all the call backs and all the
gtk calls into an independent file that just has routines that the FCL
know about and calls regardless of the API being used. This would then
start to allow people to easily write their own GUIAPI file for their
favorite API without effecting the core of the FCL.
I can get back to working on this this weekend and try and get it
working.
Opinions????
--
==== 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