Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Subclassing CHeaderCtrl in CListCtrl

Subclassing CHeaderCtrl in CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
comquestioncode-review
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mesajflaviu
    wrote on last edited by
    #1

    How is the correct way to subclassing my CHeaderCtrl class into my CListCtrl ? Let say I have CListCtrlEx , ( public of CListCtrl ) , and I have a CHeaderCtrlEx class ( public of CHeaderCtrl ) and I need to subclassing into CListCtrlEx ... how it's correct way to do it ? I tell you for what I need subclassing : I want to improve my CListCtrlEx class to CHeaderCtrlEx class from here[^] and saw there , that CHeaderCtrlEx is subclassing into CListCtrlEx ...

    E R 2 Replies Last reply
    0
    • M mesajflaviu

      How is the correct way to subclassing my CHeaderCtrl class into my CListCtrl ? Let say I have CListCtrlEx , ( public of CListCtrl ) , and I have a CHeaderCtrlEx class ( public of CHeaderCtrl ) and I need to subclassing into CListCtrlEx ... how it's correct way to do it ? I tell you for what I need subclassing : I want to improve my CListCtrlEx class to CHeaderCtrlEx class from here[^] and saw there , that CHeaderCtrlEx is subclassing into CListCtrlEx ...

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      For a dialog it could be performed as following :) :

      BOOL CYourDialog::OnInitDialog()
      {
      BOOL bResult = CDialog::OnInitDialog();

      // CListCtrlEx m_cListCtrl
      // CHeaderCtrlEx m_cHeader

      CHeaderCtrl* pcOriginalHeader(m_cListCtrl.GetHeaderCtrl());
      if (pcOriginalHeader->GetSafeHwnd()) {
      m_cHeader.SubclassWindow(pcOriginalHeader->GetSafeHwnd());
      // use the extended header class now
      }

      return bResult;
      }

      They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

      M 1 Reply Last reply
      0
      • M mesajflaviu

        How is the correct way to subclassing my CHeaderCtrl class into my CListCtrl ? Let say I have CListCtrlEx , ( public of CListCtrl ) , and I have a CHeaderCtrlEx class ( public of CHeaderCtrl ) and I need to subclassing into CListCtrlEx ... how it's correct way to do it ? I tell you for what I need subclassing : I want to improve my CListCtrlEx class to CHeaderCtrlEx class from here[^] and saw there , that CHeaderCtrlEx is subclassing into CListCtrlEx ...

        R Offline
        R Offline
        Rolf Kristensen
        wrote on last edited by
        #3

        You don't have to subclass the CHeaderCtrl to show and hide columns: CListCtrl Which Can Show and Hide Columns[^]

        1 Reply Last reply
        0
        • E Eugen Podsypalnikov

          For a dialog it could be performed as following :) :

          BOOL CYourDialog::OnInitDialog()
          {
          BOOL bResult = CDialog::OnInitDialog();

          // CListCtrlEx m_cListCtrl
          // CHeaderCtrlEx m_cHeader

          CHeaderCtrl* pcOriginalHeader(m_cListCtrl.GetHeaderCtrl());
          if (pcOriginalHeader->GetSafeHwnd()) {
          m_cHeader.SubclassWindow(pcOriginalHeader->GetSafeHwnd());
          // use the extended header class now
          }

          return bResult;
          }

          They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

          M Offline
          M Offline
          mesajflaviu
          wrote on last edited by
          #4

          And what if I create the list control dinamicaly ( with Create ) ?

          int CTestList3View::OnCreate(LPCREATESTRUCT lpCreateStruct)
          {
          if(CListView::OnCreate(lpCreateStruct) == -1)return -1;

          // TODO: Add your specialized creation code here
          
          DWORD dwStyle = WS\_CHILD | WS\_VISIBLE | WS\_TABSTOP | LVS\_REPORT;
          
          BOOL bResult = m\_List1.Create(dwStyle,CRect(0,0,0,0),this,IDC\_LIST1);
          
          return (bResult ? 0 : -1);
          

          // return 0;
          }

          E 1 Reply Last reply
          0
          • M mesajflaviu

            And what if I create the list control dinamicaly ( with Create ) ?

            int CTestList3View::OnCreate(LPCREATESTRUCT lpCreateStruct)
            {
            if(CListView::OnCreate(lpCreateStruct) == -1)return -1;

            // TODO: Add your specialized creation code here
            
            DWORD dwStyle = WS\_CHILD | WS\_VISIBLE | WS\_TABSTOP | LVS\_REPORT;
            
            BOOL bResult = m\_List1.Create(dwStyle,CRect(0,0,0,0),this,IDC\_LIST1);
            
            return (bResult ? 0 : -1);
            

            // return 0;
            }

            E Offline
            E Offline
            Eugen Podsypalnikov
            wrote on last edited by
            #5

            Then - place the subclassing lines previos to the 'return' line... :)

            They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

            M 1 Reply Last reply
            0
            • E Eugen Podsypalnikov

              Then - place the subclassing lines previos to the 'return' line... :)

              They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

              M Offline
              M Offline
              mesajflaviu
              wrote on last edited by
              #6

              It goes with PreSubclassWindow() right after Create() ! Thanks for solution ! Thanks all of you !

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups