Article View: borland.public.cppbuilder.nativeapi
Article #5999Re: HWND_BROADCAST doesn�t work!
From: Alexandre S�
Date: Fri, 17 Jun 2005 20:26
Date: Fri, 17 Jun 2005 20:26
134 lines
4977 bytes
4977 bytes
In addiction, I�ll refresh the question and put a fully functional code
bellow...
A broadcast message is not working properly.
But if I use...
PostMessage(hWindow, WM_USER, 0, 0L);
or
PostMessage(NULL, WM_USER, 0, 0L);
instead of...
PostMessage(HWND_BROADCAST, WM_USER, 0, 0L);
the message is peeked.
Se the code:
CODE CODE CODE CODE CODE CODE CODE CODE CODE
//--------------------------------------------------------------------------
-
#include <windows.h>
//--------------------------------------------------------------------------
-
static LRESULT WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return 0;
}
//--------------------------------------------------------------------------
-
#pragma argsused
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
WNDCLASS windowClass;
windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
windowClass.lpfnWndProc = (WNDPROC)WndProc;
windowClass.cbClsExtra = 0 ;
windowClass.cbWndExtra = 0 ;
windowClass.hInstance = hInstance ;
windowClass.hbrBackground = (HBRUSH)(GetStockObject(BLACK_BRUSH));
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "TMyForm";
RegisterClass(&windowClass);
HWND hWindow = CreateWindow ("TMyForm",
"MyForm",
WS_POPUP | WS_BORDER,
10,10,200,200,
NULL,
NULL,
hInstance,
NULL);
//send a broadcast message
PostMessage(HWND_BROADCAST, WM_APP, 0, 0L);
MSG msg;
//peek that message
if(PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
//it only works on Borland C++
MessageBox(NULL, "Work!", "", MB_OK);
} else {
//it doesn�t work on BCB6 and VisualStudio
MessageBox(NULL, "Don�t work!", "", MB_OK);
}
return 0;
}
//--------------------------------------------------------------------------
-
CODE CODE CODE CODE CODE CODE CODE CODE CODE
"Alexandre S�" <alexandre@daccord.com.br> escreveu na mensagem
news:42b31b9a@newsgroups.borland.com...
> > Please show all of the code. You probably are not setting up your
window
> > properly, but your pseudocode doesn't show what you are actually doing.
>
> Unfortunately, doesn�t matter the windows creation code... The same code
> works on Borland C++ and doesn�t work on BCB6...
> The code is:
>
> //*DEBUGGING MESSAGE
> WNDCLASS windowClass;
> windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;
> windowClass.lpfnWndProc = (WNDPROC)WndProc;
> windowClass.cbClsExtra = 0 ;
> windowClass.cbWndExtra = 0 ;
> windowClass.hInstance = hInstance ;
> windowClass.hbrBackground = (HBRUSH)(GetStockObject(BLACK_BRUSH));
> windowClass.lpszMenuName = NULL;
> windowClass.lpszClassName = "TMyForm";
> RegisterClass(&windowClass);
>
> HWND hWindow = CreateWindow ("TMyForm",
> "MyForm",
> WS_POPUP | WS_BORDER,
> 10,10,200,200,
> NULL,
> NULL,
> hInstance,
> NULL);
>
> MSG msg;
> PostMessage(HWND_BROADCAST, WM_USER, 0, 0L);
> if(PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
> MessageBox(NULL, "Work!", "", MB_OK);
> } else {
> MessageBox(NULL, "Don�t work!", "", MB_OK);
> }
> return 0;
> //*/
>
> On BCB6, I looked at the message gueue after the broadcast msg and there
is
> no msg to the peeked. And on the BC the message is there on the queue.
>
> Hope any help.
> Best regards,
> Alexandre S�
>
>
> "Remy Lebeau (TeamB)" <no.spam@no.spam.com> escreveu na mensagem
> news:42b317d0$1@newsgroups.borland.com...
> >
> > "Alexandre S�" <alexandre@daccord.com.br> wrote in message
> > news:42b30d0a$1@newsgroups.borland.com...
> >
> > > Let the code:
> >
> > Please show all of the code. You probably are not setting up your
window
> > properly, but your pseudocode doesn't show what you are actually doing.
> >
> >
> > Gambit
> >
> >
>
>
Technical Details
Message-ID:
<42b3322d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42b30d0a$1@newsgroups.borland.com> <42b317d0$1@newsgroups.borland.com> <42b31b9a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,af4f253f03c4e6fb X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: "Alexandre S�" <alexandre@daccord.com.br> Newsgroups: borland.public.cppbuilder.nativeapi References: <42b30d0a$1@newsgroups.borland.com> <42b317d0$1@newsgroups.borland.com> <42b31b9a@newsgroups.borland.com> Subject: Re: HWND_BROADCAST doesn�t work! Date: Fri, 17 Jun 2005 17:26:44 -0300 Lines: 136 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 200.249.236.130 Message-ID: <42b3322d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1119040045 200.249.236.130 (17 Jun 2005 13:27:25 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail