Solved

CMainFrame

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is it possible to combine several text files into one big one? (redhat v5 enterprise) 4 93
sum28 challenge 31 112
post4 challenge 28 102
Capture logon name 13 75
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

831 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