⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_62575.htm

📁 vc
💻 HTM
字号:
<p>
序号:62575 发表者:最后一根稻草 发表日期:2003-11-27 15:11:25
<br>主题:如何给对话框中的按钮更改颜色,更改字体
<br>内容:我设一个CButton型的变量,但好像这样不行啊,没有相关的函数
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:BigJames 回复日期:2003-11-27 16:31:23
<br>内容:更改颜色, 需要继承CButton,在子类里重载OnCtlColor<BR>改变字体,调CWnd::SetFont()
<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-11-27 16:58:47
<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>回复者:BigJames 回复日期:2003-11-27 17:07:00
<br>内容:时间都不多阿,我也没有美国时间。:)<BR>给你一个例子,从msdn上拷下来的。他是在CDialog的OnCtlColor里改变一个控件的颜色。你把控见id改一下就行了。<BR><BR>HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <BR>{<BR>&nbsp;&nbsp; // Call the base class implementation first! Otherwise, it may<BR>&nbsp;&nbsp; // undo what we're trying to accomplish here.<BR>&nbsp;&nbsp; HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<BR><BR>&nbsp;&nbsp; // Are we painting the IDC_MYSTATIC control? We can use<BR>&nbsp;&nbsp; // CWnd::GetDlgCtrlID() to perform the most efficient test.<BR>&nbsp;&nbsp; if (pWnd-&gt;GetDlgCtrlID() == IDC_MYSTATIC)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Set the text color to red<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;SetTextColor(RGB(255, 0, 0));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Set the background mode for text to transparent <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// so background will show thru.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pDC-&gt;SetBkMode(TRANSPARENT);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Return handle to our CBrush object<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hbr = m_brush;<BR>&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp; 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>
回复者:BigJames 回复日期:2003-11-27 17:08:39
<br>内容:至于SetFont,<BR>假设CFont* pFont = CreatFont(..);<BR><BR>GetDlgItem(IDC_BUTTON)-&gt;SetFont(pFont)。<BR><BR>Font我搞得不多。:)<BR>2003-11-27 17:09:09

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -