CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 1999
    Posts
    2

    Bitmap in MDI MAINFRAME



    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.

  2. #2
    Join Date
    Apr 1999
    Posts
    16

    Re: Bitmap in MDI MAINFRAME



    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 CMainFrameublic 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

  3. #3
    Join Date
    Apr 1999
    Posts
    11

    Re: Bitmap in MDI MAINFRAME



    Hi,


    How to draw the bitmap in OnEraseBkgnd?


    Raphael

  4. #4
    Join Date
    Apr 1999
    Posts
    16

    Re: Bitmap in MDI MAINFRAME



    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured