Archived

This topic is now archived and is closed to further replies.

Squeejee

Trouble being notified which button was pressed.

Recommended Posts

Squeejee    122
I made a window with a few buttons on it. I set it up so when a button is pressed, the window closes. I want to know how to tell which button was pressed. The Quit (hQuitButton) button in pertictular. This is what I have:
  
  case WM_COMMAND:
	{
	  switch(LOWORD(wparam))
	  {

	  case BN_CLICKED:
		{

		  PostQuitMessage(0);
		  return(0);
		  break;

		}

	  default:break;
	  }
	}
  

Share this post


Link to post
Share on other sites
Shannon Barber    1681
lParam will have a handle to the button in it
The loword of wParam contains the ID of the control - not the notification code (i.e. BN_CLICKED) that''s in the hiword.

BN_CLICKED

I haven''t used this much, but that''s what both the MSDN and Petzold say.

Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Squeejee    122
So, I do this?:

  

case WM_COMMAND:
{
switch(LOWORD(wparam))
{

case BN_CLICKED:
{
if(hQuitButton == lparam)
{
PostQuitMessage(0);
return 0;
break;
}
break;

default:break;
}
}


I says: error C2446: ''=='' : no conversion from ''long'' to ''struct HWND__ *''
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Share this post


Link to post
Share on other sites
Shannon Barber    1681
Well, make it happy and cast it - in this case it's what you need to do:

  
switch(HIWORD(wparam))
{
case BN_CLICKED:
if(hQuitButton == (HWND)lparam)
}


Magmai Kai Holmlor
- Not For Rent

Edited by - Magmai Kai Holmlor on November 7, 2001 1:52:07 AM

Share this post


Link to post
Share on other sites