Customize filter control of CHeaderCtrl
-
I have a CListCtrl in my MFC dialog application. I enabled the HDS_FILTERBAR for List control the by the following code.
CHeaderCtrl* pHeaderCtrl = m_myListCtrl.GetHeaderCtrl();
pHeaderCtrl->SetDlgCtrlID( IDC_LIST1 );
HDITEM hdItem;
ZeroMemory( &hdItem, sizeof( HDITEM ));
hdItem.mask = ( HDI_FILTER );
pHeaderCtrl->ModifyStyle( 0, HDS_FILTERBAR );
hdItem.type = HDFT_ISSTRING;The filter is displayed. However I would like to change the background color and font of the Edit control and button in the filter section. How can I achieve it.
aks
-
I have a CListCtrl in my MFC dialog application. I enabled the HDS_FILTERBAR for List control the by the following code.
CHeaderCtrl* pHeaderCtrl = m_myListCtrl.GetHeaderCtrl();
pHeaderCtrl->SetDlgCtrlID( IDC_LIST1 );
HDITEM hdItem;
ZeroMemory( &hdItem, sizeof( HDITEM ));
hdItem.mask = ( HDI_FILTER );
pHeaderCtrl->ModifyStyle( 0, HDS_FILTERBAR );
hdItem.type = HDFT_ISSTRING;The filter is displayed. However I would like to change the background color and font of the Edit control and button in the filter section. How can I achieve it.
aks
The
CEdit
class inherits fromCWnd
so you can useSetFont
to change the font. You can probably set the background colour by subclassing the window. Changing the colour and image in a button can be done in similar ways. Google should find you some samples. -
The
CEdit
class inherits fromCWnd
so you can useSetFont
to change the font. You can probably set the background colour by subclassing the window. Changing the colour and image in a button can be done in similar ways. Google should find you some samples. -
Thank you for the comment. I tried by subclassing the Header control. But I could not find any options to get the edit control and button from the CHeaderCtrl.
aks
-
aks. wrote:
I could not find any options to get the edit control and button
So who put them in the header in the first place?
-
Ok. I got it, I used FindWindoEx to find the WC_EDIT in the header. I think the filter button is not exactly a button. Its a bitmap.
aks
-
I don't think that is the best way. You put the items in the header so you should be able to get their handles quite easily using the methods of the CHeaderCtl object.