-
many buttons
is there some sort of limit of how many buttons you can have in the WM_COMMAND event?? i dont think so, but how come this doesn't work:
Code:
case WM_COMMAND: //click events
{
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[0])
{
paConfig(1);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[1])
{
paConfig(2);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[2])
{
paConfig(3);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[3])
{
paConfig(4);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[4])
{
paConfig(5);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[5])
{
paConfig(6);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[6])
{
paConfig(7);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[7])
{
paConfig(8);
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bReset)
{
paReset();
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bAllOn)
{
SendMessage(myhwnd, WM_COMMAND, (WPARAM)BN_CLICKED, (LPARAM)bLed[7]);
}
}
break;
the event when clicked bAllOn is not executed..how come? if i switch the event from bAllOn with the one from bReset, it works..
whats wrong??
Thanks
-
Code:
SendMessage(myhwnd, WM_COMMAND, (WPARAM)BN_CLICKED, (LPARAM)bLed[7]);
Try sending a different message. Perhaps WM_LMOUSEDOWN (or whatever, don't remember) followed by mouse-up?
-
hmm weird... anything i put in there doesn't seem to be executed..i tried calling other functions from my program, but doesn't work..
this buton(bAllOn) is suppoed to call this
but it doesn't work
-
wow this is just shouting for a loop huh ;) :p
-
you haven't seen the control creation.. LOL
i have thought about it, but my loop didn't work for the windows creation..
is it possible to have a loop here though? in the WM_COMMAND?
-
sure...in my checkers game I had a control array up there...works like a charm :D
-
hmm
steve, could you please show me the how you used the array in the WM_COMMAND message? thanks
-
PHP Code:
int i; //this is the loop variable
case WM_COMMAND: //click events
{
for(i=1; i<=7;i++) {
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bLed[i])
{
paConfig(i+1);
}
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bReset)
{
paReset();
}
if ((LOWORD(wParam) == BN_CLICKED) && (HWND)lParam == bAllOn)
{
SendMessage(myhwnd, WM_COMMAND, (WPARAM)BN_CLICKED, (LPARAM)bLed[7]);
}
}
break;
I typed this up in a minute or two...so there might be an error I missed....try that out. :D
See now isn't that so much nicer? :D
-
great..i am gonna try it..Thanks a lot =)
-
great..i am gonna try it..Thanks a lot :)
-
NOTE: i edited the code so use the new code when you read this :)
-
man...still doesn't work for the bAllOn stuff...but anyways thanks..
i'll try to fix it :)
-
Just a small comment on your code:
Instead of repeatedly checking for BN_CLICKED, you could create a condition similar to the following.
Code:
case WM_COMMAND:
if( HIWORD(wParam) == BN_CLICKED ) {
if( (HWND)lParam == hwndButton ) {
// ...
-
I just noticed something: You are checking the LOWORD of wParam for BN_CLICKED. BN_CLICKED is a notification, message, thus you should be checking the HIWORD instead.
-
man!! stil does't work..i dont understand...everything else works, except this button :(
-
thats really weird..i changed the name from bAll to bTotal, and it worked....weird =)