有什么好办法,我不想用自绘,因为绘不出Button的外观,或者说很麻烦,我只想改变字体颜色而已。我试了用反射也不行,不知道我用对了没有,请哪位给点代码,谢谢!
解决方案 »
- 求vc的某些用法,很有难度的
- 想在vc2005的combo boxk中以下拉列表的形式显示数据库的内容??
- 一个东西猛然不知道叫啥东西了
- 为什么给按钮关联一个变量后,就不能给它加载图片了?
- 用CImage::LoadFromResource加载JPG时遇到的问题
- CTreeCtrl如何更改一个已经存在的父节点名称?
- VC6.0 Studio使用方法
- 关于VC中生成报表的问题~大家帮帮~~~非常急!!!
- 为什么发送ICMP packet不像发送TCP or UDP packet那样,需要同时指定目标的端口号?
- 请问哪位大虾能告诉我Microsoft Visual Studio到底包括哪些东东?
- 控件之间覆盖的问题,急啊!
- 如何改变按钮的背景颜色?(灰灰的不好看!)
COLORREF crColor
);抄自MSDN的一部分代码:HBRUSH CZilchDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// Call the base class implementation first! Otherwise, it may
// undo what we're trying to accomplish here.
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // Are we painting the IDC_MYSTATIC control? We can use
// CWnd::GetDlgCtrlID() to perform the most efficient test.
if (pWnd->GetDlgCtrlID() == IDC_MYSTATIC)
{
// Set the text color to red
pDC->SetTextColor(RGB(255, 0, 0)); // Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT); // Return handle to our CBrush object
hbr = m_brush;
} return hbr;
}
WM_CTLCOLOR消息吧。这个方法对于static,group box有效!
private:
CFont m_font;
在.cpp文件
BOOL CMyDialog::OnInitDialog()
{
...
m_font.Create();//指定字体颜色
...
GetDlgItem(IDC_BUTTON)->SetFont(&m_font);
...
}