May 2, 2001 #1 Robertus Programmer Joined Feb 16, 2001 Messages 81 Location RO How could I change the color of a header ctrl in a listControl?
May 11, 2001 #2 MSamoila Programmer Joined Feb 9, 2001 Messages 14 Location CA I assume you use MFC. Derive a class from CWnd which processes WM_ERASEBKGND message: Code: class CHdrWnd : public CWnd { public: protected: afx_msg BOOL OnEraseBkgnd( CDC* pDC ); DECLARE_MESSAGE_MAP() } BOOL CHdrWnd::OnEraseBkgnd( CDC* pDC ) { pDC->FillSolidRect(RGB(255, 0, 0));//your color return TRUE; } In the class asociated with parent window of list view declare a data member of type CHdrWnd: Code: CHdrWnd m_wndHdr; Now in your WM_INITDIALOG or WM_CREATE message handler of the parent window of list view do the subclassing of the header: Code: .... HWND hWndHeader = (HWND)SendDlgItemMessage(IDC_LISTVIEW, LVM_GETHEADER, 0, 0); m_wndHdr.SubclassWindow(hWndHeader); Marius Samoila Brainbench MVP for Visual C++ http://www.brainbench.com Upvote 0 Downvote
I assume you use MFC. Derive a class from CWnd which processes WM_ERASEBKGND message: Code: class CHdrWnd : public CWnd { public: protected: afx_msg BOOL OnEraseBkgnd( CDC* pDC ); DECLARE_MESSAGE_MAP() } BOOL CHdrWnd::OnEraseBkgnd( CDC* pDC ) { pDC->FillSolidRect(RGB(255, 0, 0));//your color return TRUE; } In the class asociated with parent window of list view declare a data member of type CHdrWnd: Code: CHdrWnd m_wndHdr; Now in your WM_INITDIALOG or WM_CREATE message handler of the parent window of list view do the subclassing of the header: Code: .... HWND hWndHeader = (HWND)SendDlgItemMessage(IDC_LISTVIEW, LVM_GETHEADER, 0, 0); m_wndHdr.SubclassWindow(hWndHeader); Marius Samoila Brainbench MVP for Visual C++ http://www.brainbench.com