Solved

Problems w/ combo boxes in Dialog windows

Posted on 1997-04-09
2
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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