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

This is a discussion on help coloring individual listview item instead of all listview item in visual c++ 6 within the Windows Programming forums, part of the Platform Specific Boards category; Hi all. i am using this code to change color of listview item. But unfortunetly it goes and changes color ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    4

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

    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

    Code:
     
    
    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);
    
                //pButton->SetWindowText("Shoot");
    
            ::SendMessage(Dialog, LVM_SETTEXTCOLOR, 0, color);
    
     
    
    }

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    The ProcessCustomDraw function in this CodeProject article will probably help you out.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    4
    Quote Originally Posted by BobS0327
    The ProcessCustomDraw function in this CodeProject article will probably help you out.
    that is very stupid articel. The source code even does not work!!

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The article is a little old but provides you with more than enough information to solve your problem, including example code.

    Custom draw reference.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    The source code even does not work!!
    I just downloaded and compiled the code. It works fine for me. I made a simple mod to the ProcessCustomDraw function to accomplish your task of changing the color of a particular selected listview item.

    Maybe I'm just the exception to the rule.

  6. #6
    Registered User
    Join Date
    Jul 2006
    Posts
    4
    Quote Originally Posted by BobS0327
    I just downloaded and compiled the code. It works fine for me. I made a simple mod to the ProcessCustomDraw function to accomplish your task of changing the color of a particular selected listview item.

    Maybe I'm just the exception to the rule.
    i am running visual studio 6 so it will not compile that for me!! :-((

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Owner Draw is another option.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 07:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21