📄 subject_51248.htm
字号:
<p>
序号:51248 发表者:Ollif 发表日期:2003-08-30 14:08:36
<br>主题:请问如何设置一个控件的前景和背景色?
<br>内容:比如控件的ID为IDC_STATIC,有没有这样的函数:<BR>GetCtrlDC(IDC_STATIC)<BR>多谢
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:iamhere 回复日期:2003-08-31 00:35:50
<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>ps:奇怪,怎么有那么多人问这个问题啊?<BR><BR>
<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 + -