Solved

CMainFrame

Posted on 1996-12-22
2
962 Views
1 Endorsement
Last Modified: 2013-11-20
HELP!!!  I am trying to draw a bitmap in the CMainFrame of my MDI
application.  I am using VC 1.52.  I have tried the following:

BOOL  CMainFrame::OnEraseBkgnd(CDC* pDC)
 {
        CBitmap bitmap;
        CDC dcMemory;

        bitmap.LoadBitmap(IDB_BITMAP1);

        dcMemory.CreateCompatibleDC(pDC);
        CBitmap *obm = dcMemory.SelectObject(&bitmap);

        pDC->BitBlt(0,0,1400,500,&dcMemory,0,0,SRCCOPY);

        dcMemory.SelectObject(obm);     // have to reset DC state
before delting

        return TRUE;            // tell MFC that youv'e handled it, no
more erasing
required.
 }

The bitmap flashes on the screen and then is erased to gray again.
What am I doing wrong?


<X-FONTSIZE><PARAM>12</PARAM><FONTFAMILY><PARAM>Palatino</PARAM>HELP!!!  I am trying to draw a bitmap in the CMainFrame of my MDI
application.  I am using VC 1.52.  I have tried the following:


BOOL  CMainFrame::OnEraseBkgnd(CDC* pDC)

 {

        CBitmap bitmap;

        CDC dcMemory;


        bitmap.LoadBitmap(IDB_BITMAP1);



        dcMemory.CreateCompatibleDC(pDC);

        CBitmap *obm = dcMemory.SelectObject(&bitmap);



        pDC->BitBlt(0,0,1400,500,&dcMemory,0,0,SRCCOPY);


        dcMemory.SelectObject(obm);     // have to reset DC state
before delting


        return TRUE;            // tell MFC that youv'e handled it, no
more erasing

required.

 }


The bitmap flashes on the screen and then is erased to gray again.
What am I doing wrong?

</FONTFAMILY></X-FONTSIZE>
1
Comment
Question by:Buster122296
[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
2 Comments
 
LVL 1

Accepted Solution

by:
Brian122296 earned 100 total points
ID: 1300413
Look in the KB for drawing a bitmap to the background of CMainFrame
in your MFC app.  Has something to do with subclassing CMainFrame
but I don't remember the particulars.  Good Luck.

Corby

On 17 Dec 96 23:37:55 -0700, Robert Stromberg thought that:

: --Cyberdog-AltBoundary-00058602
: Content-Type: text/plain; charset=ISO-8859-1
: Content-Transfer-Encoding: quoted-printable

: HELP!!!  I am trying to draw a bitmap in the CMainFrame of my MDI
: application.  I am using VC 1.52.  I have tried the following:

: BOOL  CMainFrame::OnEraseBkgnd(CDC* pDC)
:  {
:         CBitmap bitmap;
:         CDC dcMemory;

:         bitmap.LoadBitmap(IDB_BITMAP1);
:    
:         dcMemory.CreateCompatibleDC(pDC);
:         CBitmap *obm =3D dcMemory.SelectObject(&bitmap);
:        
:         pDC->BitBlt(0,0,1400,500,&dcMemory,0,0,SRCCOPY);

:         dcMemory.SelectObject(obm);     // have to reset DC state
: before delting

:         return TRUE;            // tell MFC that youv'e handled it, no
: more erasing
: required.
:  }

: The bitmap flashes on the screen and then is erased to gray again.
: What am I doing wrong?



: --Cyberdog-AltBoundary-00058602
: Content-Type: multipart/mixed; boundary="Cyberdog-MixedBoundary-00058602"
: Content-Transfer-Encoding: 7bit


: --Cyberdog-MixedBoundary-00058602
: Content-Type: text/enriched; charset=ISO-8859-1
: Content-Transfer-Encoding: quoted-printable

: <X-FONTSIZE><PARAM>12</PARAM><FONTFAMILY><PARAM>Palatino</PARAM>HELP!!!=
:   I am trying to draw a bitmap in the CMainFrame of my MDI
: application.  I am using VC 1.52.  I have tried the following:


: BOOL  CMainFrame::OnEraseBkgnd(CDC* pDC)

:  {

:         CBitmap bitmap;

:         CDC dcMemory;


:         bitmap.LoadBitmap(IDB_BITMAP1);

:    

:         dcMemory.CreateCompatibleDC(pDC);

:         CBitmap *obm =3D dcMemory.SelectObject(&bitmap);

:        

:         pDC->BitBlt(0,0,1400,500,&dcMemory,0,0,SRCCOPY);


:         dcMemory.SelectObject(obm);     // have to reset DC state
: before delting


:         return TRUE;            // tell MFC that youv'e handled it, no
: more erasing

: required.

:  }


: The bitmap flashes on the screen and then is erased to gray again.
: What am I doing wrong?

0
 
LVL 2

Expert Comment

by:The Master
ID: 1300414
This is happening because the MDIFrameWnd creates an MDICLIENT window in it's client area (from it's OnCreate() function, which you can override).  The MDICLIENT window is the one that manages the child windows.  See the help entry on CMDIFrameWnd::CreateClient().

You can also see this yourself by using the Spy++ application that comes with VC.  Just click on the binoculars, and drag the target cursor over the app - you'll see the window outlines.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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