Problem with ComboBox in version 2.8.0 Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

Post by tigdra83 »

Hello again,

yes the entries are directly sorted after insertion. The output of the last line is "d".

wxString s[] = {
_("d"),
_("c"),
_("b"),
_("a")
};
wxComboBox* itemComboBox32 = new wxComboBox( this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, s, ~(wxCB_SORT)&(wxCB_DROPDOWN) );
itemComboBox32->SetStringSelection(_("a"));
cout << itemComboBox32->GetString(3) << endl;
manianis
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Jan 15, 2007 11:00 am

Post by manianis »

Try using the default constructor :

Code: Select all

wxString s[] = {
_("d"),
_("c"),
_("b"),
_("a")
};

wxComboBox* itemComboBox32 = new wxComboBox;
itemComboBox32->Create(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, s, wxCB_DROPDOWN);

itemComboBox32->SetStringSelection(_("a"));

cout << itemComboBox32->GetString(3) << endl;
This code works fine under Windows and the code you submitted too. The problem is not in this instructions it's somewhere else.
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

Post by tigdra83 »

First at all, thanks for your interest and help...

The default-constructor changes nothing on the behaviour. I agree that there must be somewhere else the problem, but where? Due to the 4 simple lines (where I think there is no mistake), the problem could appear because of
1. the linux distribution
2. or the wxWidgets configuration.

But then the question is, why is the Combo-Example running fine?

I've no idea :evil:
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

Last idea, have you tried appending them AFTER the combobox is created? Maybe that changes something.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

Post by tigdra83 »

I think you meant something like that, but anyway the last entry is "d" too...

wxComboBox* itemComboBox32 = new wxComboBox(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 0, NULL, wxCB_DROPDOWN );
wxArrayString as;
as.Alloc(4);
as.Add(_("d"),1);
as.Add(_("c"),1);
as.Add(_("b"),1);
as.Add(_("a"),1);
itemComboBox32->Append(as);
cout << itemComboBox32->GetString(3) << endl;
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

What if you append them without the arraystring, every item individually?

Code: Select all

itemComboBox32->Append(_("d")); 
itemComboBox32->Append(_("c")); 
itemComboBox32->Append(_("b")); 
itemComboBox32->Append(_("a")); 
??

Maybe the way wxArrayString Append is implemented, triggers a sort.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

Post by tigdra83 »

Always the same thing, the 2 outputs are "d"... Very strange thing...

itemComboBox32->Append(_("d"));
itemComboBox32->Append(_("c"));

cout << itemComboBox32->GetString(1) << endl;

itemComboBox32->Append(_("b"));
itemComboBox32->Append(_("a"));

cout << itemComboBox32->GetString(3) << endl;
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

And you are sure the minimal sample or combobox sample is not displaying this same behaviour?

What if you place only the essential code (e.g. the creation of the combobox and the filling of it) in the minimal sample?

The only thing I can think of is that there is something goofy with the flags.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

Post by tigdra83 »

Okay, there's one difference to the Combo-Example: they only use other types of ComboBox, e.g. OwnerDrawnComboBox (but I get a Segmentation Fault by creating it, maybe due to the library).

That's what I've done, I took the minimal example and only add the creation of the comboBox, nothing else...
User avatar
ABX
Can't get richer than this
Can't get richer than this
Posts: 810
Joined: Mon Sep 06, 2004 1:43 pm
Location: Poznan, Poland
Contact:

Re: Problem with ComboBox in version 2.8.0

Post by ABX »

tigdra83 wrote:This entries are sorted, but the style is without the option wxCB_SORT.
There was bug due to missing paranthesis which broke all wxUniv based implementations of wxComboBox (wxX11, wxMGL etc.).
tigdra83 wrote:Any idea to get rid of this problem?
Following change makes wxComboBox work as expected (at least in my wxMSWUniv build).

http://cvs.wxwidgets.org/viewcvs.cgi/wx ... 56&r2=1.57

ABX
CVS Head, 2.8.X
wxMSW, wxWinCE, wxPalmOS, wxOS2, wxMGL, bakefile
gcc 3.2.3, bcc 5.51, dmc 8.48, ow 1.6, vc 7.1, evc 3/4, pods 1.2
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

strange

Post by tigdra83 »

Hello again (back from holidays :D ),

I've tested your idea (in a circuitous way to see if it works really) and get to sorted combo-boxes:

//=================================

wxString strings[] = {_("d"),_("b"),_("c"), _("a")};

wxBoxSizer* bs = new wxBoxSizer(wxHORIZONTAL);
myFrame->SetSizer(bs);

wxComboBox* cb = new wxComboBox(this, wxID_ANY, _("a"), wxDefaultPosition, wxSize(130, -1), 4, strings, wxCB_DROPDOWN);
cb->SetStringSelection(_("a"));

cout << "style_1: " << cb->GetWindowStyle() << endl;

wxComboBox* cb2 = new wxComboBox(this,wxID_ANY,_(""), wxDefaultPosition, wxSize(130, -1), 4, strings, wxCB_READONLY|(cb->GetWindowStyle()&wxCB_SORT?0:0));

cout << "style_2: " << cb2->GetWindowStyle() << endl;

bs->Add(cb, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
bs->Add(cb2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

//=================================

But I wonder because of the output, there are 2 different styles represented (but having no influence to the graphical representation...):
style_1: 33882144
style_2: 33882128
tigdra83
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Jan 04, 2007 9:20 am

Post by tigdra83 »

Problem solved with new version :D
Post Reply