Solved

Bitmap background for MDI main window

Posted on 1998-02-05
1
406 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

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 164
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 133
How do I get Window Title of all opened process? 4 58
listing all the respondents to a twitter feed - Java 5 41
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

738 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