Results 1 to 16 of 16

Thread: many buttons

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    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
    Amon Ra
    The Power of Learning.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    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

    Code:
       paOutput(255);
    but it doesn't work
    Amon Ra
    The Power of Learning.

  4. #4
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    wow this is just shouting for a loop huh

  5. #5

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    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?
    Amon Ra
    The Power of Learning.

  6. #6
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    sure...in my checkers game I had a control array up there...works like a charm

  7. #7

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    hmm

    steve, could you please show me the how you used the array in the WM_COMMAND message? thanks
    Amon Ra
    The Power of Learning.

  8. #8
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    PHP Code:
    int i//this is the loop variable

    case WM_COMMAND:    //click events
            
    {
    for(
    i=1i<=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(myhwndWM_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.

    See now isn't that so much nicer?
    Last edited by SteveCRM; Sep 23rd, 2001 at 09:32 PM.

  9. #9

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    great..i am gonna try it..Thanks a lot =)
    Amon Ra
    The Power of Learning.

  10. #10

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    great..i am gonna try it..Thanks a lot
    Amon Ra
    The Power of Learning.

  11. #11
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    NOTE: i edited the code so use the new code when you read this

  12. #12

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    man...still doesn't work for the bAllOn stuff...but anyways thanks..
    i'll try to fix it
    Amon Ra
    The Power of Learning.

  13. #13
    Megatron
    Guest
    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 ) {
                // ...

  14. #14
    Megatron
    Guest
    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.

  15. #15

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    man!! stil does't work..i dont understand...everything else works, except this button
    Amon Ra
    The Power of Learning.

  16. #16

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    thats really weird..i changed the name from bAll to bTotal, and it worked....weird =)
    Amon Ra
    The Power of Learning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width