Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CHeaderCtrl

Status
Not open for further replies.

Robertus

Programmer
Feb 16, 2001
81
RO
How could I change the color of a header ctrl in a listControl?
 
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++
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top