- 方法一 在PreCreateWindow中更改:
在View::PreCreateWindow(CREATESTRUCT& cs)中加入:
HBRUSH hbkbrush=CreateSolidBrush(RGB(192,192,192));//创建灰色背景刷
LPCSTR lpMyOwnClass=AfxRegisterWndClass(CS_HREDRAWCS_VREDRAWCS_OWNDC,0,hbkbrush);//注册新类
cs.lpszClass=lpMyOwnClass;//修改缺省的类风格
- 方法二 在消息处理函数OnEraseBkgnd中贴bmp位图作为背景色
// TODO: Add your message handler code here and/or call default
CBitmap bmInvader;
bmInvader.LoadBitmap(IDB_BITMAP1);
CBrush brInvader(&bmInvader);
CRect rcClient;
GetClientRect(&rcClient);
pDC->FillRect(&rcClient,&brInvader);
return true;
// return CView::OnEraseBkgnd(pDC);
- 方法三 在运行时使用SetClassLong更改
static CBrush brush(RGB(255,0,255));
SetClassLong(this->m_hWnd,GCL_HBRBACKGROUND,(LONG)(HBRUSH)brush);
Comments (1)
your blog is very nice