Jump to content
  • Advertisement

Archived

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

Squeejee

Trouble being notified which button was pressed.

This topic is 6074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!