1、改变控件中字体的大小及样式
CFont m_lFont;
void xx::changeListFontSize(void)
{
m_lFont.CreateFont(
25, //nHeight
0, //nWidth
0, //nEscapement
0, //nOrientation
//FW_NORMAL, //nWeight
FW_MEDIUM,
//FW_SEMIBOLD,
FALSE, //bItalic
FALSE, //bUnderline
0, //cStrikeOut
// ANSI_CHARSET,
DEFAULT_CHARSET, //nCharSet
OUT_DEFAULT_PRECIS, //nOutPrecision
CLIP_DEFAULT_PRECIS, //nClipPrecision
DEFAULT_QUALITY, //nQuality
DEFAULT_PITCH | FF_SWISS, //nPitchAndFamily
_T("隶书"));
GetDlgItem(IDC_LIST_MUSIC)->SetFont(&m_lFont);
GetDlgItem(IDC_STATIC_MUSIC)->SetFont(&m_lFont);
}
2、改变ListCtrl中表头字体的大小及样式
CFont m_hFont;
void xx::changePriceListHeadFontSize(void)
{
m_hFont.CreateFont(
18, //nHeight
0, //nWidth
0, //nEscapement
0, //nOrientation
FW_NORMAL, //nWeight
//FW_MEDIUM,
//FW_SEMIBOLD,
FALSE, //bItalic
FALSE, //bUnderline
0, //cStrikeOut
// ANSI_CHARSET,
DEFAULT_CHARSET, //nCharSet
OUT_DEFAULT_PRECIS, //nOutPrecision
CLIP_DEFAULT_PRECIS, //nClipPrecision
DEFAULT_QUALITY, //nQuality
DEFAULT_PITCH | FF_SWISS, //nPitchAndFamily
_T("黑体"));
CHeaderCtrl* pHeaderCtrl = m_priceList.GetHeaderCtrl();
pHeaderCtrl->SetFont(&m_hFont);
}
3、改变窗体背景色、静态框、编辑框背景色,listctrl背景色
CBrush m_brush;
在初始化中:
GetParentFrame()->RecalcLayout();
m_brush.CreateSolidBrush(RGB(140,20,15));
重写OnCtlColor
HBRUSH xx::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (nCtlColor == CTLCOLOR_EDIT )
{
if (pWnd == GetDlgItem(IDC_EDT_TEXT) || pWnd == GetDlgItem(IDC_EDT_PRICE))
{
pDC->SetTextColor(RGB(255,255,255));
pDC->SetBkMode(TRANSPARENT); //背景设为透明
}
}
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(255,255,255));
HBRUSH hNullBr = (HBRUSH)::GetStockObject(NULL_BRUSH);
pDC->SetBkMode(TRANSPARENT); //背景设为透明
return hNullBr;
}
// TODO: Return a different brush if the default is not desired
return m_brush;
}