Subclassing CHeaderCtrl in CListCtrl
-
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 ...
-
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 ...
For a dialog it could be performed as following :) :
BOOL CYourDialog::OnInitDialog()
{
BOOL bResult = CDialog::OnInitDialog();// CListCtrlEx m_cListCtrl
// CHeaderCtrlEx m_cHeaderCHeaderCtrl* 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. :)
-
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 ...
You don't have to subclass the CHeaderCtrl to show and hide columns: CListCtrl Which Can Show and Hide Columns[^]
-
For a dialog it could be performed as following :) :
BOOL CYourDialog::OnInitDialog()
{
BOOL bResult = CDialog::OnInitDialog();// CListCtrlEx m_cListCtrl
// CHeaderCtrlEx m_cHeaderCHeaderCtrl* 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. :)
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;
} -
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;
}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. :)
-
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. :)
It goes with PreSubclassWindow() right after Create() ! Thanks for solution ! Thanks all of you !