Sign in Join

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

Mailing lists / lazarus / 1999-05

Has message handler stuff been implemented yet???

10 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

Michael A. Hess

Hey Michael V. what is the status of this? You said you would indicate when it has been committed and working. Is it and if not how soon until it will be? I am working on this kind of stuff and want to know if this is available or if I should do it in another fashion.

+++++ Per email on April 26th ++++++++++

As requested by Michael Zayats, we've implemented some changes to support
messages from GTK more directly.

The implementation of it is as follows:

Declare a message handler with SELF as one of the paameters.

Procedure TMyClass.MyMessageHandler (Arg1 : Type1; Arg2 : Type2;
                                     ...
                                     Self : TMyClass;
                                     Argn : Typen); message
'themessage';cdecl;

<snip>

This has been put in the compiler, but not yet tested or committed to CVS,
although the generated code looks OK.

I will notify when it has been committed and tested.

Michael.

+++++++++++++++++++++++++++++++++++++++++++

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

Reply by email

Michael A. Hess
to Unknown author: It has been there for more than a week now. You should be able to use it. (I honestly…
Show quoted text 6 lines
> Hey Michael V. what is the status of this? You said you would > indicate when it has been committed and working. It has been there for more than a week now. You should be able to use it. (I honestly thought I notified the list about it)

Maybe you did and I missed it. I tried to use it before I sent the email asking you this and it doesn't seem to work.

I have added a procedure to a class such as

procedure something; message '{thesignal}';

where each of the above items are specific names.

When I compile I get

Panic: Internal comipler error 9999, exiting.

This occurs on the line in the class definition.

Does it work and I am just doing something wrong?

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

Reply by email

Cliff Baeseman
to Unknown author: the following should compile: ------------------------------------------------------…

I think I am going to change teditor around a little. I will archive the original...

Hope Shane does not get upset with me ;)

Cliff

"Michael A. Hess" wrote 39 lines
wrote: > > the following should compile: OK. I'll test it and let you know what I get. <snip> > begin > MyObject:=TMyObject.Create; > MyObject.A:=1; > // ; > // MyProc(2,MyObject); > MyObject.Free; > end. > > The two commented out lines don't compile yet, I'll have to ask > Florian about them. But the above compiles with todays compiler, and > with last weeks too. > > I'll let you know when the two lines can be uncommented :-) I see I should have read this email before writing my last email. This is the very problem I am having. I would REALLY like to see this issue fixed. Let me know as soon as you find something out. I could use this feature in a big way. :-\ Talk at you later, -- ==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Michael A. Hess
to Michael Van Canneyt: The point is that under Windows you have message functions. Procedure DoKey (...) message…
Michael Van Canneyt wrote 11 lines
The point is that under Windows you have message functions. Procedure DoKey (...) message WM_KEyCLICK; For such a procedure, special RTTI is generated. All messages for an object come to 1 central procedure, which then calls dispatch (a method from TObject) which looks through the RTTI to see if there is a handler for the message registered. If so it is called. Thus, a Windows message arrives at the procedure you registered.

Of course I understand all of this I just didn't see how this related to Linux or using GTK.

Show quoted text 5 lines
Gtk has also messages, but they are strings, hence the possibility Procedure DoKey ( ) message 'string'; Likewise, there is now a procedure DispatchStr() which takes a string as and argument (the signal name) and looks in the RTTI to see if there is a handler registered for the given signal name.

Ahhhhhh. There is the missing key. You never mentioned that the DispatchStr function was there.

Show quoted text 11 lines
A problem with this is that GTK is not object oriented, but does allow to pass data to the signal call. This means that you must put a pointer to 'self' in this data, and that 'self' must be loaded into the object when the function gets called: hence the above syntax. So the above syntax is a mixture of 2 things: allowing string-type messages, and allowing calls from Non-OOP toolkits to OOP objects. I don't know if GTK supports a 'all-purpose' signal handler; i.e. a signal handler that is called for any type of signal, but with additionally the signal as an option;

Not that I am aware of but that is more or less what I was trying to write to use with lazarus and the fcl. That was why I was interested in getting a better handle on what exactly has been implemented with the message handler.

I hope this is clear :(

It sure is! I just need the connection between the message 'signal' and the fact that the DispatchStr function existed.

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

Reply by email

Unknown author
to Michael A. Hess: Maybe you did and I missed it. I tried to use it before I sent the email asking you this…
Michael A. Hess wrote 15 lines
wrote: > > > Hey Michael V. what is the status of this? You said you would > > indicate when it has been committed and working. > > It has been there for more than a week now. You should be able to use > it. (I honestly thought I notified the list about it) Maybe you did and I missed it. I tried to use it before I sent the email asking you this and it doesn't seem to work. I have added a procedure to a class such as procedure something; message '{thesignal}';

the following should compile:

------------------------------------------------------

program testit;
Type TMyObject = Class (Tobject)
       A : Integer;
       Procedure DoClick (Var B : Integer; Self : TMyObject); message 'click';
       end;
Procedure TMyObject.DoClick (Var B : Integer; Self : TMyObject);
begin
  Writeln ('B : ',B);
  Writeln ('A : ',A);
end;
Type TCallPRoc = Procedure (Var B: Integer; Obj : TMyObject) of object;
Var MyObject : TMyObject;
    MyProc : TCallProc;
    P : Pointer;
begin
  MyObject:=TMyObject.Create;
  MyObject.A:=1;
  // ;
  // MyProc(2,MyObject);
  MyObject.Free;
end.

-----------------------------------------------------------------------

The two commented out lines don't compile yet, I'll have to ask Florian about them. But the above compiles with todays compiler, and with last weeks too.

I'll let you know when the two lines can be uncommented :-)

Michael.

Reply by email

Unknown author
to Michael A. Hess: Hey Michael V. what is the status of this? You said you would indicate when it has been…
Michael A. Hess wrote
Hey Michael V. what is the status of this? You said you would indicate when it has been committed and working. Is it and if not how soon until it will be? I am working on this kind of stuff and want to know if this is available or if I should do it in another fashion.

It has been there for more than a week now. You should be able to use it. (I honestly thought I notified the list about it)

Michael.

Show quoted text 40 lines
+++++ Per email on April 26th ++++++++++ As requested by Michael Zayats, we've implemented some changes to support messages from GTK more directly. The implementation of it is as follows: Declare a message handler with SELF as one of the paameters. Procedure TMyClass.MyMessageHandler (Arg1 : Type1; Arg2 : Type2; ... Self : TMyClass; Argn : Typen); message 'themessage';cdecl; <snip> This has been put in the compiler, but not yet tested or committed to CVS, although the generated code looks OK. I will notify when it has been committed and tested. Michael. +++++++++++++++++++++++++++++++++++++++++++ -- ==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Michael A. Hess
to Unknown author: the following should compile: ------------------------------------------------------…
Show quoted text 34 lines
the following should compile: ------------------------------------------------------ program testit; Type TMyObject = Class (Tobject) A : Integer; Procedure DoClick (Var B : Integer; Self : TMyObject); message 'click'; end; Procedure TMyObject.DoClick (Var B : Integer; Self : TMyObject); begin Writeln ('B : ',B); Writeln ('A : ',A); end; Type TCallPRoc = Procedure (Var B: Integer; Obj : TMyObject) of object; Var MyObject : TMyObject; MyProc : TCallProc; P : Pointer; begin MyObject:=TMyObject.Create; MyObject.A:=1; // ; // MyProc(2,MyObject); MyObject.Free; end. -----------------------------------------------------------------------

OK this does compile OK, but I don't totally understand it. If you don't have the var B: integer then the compiler craps out big time. Messes up my terminal and everything. Is that leading variable required?

Secondly I guess I just don't understand the mechanics of this thing as a whole. What is the purpose of the ;message 'click'; statement at the end of the line. You seem to set the pointer MyProc equal to the value of MyObject.DoClick and then try and call the procedure. Where does the message 'click' part come into it? Sorry if this is a stupid question but I don't see why the code wouldn't be exactly the same if you didn't have the message 'click' added.

What am I missing? Could you explain this to me?

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

Reply by email

Michael Van Canneyt
to Michael A. Hess
Michael A. Hess wrote 49 lines
wrote: > > the following should compile: > > ------------------------------------------------------ > > program testit; > > Type TMyObject = Class (Tobject) > A : Integer; > Procedure DoClick (Var B : Integer; Self : TMyObject); message 'click'; > end; > > Procedure TMyObject.DoClick (Var B : Integer; Self : TMyObject); > > begin > Writeln ('B : ',B); > Writeln ('A : ',A); > end; > > Type TCallPRoc = Procedure (Var B: Integer; Obj : TMyObject) of object; > > Var MyObject : TMyObject; > MyProc : TCallProc; > P : Pointer; > > begin > MyObject:=TMyObject.Create; > MyObject.A:=1; > // ; > // MyProc(2,MyObject); > MyObject.Free; > end. > > ----------------------------------------------------------------------- OK this does compile OK, but I don't totally understand it. If you don't have the var B: integer then the compiler craps out big time. Messes up my terminal and everything. Is that leading variable required? Secondly I guess I just don't understand the mechanics of this thing as a whole. What is the purpose of the ;message 'click'; statement at the end of the line. You seem to set the pointer MyProc equal to the value of MyObject.DoClick and then try and call the procedure. Where does the message 'click' part come into it? Sorry if this is a stupid question but I don't see why the code wouldn't be exactly the same if you didn't have the message 'click' added. What am I missing? Could you explain this to me?

The point is that under Windows you have message functions.

Procedure DoKey (...) message WM_KEyCLICK;
For such a procedure, special RTTI is generated.

All messages for an object come to 1 central procedure, which then calls dispatch (a method from TObject) which looks through the RTTI to see if there is a handler for the message registered. If so it is called. Thus, a Windows message arrives at the procedure you registered.

Gtk has also messages, but they are strings, hence the possibility Procedure DoKey ( ) message 'string';
Likewise, there is now a procedure DispatchStr() which takes a string as and argument (the signal name) and looks in the RTTI to see if there is a handler registered for the given signal name.

A problem with this is that GTK is not object oriented, but does allow to pass data to the signal call. This means that you must put a pointer to 'self' in this data, and that 'self' must be loaded into the object when the function gets called: hence the above syntax.

So the above syntax is a mixture of 2 things: allowing string-type messages, and allowing calls from Non-OOP toolkits to OOP objects.

I don't know if GTK supports a 'all-purpose' signal handler; i.e. a signal handler
that is called for any type of signal, but with additionally the signal as an option;

Then you could do

TControl.GTKSignals (Msg : String; Self : TControl);
begin
  // Self loaded automatically !!
  Dispatchstr (Msg); // Calls the function that responds to 'msg'
end,

Any signal should then be connected to TControl.GTKSignals, which would dispatch automatically to any function with message MSG.
(This is the windows way of doing things)

I hope this is clear :(

Michael.

Reply by email

Michael Van Canneyt
to Cliff Baeseman: I think I am going to change teditor around a little. I will archive the original...…
Cliff Baeseman wrote
I think I am going to change teditor around a little. I will archive the original...

No need. Just take a note of the file version number: CVS can check it out for you any time. This is why you use CVS !

If for instance you want version 1.12 of a file, you do a cvs update -r1.12 editor.pp
and it gets the version for you. That is a good reason for keeping the log in the file: you can check what has changed along the versions, and then check out whatever version you need. It is also a reason for supplying CVS with good comments when committing =)

Michael.

Show quoted text 40 lines
Hope Shane does not get upset with me ;) Cliff "Michael A. Hess" wrote: > wrote: > > > > the following should compile: > > OK. I'll test it and let you know what I get. > > <snip> > > begin > > MyObject:=TMyObject.Create; > > MyObject.A:=1; > > // ; > > // MyProc(2,MyObject); > > MyObject.Free; > > end. > > > > The two commented out lines don't compile yet, I'll have to ask > > Florian about them. But the above compiles with todays compiler, and > > with last weeks too. > > > > I'll let you know when the two lines can be uncommented :-) > > I see I should have read this email before writing my last email. This > is the very problem I am having. I would REALLY like to see this issue > fixed. > > Let me know as soon as you find something out. I could use this feature > in a big way. :-\ > > Talk at you later, > --)

Reply by email

Michael A. Hess
to Unknown author: the following should compile: ------------------------------------------------------…
the following should compile:

OK. I'll test it and let you know what I get.

<snip>

Show quoted text 13 lines
begin MyObject:=TMyObject.Create; MyObject.A:=1; // ; // MyProc(2,MyObject); MyObject.Free; end. The two commented out lines don't compile yet, I'll have to ask Florian about them. But the above compiles with todays compiler, and with last weeks too. I'll let you know when the two lines can be uncommented :-)

I see I should have read this email before writing my last email. This is the very problem I am having. I would REALLY like to see this issue fixed.

Let me know as soon as you find something out. I could use this feature in a big way. :-\

Talk at you later,

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

Reply by email