dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Listview, center align subitem image

  1. #1
    Join Date
    Mar 2011
    Posts
    0

    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.

    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
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2019
    Posts
    1

    Re: Listview, center align subitem image

    Quote Originally Posted by Forcecast View Post
    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.

    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.

    But when it comes to image-items.. no way.

    Do anyone have a solution for this?

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,728

    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!

    C++17 Compiler: Microsoft VS2019 (16.1.6)

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,401

    Re: Listview, center align subitem image

    Quote Originally Posted by Mahlzeit123 View Post
    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.

    But when it comes to image-items.. no way.

    Do anyone have a solution for this?
    You may want to look at https://www.codeproject.com/Articles...l-with-subitem
    and some other articles here.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)