[fpc-devel] procedure ... message(); in Linux
Nikolai Zhubr
n-a-zhubr at yandex.ru
Thu Feb 25 20:10:53 CET 2010
25.02.2010 19:59, Michael Schnell:
> Can't anyone answer the question if in Linux the legal and compilable
> construct
>
> procedure... message;
>
> either
>
> is not supposed to be working
Is is working fine on linux, see my example below.
> or
>
> how I can have such a procedure be executed (e.g. by posting a message
> from a thread or another application, what I successfully did in Windows.
Some sort of IPC is necessary as a ground for that.
On windows, PostMessage/GetMessage mechanism is always available and it
does not require any additional libraries (as it is an integral part of
the system), so it is used most of the time.
On linux, there is no such "global default" (AFAICS), but you are free
to choose some existing library or create your specific implementation
based on OS functionality directly (like my favourite pipes or whatever).
Nikolai
>
>
>
------------------------------ cut -------------------------------
{$mode delphi}
{$ifdef win32 }{$apptype console }{$endif }
const
const_my_msg = $7FFF;
type
TMyMessage = record
Msg: Cardinal;
SomeData1: byte;
end;
TSomeTestObj = class
procedure msg_my_msg_proc(var Msg: TMyMessage); message const_my_msg;
end;
procedure TSomeTestObj.msg_my_msg_proc(var Msg: TMyMessage);
begin
writeln('I got called! SomeData1 = ', Msg.SomeData1);
end;
var
o: TSomeTestObj;
m: TMyMessage;
begin
m.Msg := const_my_msg;
m.SomeData1 := 1;
o := TSomeTestObj.Create;
o.Dispatch(m);
o.Free;
end.
More information about the fpc-devel
mailing list