基本控件属性设置1
<1> : 靜態(tài)文本框字體設(shè)置:
下面可以在oninitdialog中設(shè)置:
CFont cfont;//全局變量
cfont.CreateFont(68,??????? //這個數(shù)字就是字體大小了
?? 0,0,0,FW_BOLD,??
?? FALSE,FALSE,??
?? 0,??
?? ANSI_CHARSET,????????????? // nCharSet
?? OUT_DEFAULT_PRECIS,??????? // nOutPrecision
?? CLIP_DEFAULT_PRECIS,?????? // nClipPrecision
?? DEFAULT_QUALITY,?????????? // nQuality
?? DEFAULT_PITCH | FF_SWISS, "Arial");
?CWnd*? pWnd = GetDlgItem(IDC_PASSTEXT);//靜態(tài)文本框ID
?pWnd->SetFont(&cfont);
<2> : 靜態(tài)對話框字體顏色設(shè)置:添加響應(yīng)WM_CTLCOLOR消息,在消息映射函數(shù)中添加:
HBRUSH?C***Dlg::OnCtlColor(CDC*?pDC,?CWnd*?pWnd,?UINT?nCtlColor)
{
????HBRUSH?hbr?=?CDialog::OnCtlColor(pDC,?pWnd,?nCtlColor);
????//?TODO:??在此更改DC?的任何屬性
????//?TODO:??如果默認的不是所需畫筆,則返回另一個畫筆
????//?Determine?if?drawing?a?dialog?box?.?If?we?are?,?return?+handle?to
????//our?own?background?brush?.?Otherwise?let?windows?//handle?it?.
????
????switch(nCtlColor)
????{
????case?CTLCOLOR_STATIC:?//對所有靜態(tài)文本控件的設(shè)置
????????{
????????????//設(shè)置背景為透明
????????????pDC->SetBkMode(TRANSPARENT);?
????????????pDC->SetTextColor(RGB(0,0,0));?//設(shè)置字體顏色
pDC-> SetBkColor(RGB(0,255,0));//設(shè)置字體背景顏色????????????
break;
????????}
????case?CTLCOLOR_DLG:
????????{
???? //return?(HBRUSH)?m_brush?.GetSafeHandle();?
????????break;
????????}
????default:
????????break;
????}
????return?hbr;
}
?
?
?
?
?
?
?
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/MMLoveMeMM/articles/3089362.html
總結(jié)
- 上一篇: Page类的IsPostBack原理
- 下一篇: 排序-交换排序