🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14711

Re: Threads and messages again

#14711
From: Joe Walker
Date: Sun, 03 Aug 2003 21:59
81 lines
3721 bytes
Thanks for the answer, I think I should say that I wasnt using GetMessage
method in the execute method..
Sorry for this..
Now, the question is, what if I use GetMessage method outside of Execute
method..?
What does GetMessage do outside Execute method? It gets all the messages
including main VCL thread?
Here is a simple example how I use the GetMessage outside Execute method...

//assume that MessageA and MessageB is defined and
//when Button1 Clicked it sends MessageA and
//Button2 Clicked it sends MessageB
// there are also handlers for the messages and these are
//OnMessageA and OnMessageB

//in execute method...this is working already...
GetMessage(...)
Dispatch(..)

// in OnMessageA, I want user to send MessageB by clicking Button2

OnMessageA
{
    //do something...
    //wait until MessageB comes..
    while (1)
    {
    GetMessage(&msg....)
    if (msg.message==MessageB)
                     break;
   else
     //do not nothing, do not call other handlers,
                   continue
    }
}

What happens here is that when I use NULL for the HWND parameter of
GetMessage, it gets all messages (I think) even including mousemove,
therefore
infinite loop occurs.(I know this by debugging)
When I use (HWN)-1 for HWND parameter, it gets nothing and somehow
program goes infinite loop for which reason I dont know.. it enters
GetMessage method
and I can not reach form, cannot click a button, cannot close window..
I have also tried the filtering by assigning lower filter to WM_APP but it
doesnt work also..
I can use flags (I know), but then code will be too much and I have to spend
too much time because
there are lots of handlers and there are several cases in which I have to
wait user to send messages like this...
Any idea for this?


Thanks for your time...
JoW

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3f2d6395@newsgroups.borland.com...
>
> "Joe Walker" <__JoeW@hotmail.com> wrote in message
> news:3f2d218e@newsgroups.borland.com...
>
> > now in GetMessage, I am using NULL for the HWND
> > parameter.. My thread has no window but I want only
> > get to messages which are coming to my threads message
> > queue.. How I can do that?
>
> You are already doing what is needed.  GetMessage() always works on the
> message queue of the *calling* thread, not the main VCL thread always.  As
> long as your GetMessage() is inside the Execute() method of your thread,
it
> will only retreive messages sent to your thread.
>
> If that is still not working correctly for you, then please post your
actual
> code so we can see exactly how you are trying to use your thread.
>
>
> Gambit
>
>
Technical Details
Message-ID: <3f2d85c4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!pln-w!extra.newsguy.com!lotsanews.com!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f2d218e@newsgroups.borland.com> <3f2d6395@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,b0f5f87125b64df6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-03 15:04:04 PST
From: "Joe Walker" <__JoeW@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f2d218e@newsgroups.borland.com> <3f2d6395@newsgroups.borland.com>
Subject: Re: Threads and messages again
Date: Mon, 4 Aug 2003 00:59:36 +0300
Lines: 83
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 144.122.180.3
Message-ID: <3f2d85c4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059947972 144.122.180.3 (3 Aug 2003 14:59:32 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!pln-w!extra.newsguy.com!lotsanews.com!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail