Solved

OWL TComboBox help

Posted on 1997-04-28
9
301 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
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396948
You can write me directly to nick@rtzi.ru
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL to ElasticSearch Query 1 575
Problem to adjust sheet 1 85
Access 2013: API code to put hidden database icon in taskbar? 8 68
Trouble with References... 5 42
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now