Sign in Join

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

Mailing lists / fpc-devel / 2009-07

Message method with a string identifier

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Don Whitbeck

Message methods with a string identifier work fine. Message methods with a string identifier appear not to work. The array of TMsgStrTable records have name variables which point to something other than the string identifier. The DispatchStr call does not call the message handler.

Reply by email

Don Whitbeck
to Michael Schnell
//Defining msg
Type
   TMsg = record
        MsgStr: string[20];   //Doesn't work
	                              //MSGID: integer;  // Works
	Data: pointer;
    end;

TCustomSocket = Class(TObject)
...
Procedure MsgHandler(Var Msg: TMsg); Message 'OnAccept';

 ASocket:=TCustomSocket.Create;
var
   msg: TMsg;
....
   msg.MsgStr := 'OnAccept';
  msg.Data := PS;     // Pointer to data
   ASocket.dispatchStr(msg);

Defining a message handler identified with an integer and calling with dispatch works.
For some reason I am not successful in defining a message handler identified with a string and calling it with dispatchstr.

am Michael Schnell wrote 9 lines
Don Whitbeck wrote: > Message methods with a string identifier work fine. > Message methods with a string identifier appear not to work. ????? -Michael _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Don Whitbeck
to Michael Schnell
am Michael Schnell wrote 9 lines
> MsgStr: string[20]; //Doesn't work I suppose the string reference counting deletes the string before the receiver gets the message. -Michael _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Looking at the results of the StringMessageTable function and looking at the contents of the TMsgStrTable record, the name member seems to point to the wrong data, sometimes it contains the name of a declared procedure, sometimes it appears to be be binary data. I am assuming that these records are not being constructed properly by the compiler.

from objpash.inc

type TMsgStrTable = record

  name: PShortString;
Message name
  method: pointer;
Method to call
end;

Reply by email

Michael Van Canneyt
to Don Whitbeck: //Defining msg Type TMsg = record MsgStr: string[20]; //Doesn't work //MSGID: integer; …
Don Whitbeck wrote 26 lines
//Defining msg Type TMsg = record MsgStr: string[20]; //Doesn't work //MSGID: integer; // Works Data: pointer; end; TCustomSocket = Class(TObject) ... Procedure MsgHandler(Var Msg: TMsg); Message 'OnAccept'; ASocket:=TCustomSocket.Create; var msg: TMsg; .... msg.MsgStr := 'OnAccept'; msg.Data := PS; // Pointer to data ASocket.dispatchStr(msg); Defining a message handler identified with an integer and calling with dispatch works. For some reason I am not successful in defining a message handler identified with a string and calling it with dispatchstr.

There is a bug, obviously the string dispatch table is not written to the assembler file. I created a bugreport.

Michael.

Reply by email