75.修改视图背景
How do I change the background color of a view?
To change the background color for a CView, CFrameWnd, or CWnd object, process the WM_ERASEBKGND message. The following code shows how:
BOOL CSampleView::OnEraseBkgnd(CDC* pDC)
{
// Set brush to desired background color.
CBrush backBrush(RGB(255, 128, 128));
// Save old brush.
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect); // Erase the area needed.
pDC->PatBlt(rect.left, rect.top, rect.Width(),
rect.Height(), PATCOPY);
pDC->SelectObject(pOldBrush);
return TRUE;
}
I solved the problem like this:
HBRUSH dlgtest::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch (nCtlColor)
{
case CTLCOLOR_BTN:
case CTLCOLOR_STATIC:
{
pDC->SetBkMode(TRANSPARENT);
}
case CTLCOLOR_DLG:
{
CBrush* back_brush;
COLORREF color;
color = (COLORREF) GetSysColor(COLOR_BTNFACE);
back_brush = new CBrush(color);
return (HBRUSH) (back_brush->m_hObject);
}
}
return(CFormView::OnCtlColor(pDC, pWnd, nCtlColor));
}
修改视图背景
来源:清泛编译 2016-05-23 13:43:54 人气: 我有话说( 0 人参与)
1.属性页的添加:创建对话框的类,该类要从CpropertyPage继承;然后在要添加该对话框为 属性页的类(头文件)里创建CpropertySheet类的一
上一篇:std::find,std::find_if使用小结
下一篇:MFC Telnet Application(mfc telnet 端口,代码实现、不调用telnet.exe)
本文源自互联网,采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可,
版权归原作者,如有问题请联系service@tsingfun.com (编辑:admin)
版权归原作者,如有问题请联系service@tsingfun.com (编辑:admin)
相关热点
- 1google mock分享(全网最全最好的gmock文...
- 2【解决】asan runtime does not come ...
- 3MFC学习总结 (90个技巧) dlg 上建立View
- 4coinitialize失败,返回值是0x80010106 无...
- 5VS Addin插件基本开发入门
- 6c++编译错误:invalid new-expression of abstract class type
- 7use of deleted function std::unique_...
- 8hidden symbol ... is referenced by DSO 剖析
- 9C++使用OLE/COM高速读写EXCEL的源码
- 10error C2664: “std::list<_Ty>::list(co...
本月排行
- 1google mock分享(全网最全最... 266次浏览
- 2【解决】asan runtime does... 259次浏览
- 3浅析Linux段错误:SEGV_MAPERR... 137次浏览
- 4hidden symbol ... is referenced by DSO 剖析 112次浏览
- 5【解决】munmap_chunk(): invalid pointer 74次浏览
- 6Reference to ' ' is ambi... 74次浏览
- 7coinitialize失败,返回值是0x8... 73次浏览
- 8use of deleted function s... 60次浏览
- 9C++ Lock-free Hazard Pointer(冒险指针) 59次浏览
- 10stl 字符串std::string作为std... 51次浏览
评论排行
- 1C++ 读写xml方法整理(持续更新)3次评论
- 2Reference to ' ' is ambiguous:符号定义重复2次评论
- 3全民OS2次评论
- 4__attribute__2次评论
- 5海量数据相似度计算之simhash和海...2次评论
- 6C++使用OLE/COM高速读写EXCEL的源码2次评论
- 7AfxIsValidAddress 测试内存地址2次评论
- 8C++入门进阶最佳实战2次评论
- 9解决xrdp登陆不上的问题:xrdp s...2次评论
- 10VC 自绘日历,有绘制日历需求的...2次评论