Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

catching a button clic !!!

Status
Not open for further replies.

iza

Programmer
Apr 4, 2000
1,804
FR
... sounds easy but i've got troubls in doing it !!!!

i have a window in which i created a button (using CreateWindow("BUTTON", ...))
now i want the click on that button to be catched ... so i added :
LRESULT CALLBACK MyClass::WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
MyClass *pThis = ...

switch (uMessage)
{
case WM_NCCREATE:
{
...
}
break;

case WM_PAINT:
return pThis->OnPaint();

case BN_CLICKED():
return pThis->OnClickedLeBouton();

case WM_LBUTTONDOWN:
return pThis->OnLButtonDown();

case WM_COMMAND:
...
...
}
}

and this NEVER EVER calls the "OnClickedLeBouton()" function ....
BUT ... the clic on the button is catched by WM_COMMAND !!!

so i added
case WM_COMMAND:
switch (lParam)
{
case LE_BOUTON: // LE_BOUTON is the identifier for the button i created
return pThis->OnClickedLeBouton();
..

but it never catches the clic on the button anyway - it skips the "case ..."

do you have an explanation ? does it seem very weird to you or is it a normal behaviour ? i must missing something but i can't see exactly what :-/

i'll be glad with any help :)))
 
iza,

Your first attemp:
case BN_CLICKED():

Was certainly not going to work. I'm surprized it even compilied.

Now your problem should be with this code:
case WM_COMMAND:
switch (lParam)


You are looking for the resource ID in the LPARAM parameter, as we can see from the WM_COMMAND SDK documentation below, that is not where it is.


LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_COMMAND
WPARAM wParam, // notification code and identifier
LPARAM lParam // handle to control (HWND)
);


Hope this helps
-pete
 
yes, that was LOWORD(wParam)
thank you :))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top