?
Solved

Problems w/ combo boxes in Dialog windows

Posted on 1997-04-09
2
Medium Priority
?
434 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 300 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

765 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