📄 subject_62681.htm
字号:
<p>
序号:62681 发表者:李强-01 发表日期:2003-11-28 09:40:22
<br>主题:如何设置static控件的字体与颜色
<br>内容:下面是设置字体的一段代码,我修改了字体高度(20改成了40)与粗度(400改成了800),结果却没有反应,不知为什么.另外再添加什么代码,可以设置颜色,烦请高手增加一些代码.<BR><BR>cfnt.CreateFont( 20, 0, //字体高度、宽度<BR> 0, 0, //文本倾斜度、字体倾斜度<BR> 400, //字体粗度<BR> 0, 0, 0, //非斜体字、无下划线、无删除线<BR> ANSI_CHARSET, //所用字符集为ANSI_CHARSET<BR> OUT_DEFAULT_PRECIS, //删除精度为默认值<BR> CLIP_DEFAULT_PRECIS, //裁剪精度为默认值<BR> DEFAULT_QUALITY, //输出质量为默认值<BR> DEFAULT_PITCH|FF_DONTCARE , //字间距与字体系列为默认值<BR> _T("隶书")); //字体名称<BR><BR>m_stat1.SetFont(&cfnt);<BR><BR><BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:zzjhsj 回复日期:2003-11-28 10:12:24
<br>内容:cfnt需要在m_stat1整个生存期有效,如果SetFont后Font被delete了,嘿嘿,就不会有反应了<BR>颜色?处理 WM_CTLCOLORSTATIC
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:kobo 回复日期:2003-11-28 10:17:00
<br>内容:内容:在对话框中处理WM_CTLCOLOR消息<BR><BR>给你看看MSDN中的例子吧:<BR>// This OnCtlColor handler will change the color of a static control<BR>// with the ID of IDC_MYSTATIC. The code assumes that the CMyDialog<BR>// class has an initialized and created CBrush member named m_brush.<BR>// The control will be painted with red text and a background<BR>// color of m_brush.<BR><BR>HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <BR>{<BR> // Call the base class implementation first! Otherwise, it may<BR> // undo what we're trying to accomplish here.<BR> HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<BR><BR> // Are we painting the IDC_MYSTATIC control? We can use<BR> // CWnd::GetDlgCtrlID() to perform the most efficient test.<BR> if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)<BR> {<BR> // Set the text color to red<BR> pDC->SetTextColor(RGB(255, 0, 0));<BR><BR> // Set the background mode for text to transparent <BR> // so background will show thru.<BR> pDC->SetBkMode(TRANSPARENT);<BR><BR> // Return handle to our CBrush object<BR> hbr = m_brush;<BR> }<BR><BR> return hbr;<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:hurtmanzc 回复日期:2003-11-28 10:33:02
<br>内容:给你个例子,参考一下:
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:tiger_bai 回复日期:2003-11-28 11:56:16
<br>内容:看看这<BR>http://www.vccode.com/file_show.php?id=137
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:李强-01 回复日期:2003-11-29 18:28:51
<br>内容:请楼上的hurtmanzc老兄告诉我怎么生成的CStatic派生类CXColorStatic控件,多谢了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-12-01 10:56:46
<br>内容:不用生成控件呀,你在对话框上拖一个Static Text,给它添加变量的时候基类为CXColorStatic,然后在CXColorStatic的构造函数中加一些对颜色等的初始化设置,就OK了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -