Standalone C(Derived)HeaderCtrl in a CDialog
Posted on 2003-10-21
The MFC Documentation isn't entirely clear on how to work with HeaderCtrls that aren't embedded in List controls. How do I create one? I'm having difficulty. In the resource editor, I drew a CButton control and edited the .h and .cpp files to change references of CButton to CMyHeaderCtrl. Then I added this code: Seems to be a problem (?) in the Create function because it blanks out everything else in my dialog and causes funny paint problems.
headerRect.left = headerRect.top = 0; // -1 ?
headerRect.right = 10;
headerRect.bottom = 10;
m_header.Create(WS_BORDER |WS_CHILD | WS_VISIBLE | HDS_BUTTONS | HDS_HORZ, headerRect, this, IDC_TREE_HEADER);
// my button was called IDC_TREE_HEADER
hdl.prc = &wndRect;
hdl.pwpos = ℘
hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;
hdi.pszText = "Hello";
hdi.fmt = HDF_LEFT;
hdi.cxy = 10;