If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Listview, center align subitem image

Hey all,

I'm testing around with the listview control with WinAPI using C++ and the use of it is quite
straightforward but there is one thing that I can't tackle up until now.

As the title indicates, the listview contains multiple columns and rows. This means I got multiple
subitems. I already gave the subitems an image in the form of an icon. The thing which is giving
me a hard time is the alignment of these icons.

By research I know that the first column is fixed to a left alignment and the rest is free to adapt.
I used the keyword "LVCFMT_BITMAP_ON_RIGHT" when setting the format for each column and
this only effects the icons in the column header but not the subitems of that column.

So to put it simple, why does the header alignment only gets effected by this as you would expect that all of the content gets set to this property.

Re: Listview, center align subitem image

I'm testing around with the listview control with WinAPI using C++ and the use of it is quite
straightforward but there is one thing that I can't tackle up until now.

As the title indicates, the listview contains multiple columns and rows. This means I got multiple
subitems. I already gave the subitems an image in the form of an icon. The thing which is giving
me a hard time is the alignment of these icons.

By research I know that the first column is fixed to a left alignment and the rest is free to adapt.
I used the keyword "LVCFMT_BITMAP_ON_RIGHT" when setting the format for each column and
this only effects the icons in the column header but not the subitems of that column.

So to put it simple, why does the header alignment only gets effected by this as you would expect that all of the content gets set to this property.

Btw, I'm developing on a Windows XP atm using visual studio 2008.

P.s.: I attached a sample project which I use for quick testing.

Thanks in progress

Forcecast

Hey, i have the same problem.

I tried to use ListView_SetItemPosition, but it's just no way working

If you have to deal with text-items it's no problem.. you can just set LCFMT_CENTER fpr the column.

Re: Listview, center align subitem image

AFAIK, the only way round this is to use an owner-drawn control.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.