Page 1 of 1
Filling combobox
Posted: Thu Jul 12, 2012 8:29 pm
by tofutim
Hi, is there something special I need to do to fill a combobox on the IDE side? Seems like using CB_ADDSTRING or even the Data field in Visual Studio has no effect. I'm trying to add the strings in WM_INITDIALOG of the dialog. SendDlgItemMessage returns 0 (not -1, error), but 0 everytime, and when I go to count the items, it is zero too!
So strange.
Re: Filling combobox
Posted: Fri Jul 13, 2012 4:43 am
by tofutim
I used the essentially the same .rc dialog (not MFC) for a Win32 exe and the combo box options render fine. Here's how the .rc code looks
Code: Select all
IDD_DIALOG_IDE DIALOGEX 0, 0, 316, 185
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,205,164,50,14
PUSHBUTTON "Cancel",IDCANCEL,259,164,50,14
COMBOBOX IDC_COMBO1,55,62,135,72,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
IDD_DIALOG_IDE DLGINIT
BEGIN
IDC_COMBO1, 0x403, 10, 0
0x4c43, 0x4349, 0x4f4b, 0x434e, 0x0045,
IDC_COMBO1, 0x403, 8, 0
0x5250, 0x434f, 0x5345, 0x0053,
0
END
And I call it simply using
Code: Select all
HWND hwnd = (HWND)Window;
INT_PTR result = DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_IDE), hwnd, dlgProc);
if (result != IDOK) return -1;
and
Code: Select all
BOOL CALLBACK dlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
{
return TRUE;
}
case WM_COMMAND:
{
switch(wParam)
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, wParam);
return TRUE;
}
break;
}
}
return FALSE;
}
Am I missing something really obvious here? Is there some initialization I need on the combo? The combo items do not show up in InstallAware when the dialog comes up - and the count of items inside is always zero.
Re: Filling combobox
Posted: Fri Jul 13, 2012 5:16 am
by tofutim
My mom must have prayed.
I rebuilt my projects. The "data" field in the Properties window still doesn't work, but I was able to get my combobox options to show up using SendMessage.
Re: Filling combobox
Posted: Fri Jul 13, 2012 11:23 am
by FrancescoT
Dear tofutim,
If you want it can be developed using MFC too.
Are you separating Items with semicolons for the data property of the ComboBox?
It should work sending the message CB_ADDSTRING during WM_INITDIALOG, are you using the correct HWND handle to the Control?
Regards
Re: Filling combobox
Posted: Sat Jul 14, 2012 12:49 am
by tofutim
I never did figure out what was wrong. Once I rebuilt it, it seemed to work (although filing in Data still doesn't work - separated by
. No worries.
Re: Filling combobox
Posted: Mon Jul 16, 2012 7:54 am
by FrancescoT
Dear tofutim,
the ComboBox data property doesn't work with Win32 project but with MFC project only.
Regards