[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

OWL TComboBox help

Posted on 1997-04-28
9
Medium Priority
?
315 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 400 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

650 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