title: Get the text of a combo box Win32 API C++ (NO MFC)
body: <p>I am trying to setup a combo box so a user can select an option from the dropdown menu and then retrieve what the user selected using Win32 API C++ programming, not MFC. I read John's post <a href="https://stackoverflow.com/questions/3117619/get-set-combo-box-text-in-win32-not-mfc">here</a> and I could not get anything to work. I can set the text for the combo box, but I cannot retrieve what the user selected. Here are a few methods I have tried:</p>
  
  <pre><code>                LPTSTR buf;
                  ComboBox_GetText(hwnd, buf, 9);
                  MessageBox(NULL, buf, NULL, MB_OK);
  </code></pre>
  
  <p>And</p>
  
  <pre><code>                char* buf;
                  GetDlgItemText(hwnd, IDC_COMBO1, buf, 9);
                  MessageBox(NULL, buf, NULL, MB_OK);
  </code></pre>
  
  <p><code>IDC_COMBO1</code> is the ID of the combo box and <code>hwnd</code> is the HWND of the current dialog box.
  The code for my dialog box with the combo box is:</p>
  
  <p><code>LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
  IDD_DIALOG4 DIALOG 0, 0, 424, 181
  STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
  CAPTION "Dialog"
  FONT 8, "Ms Shell Dlg"
  {
      COMBOBOX        IDC_COMBO1, 113, 31, 119, 19, CBS_DROPDOWN | CBS_HASSTRINGS
      PUSHBUTTON      "Button1", IDC_BUTTON1, 188, 112, 50, 14
  }</code></p>
  
  <p>I am using a resource file to do this. Thanks in advance.</p>