Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Background bitmap for Main frame in MDI DOCVIEW Collapse All
Subject Author Date
Fransiscus Herry Mar 11, 2007 - 4:28 AM

Dear Prof-UIS,

I would like to know how to paint the client area in Mainframe for MDI application. Any suggestion of this, especially without much flickering?

regards,
F.Herry

Fransiscus Herry Mar 14, 2007 - 11:41 PM

Dear Prof-UIS,

I have checked the compilation time both using prof-uis and using plain MFC. It seemed the code to paint the mainframe background is only a basic code to paint which have some weaknesses as i surfaced to you earlier. But don’t worry, i have managed to custom paint the background using a code from Bogdan Ledwig in www.codeguru.com <http://www.codeguru.com/cpp/w-d/doc_view/background/article.php/c3311/>. Hopefully this will help other people that want to solve the same problem. This class works just fine with Prof-uism though i had to modify the painting method and setbitmap method in this class.

regards,
F. Herry

Fransiscus Herry Mar 14, 2007 - 2:15 AM

Dear Prof-Uis,

I have successfully implemented this code. I can load a bitmap as well using CExtImage (as per search in this forum). However, when the window of the background is resized by maximize button or minimize, the background image seems to be "late" for re-paint. maybe you could help me again with this matter.

I also noticed that in this forum about m_bCustomBackgroundInHeritanceEnabled. I just want to know whether this kind of function (overriden code) have the same purposes to paint the background?

FYI, i am happy with the service for fast answer. Thank you.

Technical Support Mar 14, 2007 - 9:24 AM

Prof-UIS is much slower when compiled under debug settings because it is crammed with assert statements to make it reliable. So please compile a release version and let us know if the problem persists.

The CExtPaintManager::m_bCustomBackgroundInheritanceEnabled flag allows you to paint a custom background for windows in your application. By default, it is set to false and the background of a particular window is painted by the current paint manager. For example, if the current paint manager is CExtPaintManagerOffice2003, a gradient background will be painted.

Now suppose you need to paint some custom background for a window or you want to paint a custom background that is consistent between all the other windows in the application like in the Tabbed Bars sample. When CExtPaintManager::m_bCustomBackgroundInheritanceEnabled is true, the paint manager, instead of painting the standard background of the window, sends a CExtPaintManager:: g_nMsgPaintInheritedBackground message to the window back and allows it to paint the background in the handler of this message. If the message is not handled, the paint manager sends it to its parent and so forth until the message is processed, which means the background has been painted. If the message has not been processed by parent windows, the paint manager simply paints the standard background.

There is also a FAQ article relating to your question:

How to paint a custom background consistent between the windows in my application?

Technical Support Mar 12, 2007 - 3:17 PM

Here is how you could do this.

1) Subclass the MDI client area and handle WM_ERASEBKGND and WM_PAINT messages:

class CMyMdiClientAreaWnd : public CWnd
{
protected:
    virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
    {
        if( message == WM_ERASEBKGND )
            return TRUE;
        if( message == WM_PAINT )
        {
            CPaintDC dc( this ); 
            CRect rc; 
            GetClientRect( &rc );
            dc.FillSolidRect( &rc, RGB(0,255,0) ); // draw entirely green background
            return TRUE;
        }
        return CWnd::WindowProc( message, wParam, lParam );
    }
};
2) Define the following property in your main frame class
CMyMdiClientAreaWnd m_wndMyMdiClientArea;
and invoke the line below somewhere at the end of the OnCreate() handler method of your main frame class
m_wndMyMdiClientArea.SubclassWindow( ::GetDlgItem( m_hWnd, AFX_IDW_PANE_FIRST ) );