c++ win 32 adding list items into a combo box




I want the user to select from a drop-down list of items in a combo box. I have called the WM_CREATE function and the user can input text. Here, I've been able to add 'Item 2', 'Item 1' seems not to show. What should I do? This is what I have

#define WC_COMBOBOX

case WM_CREATE: {

// CREATE COMBO BOX

HWND hWndComboBox = CreateWindow (TEXT("COMBOBOX"), TEXT (""),
CBS_DROPDOWN | CBS_HASSTRINGS | WS_VISIBLE | WS_CHILD | WS_BORDER,
100, 20, 200, 20,
hwnd,(HMENU) NULL, NULL, NULL);

// ADD 2 ITEMS SendMessage ( hWndComboBox, (UINT) CB_ADDSTRING , (WPARAM) 0, (LPARAM) TEXT ("Item 1")); SendMessage ( hWndComboBox, (UINT) CB_ADDSTRING, (WPARAM) 0, (LPARAM) TEXT ("Item 2"));

// SEND THE CB_SETCURSEL MESSAGE TO DISPLAY AN INITIAL ITEM IN SELECTION FIELD SendMessage (hWndComboBox, CB_SETCURSEL, (WPARAM) 1, (LPARAM) 0);
You're isn't quite the same as the sample. Why don't you start with this.
https://msdn.microsoft.com/en-us/library/windows/desktop/hh298364%28v=vs.85%29.aspx
Maybe it's a problem with the drop down list being too small for two items?
coder777 was right. When the height of the combobox is >= 80 both items show.
Topic archived. No new replies allowed.