Advertisement Jump to content


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


Buttons Question

This topic is 6270 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''ve created a normal button like this: hPlayButton = CreateWindow ("button", "", WS_CHILD | WS_VISIBLE | BS_BITMAP, 21, 473, BUTTONSIZE, 20, hWnd, (HMENU) ID_PLAYBUTTON, hThisInstance, NULL ); It shows up fine but my problem is finding out when it is clicked. The ID_PLAYBUTTON is defined like this: #define ID_PLAYBUTTON WM_USER + 3 hWnd is a handle to the main window. How do I respond to messages sent by this button?

Share this post

Link to post
Share on other sites
The identifier of the button shouldn''t really be defined as a windows'' message. (WM_USER + x) is used for sending user defined messages between windows.

When your button is pressed is will generate the WM_COMMAND message. The LOWORD of wParam will then give you the ID of the control generating the message.

You should define the ID for the button in the resources header file. If you are using VC++ you can do this by right-clicking on the ResourceView and select Resource Symbols.

Share this post

Link to post
Share on other sites
Since it''s a child window, it sends its window messages to its
parent''s WndProc. So it looks like your parent is whatever
you passed as hWnd. Check your parent''s WM_COMMAND message
for your button''s ID.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!