Solved

CMainFrame

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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