Solved

Problems w/ combo boxes in Dialog windows

Posted on 1997-04-09
2
419 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

20 Experts available now in Live!

Get 1:1 Help Now