Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 689
  • Last Modified:

Derive CHeaderCtrl

If I make my own CMyHeaderCtrl derived from CHeaderCtrl.  Do I have to do anything special using my normal clistctrl to make it call the cmyheaderctrl ??
0
cophi
Asked:
cophi
  • 2
1 Solution
 
mahesh1402Commented:
Add a member to the CListCtrl or the CListView derived class so that we can access the extended functionality.
e.g. Add a protected member like :

protected:
      CMyHeaderCtrl      m_headerctrl;

Sub-class the header control so that the DrawItem() function in CMyHeaderCtrl can get called. If you are using a CListView derived class, you can place the sub-classing code in OnInitialUpdate(). If you are using a CListCtrl derived class, then put the code in PreSubclassWindow(). In either case, make sure you call the base class version of the function before subclassing the header control.

void CMyListCtrl::PreSubclassWindow()
{
      CListCtrl::PreSubclassWindow();

      // Add initialization code
      m_headerctrl.SubclassWindow( ::GetDlgItem(m_hWnd,0) );
}

you may Derive class from CHeaderCtrl..and Override DrawItem() etc.

void CMyHeaderCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
..
}

Have a look at this sample code here :
http://www.codeguru.com/cpp/controls/listview/sorting/article.php/c977/
http://www.codeguru.com/cpp/controls/listview/usingimages/article.php/c1009/

-MAHESH
0
 
mahesh1402Commented:
so cophie have you tried that ..implement your header control ?

-MAHESH
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now