Link to home
Start Free TrialLog in
Avatar of Buster122296
Buster122296

asked on

CMainFrame

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>
ASKER CERTIFIED SOLUTION
Avatar of Brian122296
Brian122296

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of The Master
The Master

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.