wxListBox SetBackground problem

20 views
Skip to first unread message

evstevemd

unread,
Oct 1, 2010, 2:25:19 AM10/1/10
to wx-users
Hi buddies,
I'm facing some issues with wxListBox::SetBackgroundColour problem.
I get something weird like this:

http://wxforum.shadonet.com/attachments/lb_error_954.png

//Add some data here (wxArrayString --myPages )
wxListBox* lb = new wxListBox(this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, myPages, wxBORDER_NONE|wxALIGN_CENTER);
lb->SetBackgroundColour(wxT("gold"));

I don't know where I'm doing wrong.
Any correction/suggestion is appreciated.
thanks

Vadim Zeitlin

unread,
Oct 1, 2010, 8:17:48 AM10/1/10
to wx-u...@googlegroups.com
On Thu, 30 Sep 2010 23:25:19 -0700 (PDT) evstevemd <mwinj...@gmail.com> wrote:

e> I'm facing some issues with wxListBox::SetBackgroundColour problem.

Under which platform and wx version? What about reproducibility in the
widgets sample (with "Set background" on the "Listbox" page)?

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

evstevemd

unread,
Oct 3, 2010, 1:46:47 AM10/3/10
to wx-users
Sorry for late reply,
I use CodeLite bundled wxWidgets so I have to download samples and
compile.
Info:
wxWidgets 2.8.10 (Comes bundled with CL)
OS: WinXP SP3

I will try samples, first let me download and compile them


On Oct 1, 3:17 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> On Thu, 30 Sep 2010 23:25:19 -0700 (PDT) evstevemd <mwinjili...@gmail.com> wrote:
>
> e> I'm facing some issues with wxListBox::SetBackgroundColour problem.
>
>  Under which platform and wx version? What about reproducibility in the
> widgets sample (with "Set background" on the "Listbox" page)?
>
>  Regards,
> VZ
>
> --
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>
>  application_pgp-signature_part
> < 1KViewDownload

evstevemd

unread,
Oct 3, 2010, 3:11:08 AM10/3/10
to wx-users
Here is a little funny thing and I think I mess up somewhere haven't
yet realized.
When I insert wxArrayString directly on constructor, the scenario
happens.
However, If I call Set(wxArrayString) it acts normal.

Here is modified wxSample Constructor to produce the weird results. I
will stick with Set() but I want to know where I'm doing wrong

Thanks

<CODE>
wxString test[] =
{wxT("1"),wxT("2"),wxT("3"),wxT("4"),wxT("5"),wxT("6"),wxT("7")};
wxArrayString bookPages = wxArrayString(7, test);

m_lbox = new wxListBox(m_panel,
wxID_ANY, wxDefaultPosition,
wxDefaultSize,
bookPages,
wxBORDER_NONE|wxALIGN_CENTER);

</CODE>

evstevemd

unread,
Oct 3, 2010, 3:20:02 AM10/3/10
to wx-users
Further isolation shows that something is wrong with wxALIGN_CENTER
style
How can I arrange then wxLB items in center? When I apply the style,
they get centered but again the behavior above creeps in.
I'm confused

Vadim Zeitlin

unread,
Oct 3, 2010, 9:54:33 AM10/3/10
to wx-u...@googlegroups.com
On Sun, 3 Oct 2010 00:20:02 -0700 (PDT) evstevemd <mwinj...@gmail.com> wrote:

e> Further isolation shows that something is wrong with wxALIGN_CENTER
e> style

This style is not supported by wxListBox. Actually when you use it, you
specify wxLB_OWNERDRAW | wxLB_INT_HEIGHT and I guess the former is what
creates the problem (it's for internal use by wxCheckListBox only and
shouldn't be used in the code).

e> How can I arrange then wxLB items in center?

You'll need to use a different control for this (wxListCtrl,
wxHtmlListBox, ...).

evstevemd

unread,
Oct 4, 2010, 7:26:35 AM10/4/10
to wx-users
Thanks Vadim,
I guess I will have to live without it.
Thanks a lot

On Oct 3, 4:54 pm, Vadim Zeitlin <va...@wxwidgets.org> wrote:
>  application_pgp-signature_part
> < 1KViewDownload
Reply all
Reply to author
Forward
0 new messages