CodePudding user response:
Change the font sizeCodePudding user response:
Set up the icon, hold upCodePudding user response:
The MFC header background how to set up, please?CodePudding user response:
# define BACK_COLOR RGB (255128255)
Void CMyListCtrl: : OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT LPDRAWITEMSTRUCT)
{
//TODO: Add your message handler code here and/or call the default
CHeaderCtrl * pHead=GetHeaderCtrl ();
CRect rc;
PHead - & gt; GetItemRect (lpDrawItemStruct - & gt; ItemID, & amp; Rc);
HBRUSH br=CreateSolidBrush (BACK_COLOR);
: : FillRect (lpDrawItemStruct - & gt; HDC, & amp; Rc, br);
DeleteObject (br);
Char * pTxt=(char *) lpDrawItemStruct - & gt; ItemData.
Int len=strlen (pTxt);
SetBkMode (lpDrawItemStruct - & gt; HDC, TRANSPARENT);
HDITEM HDITEM;
ZeroMemory (& amp; HdItem, sizeof (hdItem));
HdItem. Mask=HDI_FORMAT | HDI_WIDTH;
PHead - & gt; The GetItem (lpDrawItemStruct - & gt; ItemID, & amp; HdItem);
If (hdItem. FMT & amp; HDF_CENTER)
{
CSize sz.//=(CDC: : FromHandle (lpDrawItemStruct - & gt; HDC)) - & gt; GetTextExtent (pTxt, len);
: : GetTextExtentPoint32 (lpDrawItemStruct - & gt; HDC, pTxt, len, & amp; Sz);
Rc. Left +=(rc) Width () - sz. Cx)/2;
}
: : TextOut (lpDrawItemStruct - & gt; HDC, rc. Left, rc. Top + 2, pTxt, len);
//CListCtrl: : OnDrawItem (nIDCtl, lpDrawItemStruct);
}
CodePudding user response:
Header is overloaded, he is an independent control HeadCtrlCodePudding user response:
Pay attention to the head to modify
M_List. InsertColumn (0, "serial number", LVCFMT_LEFT, 60).
M_List. InsertColumn (1, "name", LVCFMT_LEFT, 300);
M_List. InsertColumn (2, "weight", LVCFMT_LEFT, 300);
//Modify the name of the Item 1
HDITEM HDITEM;
ZeroMemory (& amp; HdItem, sizeof (hdItem));
HdItem. Mask=HDI_FORMAT | HDI_LPARAM;
HdItem. FMT=HDF_CENTER | HDF_OWNERDRAW;
HdItem. LParam=(long) "name";
CHeaderCtrl. * pHead=m_List GetHeaderCtrl ();
PHead - & gt; SetItem (1, & amp; HdItem);