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. Customize filter control of CHeaderCtrl

Customize filter control of CHeaderCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
7 Posts 2 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.
  • A Offline
    A Offline
    aks
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • A 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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The CEdit class inherits from CWnd so you can use SetFont 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.

      A 1 Reply Last reply
      0
      • L Lost User

        The CEdit class inherits from CWnd so you can use SetFont 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.

        A Offline
        A Offline
        aks
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • A aks

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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?

          A 1 Reply Last reply
          0
          • L Lost User

            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?

            A Offline
            A Offline
            aks
            wrote on last edited by
            #5

            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

            L 1 Reply Last reply
            0
            • A aks

              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

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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.

              A 1 Reply Last reply
              0
              • L Lost User

                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.

                A Offline
                A Offline
                aks
                wrote on last edited by
                #7

                I could only find it by using FindWondow API in class derived from CHeaderCtrl. Ans I customized the edit control from OnCustomDraw().

                aks

                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