locked
Meaning of Common Control ID, InitCommonControlsEx return 0 RRS feed

  • Question

  • In

            case WM_COMMAND:
                 {
                     int wmKind = HIWORD(wParam);
                       int wmId = LOWORD(wParam);

    in something like EN_UPDATE, the loword is an ID that I have not seen a definition. With one child  edit control it was 0x400. I wondered what it is and use. Another thing was why InitCommonControlsEx returning FALSE when I tried to load an edit control and wondered if that means it was already loaded?


    • Edited by mwindham Wednesday, May 6, 2020 7:24 PM
    Wednesday, May 6, 2020 7:23 PM

Answers

  • wmId is the ID assigned in HMENU of CreateWindowEx

    Edit controls are included in ICC_STANDARD_CLASSES

    and InitCommonControlsEx returns TRUE if I do a test with Common Controls v6

    with 

    #pragma comment(linker,"\"/manifestdependency:type='win32' \
    name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
    processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

    But not needed for Edit controls...

    • Marked as answer by mwindham Thursday, May 7, 2020 4:15 AM
    Wednesday, May 6, 2020 8:01 PM
  • The meaning of the wParam and lParam data passed with a W_COMMAND message depends on context.  This is explained in a table at https://docs.microsoft.com/en-us/windows/win32/menurc/wm-command#remarks

    Use of the wParam and lParam parameters are summarized here.

    Table 1
    Message Source wParam (high word) wParam (low word) lParam
    Menu 0 Menu identifier (IDM_*) 0
    Accelerator 1 Accelerator identifier (IDM_*) 0
    Control Control-defined notification code Control identifier Handle to the control window

    ----------------------------------------------------

    So for an EN_UPDATE notification from an edit control the low word of wParam is the control id of the control that is sending the notification.  This is also documented at EN_UPDATE notification code

    InitCommonControlsEx could fail (return FALSE) if the INITCOMMONCONTROLSEX structure was improperly initialized.

    • Edited by RLWA32 Wednesday, May 6, 2020 10:20 PM
    • Marked as answer by mwindham Thursday, May 7, 2020 4:15 AM
    Wednesday, May 6, 2020 9:57 PM

All replies

  • wmId is the ID assigned in HMENU of CreateWindowEx

    Edit controls are included in ICC_STANDARD_CLASSES

    and InitCommonControlsEx returns TRUE if I do a test with Common Controls v6

    with 

    #pragma comment(linker,"\"/manifestdependency:type='win32' \
    name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
    processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

    But not needed for Edit controls...

    • Marked as answer by mwindham Thursday, May 7, 2020 4:15 AM
    Wednesday, May 6, 2020 8:01 PM
  • The meaning of the wParam and lParam data passed with a W_COMMAND message depends on context.  This is explained in a table at https://docs.microsoft.com/en-us/windows/win32/menurc/wm-command#remarks

    Use of the wParam and lParam parameters are summarized here.

    Table 1
    Message Source wParam (high word) wParam (low word) lParam
    Menu 0 Menu identifier (IDM_*) 0
    Accelerator 1 Accelerator identifier (IDM_*) 0
    Control Control-defined notification code Control identifier Handle to the control window

    ----------------------------------------------------

    So for an EN_UPDATE notification from an edit control the low word of wParam is the control id of the control that is sending the notification.  This is also documented at EN_UPDATE notification code

    InitCommonControlsEx could fail (return FALSE) if the INITCOMMONCONTROLSEX structure was improperly initialized.

    • Edited by RLWA32 Wednesday, May 6, 2020 10:20 PM
    • Marked as answer by mwindham Thursday, May 7, 2020 4:15 AM
    Wednesday, May 6, 2020 9:57 PM
  • The pragma comment is what was needed to get a TRUE from initCommonControlsEx though the control was created sometime later. There was a lively discussion  over at 

    https://stackoverflow.com/questions/37505212/unparented-window-cant-have-hmenu-id-set. Would itbe correct to use any number for child id's as long as I cast to (HMENU) and make sure of identity? Without specifying it was 0x400. Or should I not do such and associate the ID of a child Control by matching a its hwnd if I were for some reason want to use its Id?


    • Edited by mwindham Wednesday, May 6, 2020 10:52 PM
    Wednesday, May 6, 2020 10:50 PM
  • I wonder how I mark both replies as an answer since I asked two questions. Thanks for both replies.
    • Edited by mwindham Wednesday, May 6, 2020 10:59 PM
    Wednesday, May 6, 2020 10:58 PM
  • Hello mwindham,

    You can mark multiply replies an answers if they all are helpful for solving your issue.

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 7, 2020 1:44 AM
  • I just tried to get the id from using two edit controls.Both turned out to be zero from as children both set to to zero for HMENU. I am not sure where the 0x400 for one came from last night, but both have same ID(different hWnds).

    When I use

    hWnd0 = CreateWindowExW( 0, WC_EDIT, L"Hello World0", WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP,
           50, 80, 400, 100,  hWnd, (HMENU)0x400, hInstance, NULL);
       hWnd1 = CreateWindowExW(0, WC_EDIT, L"Hello World1", WS_BORDER | WS_VISIBLE | WS_CHILD | WS_TABSTOP
           | ES_AUTOVSCROLL | WS_VSCROLL | ES_MULTILINE,
           50, 200, 400, 360, hWnd, (HMENU)0x402, hInstance, NULL);
    //...  I get the different IDs back in
    
    case WM_COMMAND:
            {
                int wmKind = HIWORD(wParam);
                int wmId = LOWORD(wParam);
                if (wmKind == EN_UPDATE){ //|| wmKind == EN_CHANGE) {
                    HANDLE hSender = (HANDLE)lParam;
                    if (hSender == hWnd0) {
                        wId0 = wmId;
                        int ilen = GetWindowTextLength(hWnd0);
                        if (ilen < BUFFER0)GetWindowText(hWnd0, &awc0[0], BUFFER0);
                    }
                    else if (hSender == hWnd1) {
                        wId1 = wmId;
                        int ilen = GetWindowTextLength(hWnd1);
                        if (ilen < BUFFER1)GetWindowText(hWnd1, &awc1[0], BUFFER0);
                    }
                    //
                    break;
                }
                // Parse the menu selections:

    Thursday, May 7, 2020 1:46 AM