Article View: borland.public.cppbuilder.nativeapi
Article #5781Re: Unregistered HWND_BROADCAST messages
From: Bob Gonder
Date: Wed, 29 Jun 2005 16:58
Date: Wed, 29 Jun 2005 16:58
63 lines
2898 bytes
2898 bytes
Alexandre S� wrote:
>I�m trying to migrate an old BC++ 4.5 project to the BCB6.
>After the migration to BCB6, the unregistered broadcast
>messages didn�t work any more.
>
>Is there a way to make BCB6 work like BC++ does?
This code works:
#include <windows.h>
//---------------------------���-----------------------------�-��-----------
LRESULT __stdcall WINAPI WndProc (HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
if((msg==WM_COMMAND) &&(wParam== (WM_USER+2)) )
{ MessageBox( hWnd, "Work!", "", MB_OK);
PostMessage( hWnd, WM_QUIT,0,0 );
};
return (DefWindowProc(hWnd,msg,wParam,lParam));
}
//------------------------�---��---------------------------�-�-�------------
#pragma argsused
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS windowClass = {0};
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";
if(!RegisterClass(&windowClass)) {
MessageBox(NULL, "!RegisterClass", "", MB_OK);
}else{
HWND hWindow = CreateWindow (
"TMyForm", "MyForm", WS_POPUPWINDOW,
10, 10, 200, 200, NULL, NULL,
hInstance, NULL);
if(!hWindow) {
MessageBox(NULL, "!CreateWindow", "", MB_OK);
}else{
ShowWindow(hWindow, SW_SHOW);
UpdateWindow(hWindow);
PostMessage(HWND_BROADCAST, WM_COMMAND,WM_USER+2, 0L);
MSG msg;
while (GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
};
MessageBox(NULL, "end", "", MB_OK);
};};
return 0;
}
Technical Details
Message-ID:
<0dk5c1ho1u1gbt1qmfcgulfr8ec9l1mqec@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<42c2c8b7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,165a0162272fa9dd X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Unregistered HWND_BROADCAST messages Date: Wed, 29 Jun 2005 09:58:05 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <0dk5c1ho1u1gbt1qmfcgulfr8ec9l1mqec@4ax.com> References: <42c2c8b7$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 71.0.135.246 X-Trace: newsgroups.borland.com 1120064286 71.0.135.246 (29 Jun 2005 09:58:06 -0700) Lines: 66 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail