Em 18/03/14 10:47, Marcos Douglas escreveu:
a form needs to notify many windows
using asynchronous messages. PostMessage do that but some programmers
say this is an old Windowish approach so, I'm searching another method
to do the same PostMessage does and making the code more cross.
I missed the "async" part, sorry. What about reuse App.QueueAsyncCall
with interface?
======>>>======
type
IProcCallback = interface
procedure ASync(data: ptrint);
end;
TProc = class(TObject)
private
FCallback: IProcCallback;
public
constructor Create(const ACallback: IProcCallback);
procedure DoStuff;
end;
constructor TProc.Create(const ACallback: IProcCallback);
begin
inherited Create;
FCallback := ACallback;
end;
procedure TProc.DoStuff;
begin
//...
Application.QueueAsyncCall(@FCallback.ASync, 0);
end;
======<<<======
You can also use {$interfaces corba} if you don't use objects with refcount.
Following this architecture, the responsible for creating TProc instance
(let's say, TMain) needs to know someone that implements IProcCallback,
which can be itself (TMain) of course. TMain knows TProc. TProc, TMain
and others know IProcCallback, and IProcCallback doesn't know anyone.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus