Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages
Started by Jeff Douglass
Thu, 24 Apr 2003 16:59
PostMessage() with HWND_BROADCAST not working.
Author: Jeff Douglass
Date: Thu, 24 Apr 2003 16:59
Date: Thu, 24 Apr 2003 16:59
12 lines
1472 bytes
1472 bytes
I hava a BCB 5 pro app the displays a system startup status form while the system does all of its initialization. I am trying to use PostMessage() with the HWND_BROADCAST constant as the window handle as detailed in the MS documentation to send a message to the startup window indicating that initialization is complete and the window should close. If I use the actual handle of the startup window in the call to PostMessage() everything works fine but when I try using the HWND_BROADCAST constant it does not work. Any ideas would be great. Thanks in advance. Jeff
Re: PostMessage() with HWND_BROADCAST not working.
Author: Remy Lebeau (TeamB)
Date: Thu, 24 Apr 2003 17:43
Date: Thu, 24 Apr 2003 17:43
16 lines
1546 bytes
1546 bytes
"Jeff Douglass" <.> wrote in message news:3ea817c4@newsgroups.borland.com... > If I use the actual handle of the startup window in the call > to PostMessage() everything works fine but when I try using > the HWND_BROADCAST constant it does not work. Any > ideas would be great. What does your actual code look like? What kind of message are you trying to broadcast specifically? Some messages can't be broadcasted with PostMessage(), they need SendMessage() instead. Is there any reason why you're broadcasting in the first place instead of simply looking for the startup window specifically? Gambit
Re: PostMessage() with HWND_BROADCAST not working.
Author: Jeff Douglass
Date: Thu, 24 Apr 2003 18:06
Date: Thu, 24 Apr 2003 18:06
32 lines
1962 bytes
1962 bytes
I am trying to use the broadcast option so in case at a later point in time I need to perform some added processing from any number of different windows the hook is already there. The message is simply defined as #define THE_MESSAGE (WM_USER + 3332) At the end of the initializtion routine that handles all the app's initialization I call: PostMessage(HWND_BROADCAST, THE_MESSAGE,0,0); The startup window is created and shown as follows: Application->Initialize() ; startupwindow->Show(); startupwindow->Update(); the call to the app's initialization routine. The only thing I can think is the problem is that the startup window is not a "top level window" The MS documentation of PostMessage says that the broadcast option send the message to all "top level windows" but not child windows. I can not find an exact definition of what makes a window a "top level window". My app is a SDI app so there are no child windows. Hope this info helps answer the problem. Thanks again Jeff
Re: PostMessage() with HWND_BROADCAST not working.
Author: Remy Lebeau (TeamB)
Date: Thu, 24 Apr 2003 19:49
Date: Thu, 24 Apr 2003 19:49
29 lines
2324 bytes
2324 bytes
"Jeff Douglass" <.> wrote in message news:3ea8274c$1@newsgroups.borland.com... > The message is simply defined as > #define THE_MESSAGE (WM_USER + 3332) I would suggest you consider having a look at the RegisterWindowMessage() function. The one gotcha with hard-coded message IDs is that you never know when someone else is using the same ID for their own stuff. Especially in a scenerio where you're broadcasting the message to everyone. Using RegisterWindowMessage() ensures you have a unique value that only you know how to interpret (and anyone else specifically written to directly support your message). > The only thing I can think is the problem is that the startup > window is not a "top level window" Very possibly. VCL forms are not stand-alone. They are actually children of the hidden global TApplication window, which is the true top-level window for the program. You will probably need to assign an event handler to the TApplication::OnMessage event in order to intercept your broadcast correctly. Otherwise, you'll have to override the form's CreateParams() method to reassign the owner window (in API terms, not VCL) to be the main Desktop window instead. That might have other side-effects on how the VCL form behaves, though. Gambit
Re: PostMessage() with HWND_BROADCAST not working.
Author: Jeff Douglass
Date: Thu, 24 Apr 2003 20:21
Date: Thu, 24 Apr 2003 20:21
6 lines
1291 bytes
1291 bytes
Thanks for advice. BTW, could you take a look at my posting "ClientSocket Problem" in the sockets group. You seem to always have all the answers and no one has posted any responses to it. Thanks again. Jeff
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads