I have made a combobox in a simple dialog like this
Code:
CONTROL "", IDCOMBO, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_VSCROLL|CBS_SORT , 28, 28, 84,300
I have added a couple of options to it, and i can select them with the keyboard.
However, when i click with a mouse on the combobox i get an empty dropdownbox which does not react to mouseclicks. I have to use the keyboard to make the options visible and to select one.
this is the command handling procedure (or whatever it is called):
Code:
BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hParent = GetParent(hwnd);
HWND hBut;
RECT rectParent;
RECT rectBut;
HWND hStatus = GetDlgItem(hwnd, ID_TEX_STATUS);
int i;
GetClientRect(hParent,&rectParent);
switch(msg)
{
case WM_INITDIALOG:
SendMessage(GetDlgItem(hwnd,IDCOMBO), CB_RESETCONTENT ,0,0);
EnableWindow(GetDlgItem(hwnd, IDCOMBO), false);
EnableWindow(GetDlgItem(hwnd, IDCOMBO), true);
SendMessage(GetDlgItem(hwnd,IDCOMBO), CB_ADDSTRING ,0,(LPARAM)"option1");
SendMessage(GetDlgItem(hwnd,IDCOMBO), CB_ADDSTRING ,0,(LPARAM)"option2");
SendMessage(GetDlgItem(hwnd,IDCOMBO), CB_ADDSTRING ,0,(LPARAM)"option3");
SendMessage(GetDlgItem(hwnd, IDCOMBO),CB_SELECTSTRING,(WPARAM)-1,(LPARAM)"option3");
return true;
break;
case WM_MOVE:
return true;
break;
case WM_CLOSE:
PostQuitMessage(WM_QUIT);
return true;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_BUT_GO:
SendMessage(GetDlgItem(hwnd, IDCOMBO),CB_SELECTSTRING,(WPARAM)-1,(LPARAM)"option1");
SendMessage(hStatus,WM_SETTEXT,(WPARAM)NULL,(LPARAM) "blablabla");
return true;
break;
case ID_BUT_EXIT:
PostQuitMessage(WM_QUIT);
return true;
break;
case IDCOMBO:
//MessageBox(hwnd, "combo is used", "WARNING",MB_OK | MB_ICONEXCLAMATION);
return true;
break;
default:
return false;
}
break;
default:
return false;
}
return false;
}