Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wxListCrl errornously creates first column with left alignment on windows

5 views
Skip to first unread message

Thomas Zehbe

unread,
May 13, 2008, 2:35:00 AM5/13/08
to
Hi,

This is the code wich adds two cols to a list control:
mList->InsertColumn(0, _T("col1"), wxLIST_FORMAT_RIGHT, 100);
mList->InsertColumn(1, _T("col2"), wxLIST_FORMAT_RIGHT, 100);
Using 2.8.7 on linux everything works, but using the same on windows, I get
the first column left aligned.

This seems to be a bug, or do I do something wrong?

Regards,
Thomas

--
Dipl.-Ing. Thomas Zehbe
Kuhweide 6
31552 Apelern

Vadim Zeitlin

unread,
May 13, 2008, 12:37:42 PM5/13/08
to
On Tue, 13 May 2008 08:35:00 +0200 Thomas Zehbe <t...@thomas-zehbe.de> wrote:

TZ> This is the code wich adds two cols to a list control:
TZ> mList->InsertColumn(0, _T("col1"), wxLIST_FORMAT_RIGHT, 100);
TZ> mList->InsertColumn(1, _T("col2"), wxLIST_FORMAT_RIGHT, 100);
TZ> Using 2.8.7 on linux everything works, but using the same on windows, I get
TZ> the first column left aligned.

Is this problem reproducible in the listctrl sample?
VZ

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

Robin Dunn

unread,
May 13, 2008, 1:50:40 PM5/13/08
to
Thomas Zehbe wrote:

> Am Dienstag, 13. Mai 2008 schrieb Vadim Zeitlin:
>> On Tue, 13 May 2008 08:35:00 +0200 Thomas Zehbe <t...@thomas-zehbe.de> wrote:
>>
>> TZ> This is the code wich adds two cols to a list control:
>> TZ> mList->InsertColumn(0, _T("col1"), wxLIST_FORMAT_RIGHT, 100);
>> TZ> mList->InsertColumn(1, _T("col2"), wxLIST_FORMAT_RIGHT, 100);
>> TZ> Using 2.8.7 on linux everything works, but using the same on windows, I
>> get TZ> the first column left aligned.
>>
>> Is this problem reproducible in the listctrl sample?
>> VZ
>
> Yup, it is. I changed line 468 like this:
> //m_listCtrl->InsertColumn(0, itemCol);
> m_listCtrl->InsertColumn(0, _T("Col1"), wxLIST_FORMAT_RIGHT, 200);
> commented out the autosize option for column 0 and got the output attached as
> a jpg. (All done with 2.8.7, on win2k with VC6 in unicode debug build)

This has always been this way, and I expect that it is a "feature" of
the MS ListView control that it won't change alignment of the first
column. I would love to be proven wrong however.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Vadim Zeitlin

unread,
May 13, 2008, 2:02:16 PM5/13/08
to
On Tue, 13 May 2008 10:50:40 -0700 Robin Dunn <ro...@alldunn.com> wrote:

RD> Thomas Zehbe wrote:
RD> > Am Dienstag, 13. Mai 2008 schrieb Vadim Zeitlin:
RD> >> On Tue, 13 May 2008 08:35:00 +0200 Thomas Zehbe <t...@thomas-zehbe.de> wrote:
RD> >>
RD> >> TZ> This is the code wich adds two cols to a list control:
RD> >> TZ> mList->InsertColumn(0, _T("col1"), wxLIST_FORMAT_RIGHT, 100);
RD> >> TZ> mList->InsertColumn(1, _T("col2"), wxLIST_FORMAT_RIGHT, 100);
RD> >> TZ> Using 2.8.7 on linux everything works, but using the same on windows, I
RD> >> get TZ> the first column left aligned.
RD> >>
RD> >> Is this problem reproducible in the listctrl sample?
RD> >> VZ
RD> >
RD> > Yup, it is. I changed line 468 like this:
RD> > //m_listCtrl->InsertColumn(0, itemCol);
RD> > m_listCtrl->InsertColumn(0, _T("Col1"), wxLIST_FORMAT_RIGHT, 200);
RD> > commented out the autosize option for column 0 and got the output attached as
RD> > a jpg. (All done with 2.8.7, on win2k with VC6 in unicode debug build)
RD>
RD> This has always been this way, and I expect that it is a "feature" of
RD> the MS ListView control that it won't change alignment of the first
RD> column. I would love to be proven wrong however.

No, you're unfortunately right, I remember it myself too now: the list
control handles the first column specially. In fact my curiosity even
pushed me to look at the disassemble of the list view column insertion
function and it only uses LV_COLUMN::fmt" field if column index is > 0.

Workarounds for this exist though: you can create the first column of 0
width (and disallow resizing this), and use column 1 as the "real" first
column. You can also use SetColumnsOrder() to exchange the column index
with that of another, left-aligned, column: the first "logical" column is
left-aligned, not the first physically leftmost one.

Maybe we should put the first workaround in place automatically if
non-left alignment is specified for the column 0 (the other one would be
too difficult to do automatically) in wx...

Regards,

Thomas Zehbe

unread,
May 14, 2008, 2:01:12 AM5/14/08
to

Thx for the hints :). "Disposing" the first column immediately came in my mind
when i read Robin's comment. As I only need 2 right aligned cols, i'll do
that.

Thanks again and Regards,

0 new messages