如何设定视图窗口的背景色

kangarooxy 2003-09-26 11:04:26
我想将视图的背景色设为系统色,该怎办?
...全文
99 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
CuckFSDN 2003-09-26
  • 打赏
  • 举报
回复
搜搜以前的贴子,这种问题的答安太多了.
CuckFSDN 2003-09-26
  • 打赏
  • 举报
回复
在视图的precreatewindow中把原类拷贝一分,并改 hbrBackground成员为想要的色,然后再注册
wangjs720 2003-09-26
  • 打赏
  • 举报
回复
Allows you to register your own window classes.

LPCTSTR AFXAPI AfxRegisterWndClass(
UINT nClassStyle,
HCURSOR hCursor = 0,
HBRUSH hbrBackground = 0,
HICON hIcon = 0
);
Parameters
nClassStyle
Specifies the Windows class style or combination of styles, created by using the bitwise-OR (|) operator, for the window class. For a list of class styles, see the WNDCLASS structure in the Platform SDK. If NULL, the defaults will be set as follows:
Sets the mouse style to CS_DBLCLKS, which sends double-click messages to the window procedure when the user double-clicks the mouse.
Sets the arrow cursor style to the Windows standard IDC_ARROW.
Sets the background brush to NULL, so the window will not erase its background.
Sets the icon to the standard, waving-flag Windows logo icon.
hCursor
Specifies a handle to the cursor resource to be installed in each window created from the window class. If you use the default of 0, you will get the standard IDC_ARROW cursor.
hbrBackground
Specifies a handle to the brush resource to be installed in each window created from the window class. If you use the default of 0, you will have a NULL background brush, and your window will, by default, not erase its background while processing WM_ERASEBKGND.
hIcon
Specifies a handle to the icon resource to be installed in each window created from the window class. If you use the default of 0, you will get the standard, waving-flag Windows logo icon.
Return Value
A null-terminated string containing the class name. You can pass this class name to the Create member function in CWnd or other CWnd-derived classes to create a window. The name is generated by the Microsoft Foundation Class Library.

Note The return value is a pointer to a static buffer. To save this string, assign it to a CString variable.
Remarks
The Microsoft Foundation Class Library automatically registers several standard window classes for you. Call this function if you want to register your own window classes.

The name registered for a class by AfxRegisterWndClass depends solely on the parameters. If you call AfxRegisterWndClass multiple times with identical parameters, it only registers a class on the first call. Subsequent calls to AfxRegisterWndClass with identical parameters simply return the already-registered classname.

If you call AfxRegisterWndClass for multiple CWnd-derived classes with identical parameters, instead of getting a separate window class for each class, each class shares the same window class. This can cause problems if the CS_CLASSDC class style is used. Instead of multiple CS_CLASSDC window classes, you end up with one CS_CLASSDC window class, and all C++ windows that use that class share the same DC. To avoid this problem, call AfxRegisterClass to register the class.

SilverDragon 2003-09-26
  • 打赏
  • 举报
回复
CView::OnEraseBkgnd(pDC);
.....
先擦除原来的背景
zhucde 2003-09-26
  • 打赏
  • 举报
回复
在View中添加WM_ERASEBKGND消息

BOOL CAaView::OnEraseBkgnd(CDC* pDC)
{
// Create a pruple brush.
CBrush Brush (RGB (128 , 0 , 128) );//颜色自己定
// Select the brush into the device context .
CBrush* pOldBrush = pDC->SelectObject(&Brush);
// Get the area that needs to be erased .
CRect rcClip;
pDC->GetClipBox(&rcClip);
//Paint the area.
pDC-> PatBlt (rcClip.left , rcClip.top , rcClip.Width ( ) , rcClip.Height( ) , PATCOPY );
//Unselect brush out of device context .
pDC->SelectObject (pOldBrush );
// Return nonzero to half fruther processing .
return TRUE;
}
紫郢剑侠 2003-09-26
  • 打赏
  • 举报
回复
处理WM_ERASEBKGND消息.
fanqing 2003-09-26
  • 打赏
  • 举报
回复
WM_ERASEBKGND
获得客户区,用画刷填充。

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧