Solved

CMainFrame

Posted on 1996-12-22
2
925 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
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

14 Experts available now in Live!

Get 1:1 Help Now