Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HWND_BROADCAST and CDialog

Status
Not open for further replies.

cchipman

IS-IT--Management
Sep 16, 2002
125
US
I've created a simple dialog based app and I am having some message problems. I'm trying to send it a windows mesage of a define user type.

I define the message thus:
Code:
#define MW_SHOW_TROY WM_USER + 1

Create the map entry in the dialog.ccp file

Code:
	ON_MESSAGE(MW_SHOW_TROY, OnMwShowTroy)

and create the map entry in the h file:

Code:
	afx_msg LONG OnMwShowTroy( UINT uParam, LONG lParam );

if I call send message in either of these fashions

Code:
	::SendMessage(AfxGetMainWnd()->GetSafeHwnd(), MW_SHOW_TROY,       // message to post
				0x0012345,  // first message parameter
				(LPARAM)pdata);// second message parameter

	AfxGetMainWnd()->SendMessage(MW_SHOW_TROY,       // message to post
				0x0012345,  // first message parameter
				(LPARAM)pdata);// second message parameter

it works. However, if I send it this way:

Code:
	::SendMessage(HWND_BROADCAST, MW_SHOW_TROY,       // message to post
			0x0012345,  // first message parameter
			(LPARAM)pdata);// second message parameter

it doesn't. I'm missing something simple, aren't I. I wouldn't be bothering with it, except where having to use a MFC app with a lot of code running in a non-mfc thread, and I'm not wanting to have to pass it a window handle, but wanting to use the broadcast. Do dialog based apps not respond to broadcast messages?
 
Broadcast messages only go to top-level windows, and not to their children. Maybe your dialog is not set up as a top-level window?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top