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 » MDI question Collapse All
Subject Author Date
David Skok Feb 14, 2008 - 1:47 PM

I would like to use paint manager to paint a gradient on the client area of the MDI when no view is open. Right now the default is a dark charcoal color. I tried overriding OnEraseBackground and OnPaint of the CMDIFrameWnd and neither affects this background. I also tried overriding OnTabWndEraseClientArea in the CExtTabMdiOneNoteWnd tabs I use. This does not get at this background either. What in the world is responsible for painting the empty client area of MDI?

The main reason I would like to do this is because if no view is open and a dockable control bar is resized, you cannot see the border drag across this area because the drag frame color is the same as the background. I would however like to put a bitmap there in the future.

The gradient code I use is:

COLORREF clrFill =
    g_PaintManager->GetColor( CExtPaintManager::CLR_TASK_PANE_BK_TOP, (CObject*)this );

g_PaintManager->stat_PaintGradientRect(
        dc,
        rcGridInner,
        RGB(255, 255, 255),
        clrFill,
true
        //bool bHorz = false,
        //UINT nCountOfSteps = 256
        );

thanks,

Dave

Technical Support Feb 15, 2008 - 8:09 AM

The MDI frame window is not the parent window of MDI child frames directly. The MDI frame window contains an MDI client window (dark charcoal). The MDI client window contains MDI child frames. So, you should subclass the MDI client window and implement paint message handlers in it. First, you need a new C++ class like this:

class CMyMdiClientAreaWnd : public CWnd
{
protected:
      virtual void PreSubclassWindow()
      {
            CWnd::PreSubclassWindow();
            if( ( GetStyle() & (WS_CLIPCHILDREN|WS_CLIPSIBLINGS) ) != (WS_CLIPCHILDREN|WS_CLIPSIBLINGS) )
                  ModifyStyle( 0, WS_CLIPCHILDREN|WS_CLIPSIBLINGS );
      }
      virtual LRESULT WindowProc( UINT message,  WPARAM wParam, LPARAM lParam )
      {
            switch( message )
            {
            case WM_ERASEBKGND:
            return 1L;
            case WM_PAINT:
            {
                  CPaintDC dcPaint( this );
                  CRect rcClient;
                  GetClientRect( &rcClient );
                  CExtMemoryDC dc( &dcPaint, &rcClient );
                  if(         (! g_PaintManager->GetCb2DbTransparentMode( this ) )
                        &&    (! g_PaintManager->PaintDockerBkgnd( true, dc, this ) )
                        )
                        dc.FillSolidRect( &rcClient, g_PaintManager->GetColor( COLOR_3DFACE ) );    
            }
            return 1L;
            }
            return CWnd::WindowProc( message, wParam, lParam );
      }
};
Then you should add the following property to the CMainFrame class:
CMyMdiClientAreaWnd m_wndMyMdiClientArea;
Finally you should invoke the following code in the CMainFrame::OnCreate() method:

HWND hWnd = ::GetDlgItem( m_hWnd, AFX_IDW_PANE_FIRST );
      ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
      m_wndMyMdiClientArea.SubclassWindow( hWnd );