> hooger <mberge...@NOSPAM.eduglobe.ca> wrote in message
> news:WxGW8.2928$_y5.110415@charlie.risq.qc.ca...
> > Hi!
> > In my program, I have a Thread (TThread) which does something like that
:
> > procedure TBuffThread.Execute;
> > ...
> > while(Terminated = false) do
> > begin
> > file://Get Messages in fHandle queue
> > if PeekMessage(lpMsg, fHandle, 0, 600, PM_NOREMOVE) then
> > begin
> > if lpMsg.message = RFB_SCREEN_UPDATE then
> > ...
> > where fHandle is the handle (HWND) to a specified window (already opened
> on
> > the computer) like Notepad and RFB_SCREEN_UPDATE a message previously
> > registered with RegisterWindowMessage() and sent by an hook installed on
> the
> > window fHandle.
> > The problem is that the thread get absolutely no messages. I know that
I
> > can't get messages for a window which was not created by my thread
(which
> is
> > my case!) and in the situation of my program I can't put another hook
> > either. So, any ideas how to proceed?
> > Thanks,
> > hooger
> I think you have this one back the front. PeekMessage() and the like
> fetch messages from the message queue associated with the thread in which
> they are executed. PostMessage() and the like place messages in the queue
of
> the thread that created the window to which they are sent.
> I've never tried hooking an application and getting the hook to send an
> interapplication message, but assuming you have this bit working OK, then
> what you need to do is get a message queue working in your thread. Windows
> does this for you when the thread creates its first window. Currently you
> have none, so you can do something quick like creating a TTimer in the
> Execute code, or use the Delphi function AllocateHWnd to create one. This
is
> the window handle that you use in PeekMessage. If this is all the thread
is
> doing, then I would be inclined to use GetMessage() with NULL as the
window
> handle. This simplifies any problems of not getting the right handle and
so
> forth.
> This leaves the problem of getting the message to the queue of the thread.
> Once again, you can avoid the issue of having to identify the right window
> to post the message to by using the HWND_BROADCAST for the hWnd parameter
> of Postmessage()........... I think this will find the thread window OK,
but
> am not sure.
> Dave