Click to See Complete Forum and Search --> : [RESOLVED] How to id which button is being pressed?


light85
June 26th, 2009, 12:49 PM
Hi, I have created 2 buttons on a window

hwndWin = CreateWindowEx(
WS_EX_CLIENTEDGE,
(LPCWSTR)g_szClassName,
(LPCWSTR)L"Streamer",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
NULL, NULL, hInstance, NULL);

//create Play button
hwndButtonP = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed.
L"Play", // Button text.
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles.
10, // x position.
500, // y position.
60, // Button width.
25, // Button height.
hwndWin, // Parent window.
NULL, // No menu.
(HINSTANCE)GetWindowLong(hwndWin, GWL_HINSTANCE),
NULL); // Pointer not needed.

//create Play button
hwndButtonS = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed.
L"Stop", // Button text.
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles.
80, // x position.
500, // y position.
60, // Button width.
25, // Button height.
hwndWin, // Parent window.
NULL, // No menu.
(HINSTANCE)GetWindowLong(hwndWin, GWL_HINSTANCE),
NULL); // Pointer not needed.


In the WinProc callback, in WM_COMMAND i have the BN_CLICKED.

Which i know that LPARAM lParam parameter should be used to id the button but how do i do it?

MrViggy
June 26th, 2009, 12:55 PM
CreateWindow (http://msdn.microsoft.com/en-us/library/ms632679(VS.85).aspx): Look at the 'hMenu' param.

Viggy