标 题: How change the background color of a view?
发信人: Pacific (无情~~~Nolove), 信区: VisualC
发信站: BBS 水木清华站 (Fri Oct 16 17:50:50 1998)
To change the background color for a CView, CFrameWnd, or CWnd object,
process the WM_ERASEBKGND message. The sample code below demonstrates
how.
Sample Code
-----------
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;
}
To change the background color for a CMDIFrameWnd you must subclass the
multiple document interface (MDI) client window (window in the client area
of CMDIFrameWnd) and process the WM_ERASEBKGND message. For more
information about the MDI client window in an MDI application, see chapter
18 in "Programming Windows 3.1 - Third Edition" by Charles Petzold. For an
example that shows how to subclass the MDICLIENT window, please see the
article in the Microsoft Knowledge Base:
ARTICLE-ID: Q129471
TITLE: How to subclass the MDICLIENT by Using MFC
To change the background color of an MDI client window (client area of a
CMDIFrameWnd), perform the following steps using an AppWizard-generated
application:
--
老鸟有交待,中鸟要等待,菜鸟要忍耐。
老鸟级功夫:吹牛、聊天、玩MUD 、发呆。
中鸟级功夫:睡觉、灌水、玩游戏、NT&VC。
菜鸟级功夫:学习、泡妞、玩篮球、And so on
My E-Mail: Nolove@263.net
--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: yazhou.bbs@bbs.net.t]
※ 修改:.fzx 于 Aug 9 16:44:16 修改本文.[FROM: heart.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:6.040毫秒