Solved

OWL TComboBox help

Posted on 1997-04-28
9
307 Views
Last Modified: 2013-12-04
I have a custom dialog box (which I'm loading from a resource) that is created by a function call within a DLL that I'm writing.  I have three combo boxes in the dialog, which I wish to use as dropdown single-selection lists.  I have written my own class which inherits from TDialog.  I overloaded SetupWindow() to initialize the comboboxes to contain the text I want. Here's the current code that I'm trying to make work:

void UserDataDialog::SetupWindow()
{
  // Can't play with controls until TDialog::SetupWindow()
  // is called
  TDialog::SetupWindow();

  gender->InsertString(" ", 0);
  gender->InsertString("Male", 1);
  gender->InsertString("Female", 2);

  ageRange->InsertString(" ", 0);
  ageRange->InsertString("under 21", 1);
  ageRange->InsertString("21 and over", 2);

  incomeRange->InsertString(" ", 0);
  incomeRange->InsertString("Got a tax refund", 1);
  incomeRange->InsertString("Owed more taxes", 2);
}

My problem is that the comboboxes are completely empty if you click on the dropdown arrow with the mouse.  However, I have found that if you use the keyboard to select an item (using the up/down arrow keys), the strings are actually there.  In either case, though, the combobox reports that the selected item is index number zero, regardless of what may have been selected.  The InsertString functions actually succeed (I tested that first thing), but still the dropdown list is not properly initialized.  I tried using SendDlgItemMessage, but that didn't work either.  Using Borland's WinSight tool, I know that the boxes are being created and are receiving mouse clicks.

*** What am I missing? ***

Feel free to email me at olsonmd@aureate.com
0
Comment
Question by:gurumike
[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
  • 5
  • 4
9 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 200 total points
ID: 1396945
Try to use just AddString:gender->AddString(" ");
gender->AddString("Male");
gender->AddString("Female");// Now select "Female" (if your combobox has no CBS_SORT style)gender->SetSelIndex(2);

ageRange->AddString(" ");
ageRange->AddString("under 21");
ageRange->AddString("21 and over");
// Now select "under 21"
ageRange->SetSelIndex(1);

0
 

Author Comment

by:gurumike
ID: 1396946
I tried doing as you suggested.  I failed to mention in the question that I had tried AddString() before, and it had failed; however, I previously didn't do any SetSelIndex() calls.  So, I tried it without effect.  I am using BC++ 5.02 - could v5.02 have a bug that causes this to fail?  I checked Borland's website recently and was unable to find any bug reports of this nature.
I think I'll increase the number of points this question is worth - I may have underestimated its trickiness.  I'm not going to reject this answer though until I give you a chance to comment!

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396947
Can you post your source code (constructor with calls to TEdit, SetupWindow(), resource statements)?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 15

Expert Comment

by:NickRepin
ID: 1396948
You can write me directly to nick@rtzi.ru
0
 

Author Comment

by:gurumike
ID: 1396949
[Sent relevant source to NickRepin]

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396950
You have used too small height for your edit controls (12).
Set it as 80 (for example). This value defines not the height of selection field but the height of drop-down list! So your drop-down list window is too small to display items.

Check this in resource editor by selecting Dialog->TestDialog menu.


0
 

Author Comment

by:gurumike
ID: 1396951
Great!  Thanks for the answer.  As I received your email, I found that this question had been asked before (and I got the same answer there, too!)  Experts Exchange needs to do some interface work...

The only thing that still bugs me is that my code still reports zero as the index of the selected values, regardless of what I choose.  Any hints there?  (I did put that in the original question, although it's probably a more trivial problem)

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396952
You used following code:int UserDataDialog::Execute() {
  int ret = TDialog::Execute();
  data->gender = gender->GetSelIndex();
  data->ageRange = ageRange->GetSelIndex();
  data->incomeRange = incomeRange->GetSelIndex();
  return ret; }
But if TDialog::Execute() executes then all controls of this dialog box does not exist (I mean windows, not TComboBox objects). So their cannot respond to GetSelIndex().Use CleanupWindow() instead of Execute():void UserDataDialog::CleanupWindow(){
  data->gender = gender->GetSelIndex();
  data->ageRange = ageRange->GetSelIndex();
  data->incomeRange = incomeRange->GetSelIndex();
  TDialog::CleanupWindow();}or,bool UserDataDialog::CanClose()
{  data->gender = gender->GetSelIndex();
  data->ageRange = ageRange->GetSelIndex();
  data->incomeRange = incomeRange->GetSelIndex();
  return TDialog::CanClose();
}


0
 

Author Comment

by:gurumike
ID: 1396953
Excellent.  I used CleanupWindow() and it worked perfectly.  All of my questions have been answered - thank you for your time and your help!!

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a log table of all deleted records Sql Server 2008? 5 80
Example of WebAPI 7 36
Explain Unit of Work pattern 2 84
Licensing Sharepoint 2016 for developers 11 90
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…

740 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