Derive CHeaderCtrl

Posted on 2006-05-12
Last Modified: 2013-11-20
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 ??
Question by:cophi
    LVL 22

    Accepted Solution

    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 :

          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()

          // 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 :

    LVL 22

    Expert Comment

    so cophie have you tried that ..implement your header control ?


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Whole sheet autoscrub still needed 19 41
    java ^ examples 8 48
    EvenOdd challenge 10 68
    Fibonacci challenge 11 61
    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now