sternocera
asked on
MFC: What CListCtrl function displays a windows explorer style header button?
I want to display a ClistView's column header, in the style of windows explorer. I've obtained a pointer to the CListCtrl's corresponding CHeaderCtrl:
CListCtrl& theCtrl = GetListCtrl();
theCtrl.SetExtendedStyle(L VS_REPORT) ;
CHeaderCtrl* HeaderCtrl = theCtrl.GetHeaderCtrl();
I understand that some member function of CListCtrl displays the column header, but I don't know which one.
Please advise,
Regards,
Sternocera
CListCtrl& theCtrl = GetListCtrl();
theCtrl.SetExtendedStyle(L
CHeaderCtrl* HeaderCtrl = theCtrl.GetHeaderCtrl();
I understand that some member function of CListCtrl displays the column header, but I don't know which one.
Please advise,
Regards,
Sternocera
ASKER
Mahesh,
I've downloaded this very tutorial already. It says "The fact that the CHeaderCtrl's visibility is managed by the CListCtrl will become important later when we address message handling."
This is how I learned that CHeaderCtrl's visibility is managed by a CListCtrl member function. How do I actually display the CHeaderCtrl?,
Regards,
Sternocera
I've downloaded this very tutorial already. It says "The fact that the CHeaderCtrl's visibility is managed by the CListCtrl will become important later when we address message handling."
This is how I learned that CHeaderCtrl's visibility is managed by a CListCtrl member function. How do I actually display the CHeaderCtrl?,
Regards,
Sternocera
>>How do I actually display the CHeaderCtrl?,
I am not getting you...When the list view control is in the report style it usually displays a header control to label the columns. This header control is a embedded child window of the list view control ... you can get pointer to that one as u did above
-MAHESH
I am not getting you...When the list view control is in the report style it usually displays a header control to label the columns. This header control is a embedded child window of the list view control ... you can get pointer to that one as u did above
-MAHESH
and that will not appear unless you create columns !
ASKER
I have created columns.
ASKER
Mahesh,
Here is the OnInitialUpdate() function:
void CMyListView::OnInitialUpda te()
{
CListView::OnInitialUpdate ();
// Gain a reference to the list control itself
CListCtrl& theCtrl = GetListCtrl();
theCtrl.SetExtendedStyle(L VS_REPORT) ;
CHeaderCtrl* HeaderCtrl = theCtrl.GetHeaderCtrl();
// Insert a column. This override is the most convenient.
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);
theCtrl.InsertColumn(0, _T("Player team"), LVCFMT_LEFT);
theCtrl.InsertItem(0, "an entry");
theCtrl.InsertItem(1, "another entry");
// Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
}
I set the style to LVS_REPORT through SetExtendedStyle, yet I can't see any column headers.
Why do you think that is?
Thanks
Here is the OnInitialUpdate() function:
void CMyListView::OnInitialUpda
{
CListView::OnInitialUpdate
// Gain a reference to the list control itself
CListCtrl& theCtrl = GetListCtrl();
theCtrl.SetExtendedStyle(L
CHeaderCtrl* HeaderCtrl = theCtrl.GetHeaderCtrl();
// Insert a column. This override is the most convenient.
theCtrl.InsertColumn(0, _T("Player Name"), LVCFMT_LEFT);
theCtrl.InsertColumn(0, _T("Player team"), LVCFMT_LEFT);
theCtrl.InsertItem(0, "an entry");
theCtrl.InsertItem(1, "another entry");
// Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
theCtrl.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
}
I set the style to LVS_REPORT through SetExtendedStyle, yet I can't see any column headers.
Why do you think that is?
Thanks
what if u try with using LVCOLUMN struct like :
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Player Name");
col.fmt = LVCFMT_LEFT;
theCtrl.InsertColumn(1, &col);
-MAHESH
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Player Name");
col.fmt = LVCFMT_LEFT;
theCtrl.InsertColumn(1, &col);
-MAHESH
ASKER
Nothing happens...
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works! Thanks again, Mahesh.
Thats cause LVS_REPORT is not extended style..setting normally or using ModifyStyle should work.
-MAHESH
-MAHESH
ASKER
Right, thanks
See for more :
http://www.codeproject.com/listctrl/headerctrl.asp
-MAHESH