-2

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?

drescherjm
  • 10,365
  • 5
  • 44
  • 64
MangoPapa7
  • 109
  • 1
  • 10
  • What do you mean by "_It's supposed to be an integer_"? Where did you read that? As described in the [documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632679(v=vs.85).aspx), the parameter where you are trying to pass `IDC_COMBOBOX_LAYER` to is of type `HMENU`. Which is **not** an integer. – Algirdas Preidžius Dec 07 '17 at 02:54
  • It's an HMENU but when used with a window with the WS_CHILD style it's treated as v.an integer. – SoronelHaetir Dec 07 '17 at 05:05
  • Have a look at [The Definitive C++ Book Guide and List](https://stackoverflow.com/q/388242). This is really, *really* basic. – IInspectable Dec 07 '17 at 09:36

1 Answers1

1

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.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23
  • [Why do dialog editors start assigning control IDs with 100?](https://blogs.msdn.microsoft.com/oldnewthing/20041214-00/?p=37013/) – IInspectable Dec 07 '17 at 09:21