Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 7th, 2006, 05:15 AM
Friend of Wrox
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default help coloring individual listview item instead al

help coloring individual listview item instead of all listview item in visual c++

Hi all. i am using this code to change color of listview item.
 But unfortunetly it goes and changes color of all item instead
 of only changing the color selected listview item. Could an expert
 look at this and show me how i can only change color of selected
listview item instead of coloring all items in listview.Thanks


void CColor1Dlg::OnButton1() 


HWND hPalWnd = ::FindWindow("my window class", NULL);

        HWND spilterwindow = FindWindowEx(hPalWnd, 0, "WTL_SplitterWindow", 0);

        spilterwindow = FindWindowEx(spilterwindow, 0, "WTL_SplitterWindow", 0);

        HWND ATL = FindWindowEx(spilterwindow, 0, "WTL_SplitterWindow", 0);

        HWND ATLWIN = FindWindowEx(ATL, 0, "atl:0053c8d0", 0);

        HWND Dialog = FindWindowEx(ATLWIN, 0, "SysListView32", 0);

        HWND Rich = FindWindowEx(Dialog, 0, "SysHeader32", 0);


            CButton *pButton1 = (CButton*)GetDlgItem(IDC_BUTTON1);

            COLORREF GetBkColor(IDC_BUTTON1);

            //COLORREF color = m_color.GetColor();

COLORREF color = 33023;

            TRACE("Color of the selected font = %8x\n", color);

            //CButton *pButton = (CButton*)GetDlgItem(IDC_BUTTON2);


        ::SendMessage(Dialog, LVM_SETTEXTCOLOR, 0, color);


Old August 1st, 2006, 08:25 AM
Authorized User
Join Date: Jun 2003
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts


You need to use a callback function i think (long time since I did this myself). Try to find some useful tips at Codeproject.com



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get selected item from listview? try.test.abc C# 1 January 4th, 2007 02:34 AM
problem selecting listview item method Visual C++ 0 July 7th, 2006 04:06 PM
how to select an item from listview jthadathilm16 VB How-To 1 April 24th, 2006 11:33 AM
coloring datagrid preethi_04 .NET Framework 1.x 1 December 22nd, 2005 01:11 AM
Selecting a ListView item bmains Pro VB.NET 2002/2003 0 January 22nd, 2005 11:19 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.