Filling combobox

Interested in developing new plug-ins? Got one to share? Post here!
tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Filling combobox

Postby tofutim » Thu Jul 12, 2012 8:29 pm

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.

tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Filling combobox

Postby tofutim » Fri Jul 13, 2012 4:43 am

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.

tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Filling combobox

Postby tofutim » Fri Jul 13, 2012 5:16 am

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.

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Filling combobox

Postby FrancescoT » Fri Jul 13, 2012 11:23 am

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
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

tofutim
Posts: 176
Joined: Thu Mar 01, 2012 1:16 pm

Re: Filling combobox

Postby tofutim » Sat Jul 14, 2012 12:49 am

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.

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Filling combobox

Postby FrancescoT » Mon Jul 16, 2012 7:54 am

Dear tofutim,

the ComboBox data property doesn't work with Win32 project but with MFC project only.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Plug-In Development”

Who is online

Users browsing this forum: No registered users and 27 guests