位图作为MDI mainfrm的背景 [英] Bitmap as background to MDI mainfrm
问题描述
在尝试加载其他帧之前,我正在尝试为大型机的背景制作位图图像,但是我没有运气,我还缺少什么?
I am trying to make a bitmap image the background for the mainframe before any other frames are loaded but I'm not having any luck, what am I missing?
BOOL CMainFrame::OnEraseBkgnd(CDC* pDC)
{
CBitmap m_cbImage;
COLORREF m_crBack;
UINT m_uImage;
m_crBack = RGB(255, 255, 255);
m_uImage = IDB_SPLASH;
if ((m_cbImage.m_hObject == NULL) && (m_uImage>0))
{
m_cbImage.LoadBitmap(m_uImage);
m_bFirst = TRUE;
}
else
{
if (m_bFirst)
{
m_bFirst = FALSE;
}
}
CRect rcClient;
GetClientRect(rcClient);
pDC->FillSolidRect(rcClient, m_crBack);
if (m_cbImage.m_hObject != NULL)
{
BITMAP sBitmap;
m_cbImage.GetBitmap(&sBitmap);
CSize szImage(sBitmap.bmWidth, sBitmap.bmHeight);
pDC->DrawState(CPoint(0, 0), szImage, &m_cbImage, DST_BITMAP | DSS_NORMAL);
}
return TRUE;
}
推荐答案
看起来好像大型机的背景不是真的.大型机通常只是处理:框架.MDI客户区由"MDI客户"窗口处理(该窗口又管理MDI子窗口).
What looks like the background of the mainframe really isn't. The mainframe mostly just handles exactly that: the frame. The MDI client area is handled by a MDI Client window (which, in turn, manages the MDI child windows).
要更改背景图形,请创建一个MDI Client窗口类( CWnd
的公共派生),并在其 OnEraseBkgnd
中处理该图形.在MainFrame类中创建该类的实例,然后在MainFrame的 OnCreate
中,告诉MDI客户将股票MDI客户窗口子类化:
To change the background drawing, you create a MDI Client window class (public derivative of CWnd
), and handle the drawing in its OnEraseBkgnd
. Create an instance of that class in your MainFrame class, and in your MainFrame's OnCreate
, tell your MDI client to subclass the stock MDI client window:
myClient.SubclassWindow(m_hWndMDIClient);
这篇关于位图作为MDI mainfrm的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!