🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Messages and threads

#14865
From: Fatih Keles
Date: Tue, 29 Jul 2003 10:32
48 lines
2666 bytes
Hi, I have a question about window messages but I dont know whether I am at
the right group ..
Ayway,  my problem is the following:

I have several threads. I want to create specific message handlers for each
thread. I mean WM_MESSAGE1 for thread 1 and
WM_MESSAGE2 and  WM_MESSAGE2 for thread 2 etc.And in each thread I want to
broadcast messages to all other threads.
I tried to use in thread .h file...->

#define WM_MYFIRSTMESSAGE  (WM_APP + 400)
void __fastcall MyMessageHandler(TMessage &Message);

BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER(WM_MYFIRSTMESSAGE, TMessage, MyMessageHandler)
END_MESSAGE_MAP(TThread);

(Note: it says that if you will broadcast messages, you have to register
message, but I dont know how to do that because MESSAGE_HANDLER wants a
const parameter.)
 In Execute Method->

                    MSG msg;
                    HANDLE HWND
                   if ((bRet = GetMessage( &msg,HWND, 0, 0)) != 0)
                   {
                        if (msg.message==WM_MYFIRSTMESSAGE)
                        {
                                   TranslateMessage(&msg);
                                    DispatchMessage(&msg);
                        }
                    }

void __fastcall TExampleThread::MyMessageHandler(TMessage &Message)
{
     int a=2;
}

and I tried to use in another thread->
        ShowMessage(PostMessage(HWND_BROADCAST,WM_MYFIRSTMESSAGE, 1,2));

ShowMessage(PostThreadMessage(ExampleThread->ThreadID,WM_MYFIRSTMESSAGE,
1,2));

Both returns 1 but, my first thread cant get message?
So, can anyone explain how messages work in threads?:)

Thanks for your time...
Technical Details
Message-ID: <3f264d2b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c519897f9efe71e1,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-29 03:40:31 PST
From: "Fatih Keles" <fatihks@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject:  Messages and threads
Date: Tue, 29 Jul 2003 13:32:19 +0300
Lines: 50
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: <3f264d2b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059474731 144.122.180.3 (29 Jul 2003 03:32:11 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail