none
Combo Box Drop Down and Drop Down List RRS feed

  • Question

  • How do I PROPERLY get the string of a selected item in a combo box? msdn provide several ways of doing it but what is the best way? Here's my code:

    			case CBN_SELCHANGE:
    				{
    					
    					switch (LOWORD (wparam))
    					{
    						case 2:
    						{
    							x = ComboBox_GetCurSel (hCmbBx); // combo Box (Drop-down style)
    							_itow_s (x, buffer, 20, 10);
    							buffer_s = buffer;
    							switch (x)
    							{
    							case 0:
    								{
    									MessageBox (hWnd, L"You have chosen the C# programming language.", L"Message", MB_OK | MB_ICONINFORMATION);
    									break;
    								}
    							}
    							break;
    						}
    						case 3:
    						{
    							ComboBox_GetText (hCmbBx2, buffer, 19); // Combo Box (Drop-down list style)
    							buffer_s = L"You have chosen the ";	
    							buffer_s += buffer;
    							buffer_s += L" programming language.";
    							MessageBox (hWnd, buffer_s.c_str (), L"Message", MB_OK | MB_ICONINFORMATION);
    							break;
    						}
    					}
    					break;
    The code in case 3 (which is a combo box drop down list style) doesn't seem to work in a combo box with a drop down style.

    Tuesday, June 11, 2013 8:08 AM

Answers