Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bitmap background for MDI main window

Posted on 1998-02-05
1
Medium Priority
?
410 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

604 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