Solved

Bitmap background for MDI main window

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
ORA-01403: no data found 43 83
How to know only "File created" with EventLog 3 29
no14 challenge 14 57
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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

12 Experts available now in Live!

Get 1:1 Help Now