On Tue, 30 Aug 2005, Micha Nelissen wrote:
> On Mon, 29 Aug 2005 23:48:52 +0200 (CEST)
> Michael Van Canneyt <[EMAIL PROTECTED]> wrote:
>
> > > Otherwise all ipc message would be ignored until the user does something
> > > (not what you want most of the cases).
> >
> > But isn't that is what the Idle handler is for ?
> > It's called when the user does nothing ?
> > That is how all actions work, after all...
>
> What do you mean with Idle handler? TApplication.OnIdle ? In any sane app,
> that is only called once when the user goes idle; after that, the app is
> blocked waiting for user input.
Hm.
So that is not usable.
On Unix, it's easy:
I once wrote a GTK version of a debug server.
You can tell GTK to watch for input on a file descriptor in it's main loop.
If there is input on your descriptor, a callback you specify is called.
In windows, it's slightly more difficult (surprise, surprise :-) )
You can use MsgWaitForMultipleObjects to do this for a windows
handle, or use WaitForSingleObject on a simple file handle.
(Why they made this two separate functions is a mystery to me,
it makes things horribly complicated...)
So in fact, what we'd need is a pair of calls in TApplication :
TApplication.AddWatch(AHandle: THandle; Handler : TNotifyEvent);
TApplication.RemoveWatch(AHandle: THandle);
Which would handle both things transparantly in the message loop.
(the standard IsWindow function of Windows could be used to determine what
kind of handle it is in a windows app)
This would come in handy in many applications.
Michael.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives