Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I have used AddString to add elements to a combobox in a dialog box, but he list isn't displayed

Posted on 1998-10-11
4
Medium Priority
?
730 Views
Last Modified: 2012-08-13
Hi again...

I'm programming an application based on a dialog box. That dialog box is a resource. I have on the dialog a Combobox which I fill with strings using AddString method. It seems that it works, because when I run the application.. the elements are on the list (pressing up or down arrow keys, the elements are displayed one by one), but when I press on the combobox arrow, the list isn't dropped down.

The million question... How can I do it? I'm programming in BC++ 5.0.
Thanks in advance

Jaime

Here's my application:

#include <owl\pch.h>
#include <owl\applicat.h>
#include <owl\combobox.h>
#include <owl\dialog.h>
#include <owl\framewin.h>
#include "Clusters.h"

class TClusterDlg : public TDialog
{
  public:
    TClusterDlg( TWindow* parent, const char far* name );

    void UpdateDialog( );

  protected:
    TComboBox* DiskList;

    void SetupWindow( );

  DECLARE_RESPONSE_TABLE( TClusterDlg );
};

DEFINE_RESPONSE_TABLE1( TClusterDlg, TDialog )
  EV_COMMAND( IDOK, CmOk ),
END_RESPONSE_TABLE;

TClusterDlg::TClusterDlg( TWindow* parent, const char far* name ) :
                          TDialog( parent, name ), TWindow( parent )
{
  DiskList = new TComboBox( this, IDC_DRIVES );
}

void TClusterDlg::SetupWindow( )
{
  char Discos[80];
  UINT StringPos = 0, TipoDisco;

  TDialog::SetupWindow( );
  /* Borra los datos a desplegar en el cuadro de diálogo */
  SetDlgItemText( IDC_NUMBYTES, "" );
  SetDlgItemText( IDC_NUMFILES, "" );
  SetDlgItemText( IDC_BYTES, "" );
  SetDlgItemText( IDC_PORCENTAJE, "" );
  SetDlgItemText( IDC_CLUSTERSIZE, "" );
  /* Obtiene las unidades de disco disponibles */
  GetLogicalDriveStrings( 78, Discos );
  while( Discos[StringPos] ) {
    /* Obtiene que tipo de disco es */
    TipoDisco = GetDriveType( &Discos[StringPos] );
    if( TipoDisco == DRIVE_FIXED || TipoDisco == DRIVE_REMOVABLE ) {
      /* Llena el combobox de discos si es disco duro o diskette */
      DiskList->AddString( &Discos[StringPos] );
    }
    StringPos += 4;
  }
}

void TClusterDlg::UpdateDialog( )
{

}

class TClusterApplication : public TApplication
{
  public:
    TClusterApplication( ) : TApplication( "Desperdicio de clusters App" ) {}

    void InitMainWindow( )
    {
      EnableCtl3d( );
      Dialog = new TClusterDlg( 0, "ClusterDlg" );
      MainWindow = new TFrameWindow( 0, "Desperdicio de Clusters", Dialog, TRUE );
      MainWindow->SetIcon( this, "ClusterDlg" );
      MainWindow->Attr.Style &= ~(WS_MAXIMIZEBOX|WS_THICKFRAME);
    }

  private:
    TClusterDlg* Dialog;
};

int OwlMain( int /*argc*/, char * /*argv*/ [] )
{
  return TClusterApplication( ).Run( );
}
0
Comment
Question by:demarcy
[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
4 Comments
 

Accepted Solution

by:
clance earned 150 total points
ID: 1174862
The problem is that your combo box has the same height opened as it does closed.  You change its height in the resource file (MyApp.rc).  Examine the following example:

BEGIN
    COMBOBOX        IDC_MY_CBO,360,161,157,118,CBS_DROPDOWNLIST |
                    WS_VSCROLL | WS_TABSTOP
END

The numbers represent in order upper-left corner X, upper-left corner Y, width, and height.  Increase the height and you increase the size of the drop down portion.

If you need to do this programmatically, I believe you'd have to make your combo box an owner draw and handle messages yourself.  However, I can't imagine why anyone would want or need to do that.

Hope that answers your question.

-- Craig

0
 

Expert Comment

by:KCN
ID: 1174863
In dialog editor,you can click the drop down box on the right of the combo box.The rectangle of control will extension to the area after droping down.Then you can adjust it.
0
 

Author Comment

by:demarcy
ID: 1174864
Thanks.. that worked.... now... how can I notify the application that the combobox has changed its value? that is, how can I define an event for the combobox.

Thanks again in advance
Jaime
0
 

Expert Comment

by:clance
ID: 1174865
Well, here's the rub.  You're using Borland's OWL.  I use Microsoft's MFC ClassWizard.  So, I cannot tell you the easy OWL way of doing this.  However, I can tell you how to find it.

Given my example of having a combo box identifier IDC_MY_CBO, I can tell MFC's ClassWizard to map the CBN_SELCHANGE windows message to my IDC_MY_CBO combo box.  ClassWizard makes an empty function named OnSelchangeMyCBO().  I'm sure Borland has something similar to ClassWizard.

But, the key here is to look up the CBN_SELCHANGE windows message.  Regardless of what brand compiler, what application framework you are using, and whether you use C or C++, when the current selection has changed a CBN_SELCHANGE message will be sent to the dialog box that has the combo box as a control (unless you make your combo box an owner-draw control, but that's another story).
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

715 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