Solved

Problems w/ combo boxes in Dialog windows

Posted on 1997-04-09
2
426 Views
Last Modified: 2013-12-03
Ok, I have a dialog box, and I have a combo box within the dialog box.  I am trying to add items to the combo box, but the program refuses to do it.  Here are snippits of the dialog box definition in the rc script, and various relevant C code segments. . .

Here is from the rc file. . .

SETUPDIALOG DIALOG DISCARDABLE  20, 20, 186, 106
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
    WS_SYSMENU
CAPTION "Setup"
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,19,85,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,103,85,50,14
    LTEXT           "Generation Type:",IDC_STATIC,7,17,56,8
    LTEXT           "Generation Description:",IDC_STATIC,7,33,75,8
    EDITTEXT        IDC_EDIT1,7,44,172,35,ES_AUTOHSCROLL | ES_READONLY
    COMBOBOX        IDSETUP_COMBO,68,16,89,12,CBS_DROPDOWNLIST | WS_VSCROLL |
                    WS_TABSTOP
END


Here is the case from the oncommand function that creates the dialog box if someone calls setup. . .

case CM_SETUP:
            {
            FARPROC SetupProg =
                  MakeProcInstance((FARPROC)SetupPrgDlgProc, hInstance);
            DialogBox(hInstance,"SETUPDIALOG", MainWindow, (DLGPROC)SetupProg);
            FreeProcInstance(SetupProg);
            InvalidateRect(hwnd, NULL, TRUE);
            break;
            }


Here is the dialog callback function. . . (I also tried to send a message to a dialog item too)

/////////////////////////////////////
// Setup Dialog
////////////////////////////////////

#pragma argsused
BOOL CALLBACK SetupPrgDlgProc(HWND hDlg, UINT Message,
                                                WPARAM wParam, LPARAM lParam)
{
      char S[50];

      strcpy(S,"Method 1");
      switch(Message)
      {
      case WM_INITDIALOG:
            {
                  strcpy(com,"Init dialog called");
                  ComboBox_AddString(GetDlgItem(hDlg,IDSETUP_COMBO), S);
                  return TRUE;
            }
      case WM_COMMAND:
            if (LOWORD(wParam) == IDOK ||
                  LOWORD(wParam) == IDCANCEL)
            {
                  EndDialog(hDlg, LOWORD(wParam));
                  return TRUE;
            }
            break;
      }

      return FALSE;
}


I really want to be able to add multiple string options to this combo box for someone to select for the setup function, but it just doesn't want to add the strings.  If someone else has run into this - or sees what I am doing wrong - any and all help would be most appreciated.
0
Comment
Question by:navigator010897
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 150 total points
ID: 1334500
You C code is OK. When you created the combobox with AppStudio (or other Resource Editor), did you clicked on the down arrow of the combobox? Click on it, then you can set the drop down size. By default, it is the same size as the edit box. In fact, you did add a string to it but you could not see it. Or you can modify your RC file directly.

COMBOBOX IDSETUP_COMBO,68,16,89,62,CBS_DROPDOWNLIST |
                     WS_VSCROLL |
                         WS_TABSTOP

0
 

Expert Comment

by:Thuy
ID: 4992903
I got the same problem, too. None of CB_ADDSTRING or CB_INSERTSTRING, SendMessage or SendDlgItemMessage works.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TFS Branching 4 71
Should CArray be used for a list of pointers in C++? 19 97
Is AWS.RDS considered a part of "Big Data"? 4 94
Best book to learn C++ 4 70
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now