c++winapicomboboxcreatewindow

C++ Declare Combo Box Identifier


just wondering how to declare a combobox identifier. I've got two comboboxes on my page so I need two identifiers to distinguish them. I enter the following code but Visual Studio 15.5 tells me that IDC_COMBOBOX_LAYER is an undeclared identifier. It's supposed to be an integer but a number like 100 won't work either.

HWND hWndComboBox = CreateWindow(WC_COMBOBOX, TEXT(""),
    CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE,
    xpos, ypos, nwidth, nheight, parWnd, IDC_COMBOBOX_LAYER, NULL,
    NULL);

I've searched Google but I'm resigned to asking you here. How do I declare the identifier?


Solution

  • If this is not being used in a dialog resource I would suggest that you just assign a value and use it:

    enum CHILD_IDs : UINT { IDC_COMBOBOX = 1 };
    

    If it is being used in a dialog (but not part of the template for some reason) I suggest you define it through the resource system, go to the resource explorer (ctrl+shift+e) right click on the resource file and select "resource symbols", you then have the ooption of creating a new symbol value.