Solved

Bitmap background for MDI main window

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now