?
解决方案 »
- wchar_t到底是几个字节长的? 为什么有的系统里面是4个字节?
- VC 屏幕最大化
- 这个如何运行其结果?
- 请教一个关于CDC的问题
- 怎样才能获得自绘按钮的WM_COMMAND消息?
- 内存跟硬盘交换数据的单位是多少K.
- zhujianping_es(DavidRipple),sharkhuang(共享智慧),sillyou(),oyljerry(☆勇敢的心☆-Paper Reviewing), 进来领分
- 安装包怎么做?
- DLL不是挺好的吗?那干吗还要用COM呢?
- 背景有时会运动有时不会 人物可能会改变位置也可能不变
- 今天收到<C++Primer>呵呵~~~~,大散分!!! 10分钟准时结贴,赶快哦~~~~~~~~~~~~~~~
- 有没有人做过Mail服务器程序?
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// if (nCtlColor==IDC_palm)
if(pWnd->GetDlgCtrlID()==IDC_palm)
pDC->SetTextColor(RGB(255,0,255));
return hbr;
}
绝对可以!
然后再初始化的过程中Create最后在OnCtlColor里面返回它的句柄就行了
注意,千万不要在OnCtlColor中来创建一个CBrush对象,因为这样的话,这个函数结束后它的生命期也就结束了。除非用指针,但这样依然有许许多多的问题,包括释放以及第一次创建的时候需要Create等等的问题。
// with the ID of IDC_MYSTATIC. The code assumes that the CMyDialog
// class has an initialized and created CBrush member named m_brush.
// The control will be painted with red text and a background
// color of m_brush.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;
}
if (pWnd->GetDlgCtrlID()==IDC_palm)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetBkColor(RGB(255, 255, 255));
static CBrush m_brushEdit(RGB(255, 255, 255));
hbr = m_brushEdit;
}