?
Solved

CMainFrame

Posted on 1996-12-22
2
Medium Priority
?
979 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 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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…
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…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

777 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