CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2017
    Posts
    23

    [RESOLVED] Image on listview column header instead of text

    Hello.
    I'm creating a program, and I occured a problem.
    At my progress I'm trying to create ListView control using Visual C++ in Visual Studio 2017 and acquire a result similar to this:

    Name:  48faa3a16b8f4bdb94f95a60cb4ec22f.jpg
Views: 263
Size:  6.9 KB

    How could I insert bmp image at the column header using visual C++?
    I was trying to use ImageList, but it doesn't work or maybe i did something wrong.

    Could you please help me at this thing?
    Greetings, Genotypek.

  2. #2
    Join Date
    Apr 2017
    Posts
    23

    Re: Image on listview column header instead of text

    I want to notice, that this screenshot is taken also project of my program, but it's writed in AutoIT3 language.
    (I don't really know how to edit my previous post, could you tell me how to do it? Am I stupid or something?)

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

    Re: Image on listview column header instead of text

    Quote Originally Posted by Genotypek View Post
    I want to notice, that this screenshot is taken also project of my program, but it's writed in AutoIT3 language.
    (I don't really know how to edit my previous post, could you tell me how to do it? Am I stupid or something?)
    No. Editing of posts is only allowed after several posts have been made.
    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++23 Compiler: Microsoft VS2022 (17.6.5)

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

    Re: Image on listview column header instead of text

    Quote Originally Posted by Genotypek
    How could I insert bmp image at the column header using visual C++?
    I was trying to use ImageList, but it doesn't work or maybe i did something wrong.
    You may want to show your code so we could better see/understand what and why you did wrong.
    Victor Nijegorodov

  5. #5
    Join Date
    Apr 2017
    Posts
    23

    Re: Image on listview column header instead of text

    I found a solution by myself.

    Code:
    this->GUI_ListView_Ruch = ( gcnew System::Windows::Forms::ListView() );
    			this->GUI_ListView_Ruch_Typ = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_Interwal = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_DataWyslania = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_DataDotarcia = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_ZWioski = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_XCelu = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_YCelu = ( gcnew System::Windows::Forms::ColumnHeader() );
    			this->GUI_ListView_Ruch_Piki = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_spear.jpg" ) );
    			this->GUI_ListView_Ruch_Miecze = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_sword.jpg" ) );
    			this->GUI_ListView_Ruch_Topory = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_axe.jpg" ) );
    			this->GUI_ListView_Ruch_Luki = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_archer.jpg" ) );
    			this->GUI_ListView_Ruch_Zwiadowcy = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_spy.jpg" ) );
    			this->GUI_ListView_Ruch_LK = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_light.jpg" ) );
    			this->GUI_ListView_Ruch_LNK = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_marcher.jpg" ) );
    			this->GUI_ListView_Ruch_CK = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_heavy.jpg" ) );
    			this->GUI_ListView_Ruch_Tarany = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_ram.jpg" ) );
    			this->GUI_ListView_Ruch_Katapulty = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_catapult.jpg" ) );
    			this->GUI_ListView_Ruch_Rycerz = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_knight.jpg" ) );
    			this->GUI_ListView_Ruch_Szlachcice = ( gcnew System::Windows::Forms::ColumnHeader( L"unit_snob.jpg" ) );
    And now I created ListView with jpgs in header.
    But anyway, thanks for help.
    Greetings, Genotypek.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Image on listview column header instead of text

    Congrats!
    However, the code you've posted has nothing to do with the native VC++. It looks like the manage one...
    Victor Nijegorodov

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Image on listview column header instead of text

    [moved from the Visual C++ forum]
    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
  •  





Click Here to Expand Forum to Full Width

Featured