Solved

OWL TComboBox help

Posted on 1997-04-28
9
303 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
  • 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Launching Internet Explorer inPrivate mode using VBA 14 461
Having Trouble with MS Access 2010 CommandBars 19 98
Application vs Workbook.applicaiton 3 35
Windows Installer 4 73
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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