veigo18
January 17th, 2006, 07:41 AM
Hello
I made two buttons and want to recognise which button is clicked by user.
Found at MSDN that "For a child window, hMenu specifies the child-window identifierin" in CreateWindow function. But compiler gives error "invalid converison from int to HMENU_".
#define ID_BTN1 401
hwndButton = CreateWindow(
"BUTTON", // predefined class
"OK", // button text
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_FLAT, // styles
250, // starting x position
250, // starting y position
40, // button width
40, // button height
hwnd, // parent window
ID_BTN1, //
(HINSTANCE) GetWindowLong(hwnd, GWL_HWNDPARENT),
NULL); // pointer not needed
what's wrong here?
Is it correct to use following code if I want to check which button was clicked?
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
switch (lParam)
{
case ID_BTN1:
...
case ID_BTN2:
...
Thanks in advance!
I made two buttons and want to recognise which button is clicked by user.
Found at MSDN that "For a child window, hMenu specifies the child-window identifierin" in CreateWindow function. But compiler gives error "invalid converison from int to HMENU_".
#define ID_BTN1 401
hwndButton = CreateWindow(
"BUTTON", // predefined class
"OK", // button text
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_FLAT, // styles
250, // starting x position
250, // starting y position
40, // button width
40, // button height
hwnd, // parent window
ID_BTN1, //
(HINSTANCE) GetWindowLong(hwnd, GWL_HWNDPARENT),
NULL); // pointer not needed
what's wrong here?
Is it correct to use following code if I want to check which button was clicked?
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
switch (lParam)
{
case ID_BTN1:
...
case ID_BTN2:
...
Thanks in advance!