Solved

Bitmap background for MDI main window

Posted on 1998-02-05
1
407 Views
Last Modified: 2013-11-19
I want to add a bitmap background to my MDI main window
how do I go about this (code example). I have read that EraseBkgnd and OnPaint need to be user processed.
0
Comment
Question by:jerzak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
hasmet earned 0 total points
ID: 1315638
Create new CWnd base class CBackGround

handle WM_ERASEBKGND as below in your new class.

BOOL CBackGround::OnEraseBkgnd(CDC* pDC)
{
      BOOL result;
      result = CWnd::OnEraseBkgnd(pDC);
      BITMAP BM;
      CBitmap m_Bitmap;
      CDC m_DC;
      RECT ici;
      GetClientRect(&ici);
      m_Bitmap.LoadBitmap(IDB_BITMAP_PLANT);
      m_DC.CreateCompatibleDC(pDC);
      m_DC.SelectObject(&m_Bitmap);
      m_Bitmap.GetObject(sizeof(BM), &BM);
      if(pDC->StretchBlt(0,0,
        (ici.right - ici.left),(ici.bottom - ici.top),
        &m_DC, 0, 0, BM.bmWidth, BM.bmHeight, SRCCOPY) == 0)
      {
            AfxMessageBox("failed to create bitmap");
      }
      return result;
}

in your mainframe.h file include the header for the new class
and create a protected member

say

CBackGround m_background;

and
Subclass this client window in your mainframe's OnCreate function as

m_background.SubclassWindow(m_hWndMDIClient);


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question