Click to See Complete Forum and Search --> : Bitmap in MDI MAINFRAME


gilles
March 31st, 1999, 03:45 PM
How can i display a bitmap in a MDI MainFrame (on the back) not on a child ?


If no possible, is it possible to have a childFrame that doesn't come front when mouse click on?


thanks for your answer.

Ramon Saenz-Badillos
March 31st, 1999, 06:38 PM
You can do it usings OnEraseBkgnd and SubclassWindow(m_hWndMDIClient)like this:

.

subclass the MDI client window with a CWnd derived class lets call it

CBackground. use class wizard to add handles for the WM_ERASEBKGND and WM_SIZE

messages.

edit CBackground::OnEraseBkgnd to display your bitmap, you might want to size it to the size of your window client.

dont forget to return TRUE to indicate the background was erased.

Edit Cbackground::OnSize to include Invalidtate(TRUE).

Next step is to Add a member variable of your CBackground type to your main applications window class and use

SubclassWindow() in your mains application OnCreate() like this

class CMainFrame:public CMDIFrameWnd

(//...

protected:

CBackground m_wndBackground;

//...}

.

int CMainFrame::OnCreate(...) {

//...

if( !m_wndBackground.SubclassWindow(m_hWndMDIClient))

{ return -1;}

//m_hWndMDIClient is an undocumented member of CMDI FrameWnd class.



good luck

Raphael Phan
April 1st, 1999, 03:00 AM
Hi,


How to draw the bitmap in OnEraseBkgnd?


Raphael

Ramon Saenz-Badillos
April 1st, 1999, 12:57 PM
There are many ways to draw a bitmap. heres one...

.

//declare m_bitmap as a CBitmap in the CBackground constructor

//load it with LoadBitmap()

Bool CBackground::OneraseBkgnd(CDC* pDC) //see other posts for explanation

CDC dcMem;

dcMem.CreateCompatibleDC(pDC);

CBitmap* pOldBitmap=dcMem.SelectObject(&m_bitmap);

BITMAP bmp;

m_bitmap.GetObject(sizeof(bmp),&bmp); //get size

CRect rect;

GetClientRect(&rect); //get size of window

pDC->StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),&dcMem,

0,0,bmp.bmWidth,bmp.bmHeight,SRCOPY);

dcMem.SelectObject(pOldBitmap);

return TRUE;

)

good luck