Thread: Wm_command?

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    Wm_command?

    can you use switch case in the WM_COMMAND message instead of if in C and API?

    if so how would you do this, thanks

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    9
    Of course u can use switch statements:

    eg:-
    switch(&msg)
    {
    case WM_COMMAND:
    {
    case 1: //Add cases such as button clicks
    //Add code here
    }
    }

    I'm new 2 the subject. apologies if something gets wrong

  3. #3
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    here ill explain what i mean
    with if you use say
    if((HWND)lParam == hwndButton){....

    is there a way with switch case so you can case hwndButton like this.

    case hwndButton:

    or something like that

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    84
    Where's the problem? Example:
    Code:
    switch (uMsg)
    {
    case WM_COMMAND:
        WORD wCtrlID = LOWORD(wParam);
        WORD wNotify = HIWORD(wParam);
        
        if (lParam) // Control
            switch (wCtrl)
            {
            case IDC_BUTTON1:
                if (wNotify == BN_CLICKED)
                    DoStuff();
                break;
            case IDC_BUTTON2:
                if (wNotify == BN_CLICKED)
                    DoStuff();
                break;
            case IDC_BUTTON2:
                if (wNotify == BN_CLICKED)
                    DoStuff();
                break;
            }
        else        // Menu
        {
        }
        
        return 0;
        
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }

Popular pages Recent additions subscribe to a feed
Website Security Test