Skip to main content
gamedev.net
🔒 Locked

Buttons Question

Started by DanTheRocker Nov 18, 2001 at 9:57 PM 2 replies 150+ views
Original Post
DanTheRocker
DanTheRocker
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?
-Dan
Oluseyi
Oluseyi
Look up WM_NOTIFY and NM_* messages.
JY
JY
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.
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
jtech
jtech
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.