Your first question is how to repaint the background of MDI client area window. You can subclass this window and handle WM_PAINT
messages. So, first of all, create a CWnd
-derived class for handling both WM_PAINT
and WM_ERASEBKGND
messages:
class CYourMdiClientAreaWnd : public CWnd
{
public:
CYourMdiClientAreaWnd(){}
~CYourMdiClientAreaWnd(){}
protected:
virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
if( message == WM_ERASEBKGND )
return 1;
if( message == WM_ERASEBKGND )
{
CPaintDC dc( this );
CRect rcClient;
GetClientRect( &rcClient );
// this line will draw red background
// but you should draw your bitmapped background instead
dc.FillSolidRect( &rcClient, RGB(255,0,0) );
return 0;
}
return CWnd::WindowProc( message, wParam, lParam )
}
}
Now you should add this window to your
CMainFrame
class declaration:
CYourMdiClientAreaWnd m_wndYourMdiClientAreaWnd;
And subclass the MDI client area window with the
m_wndYourMdiClientAreaWnd
object. You can do this somewhere at the the end of the
CMainFrame::OnCreate()
method:
m_wndYourMdiClientAreaWnd.SubclassWindow( GetDlgItem(AFX_IDW_PANE_FIRST) );
Of course, you can modify the built-in menu of dynamic bar site or even re-create it from scratch. Please note this menu always deals with particular control bars. So, you should use your own
CExtDynamicControlBar
-derived class and implement the
CExtDynamicControlBar::OnInitDbsMenu()
virtual method. In it, you can invoke the parent class’s method and modify the menu created by default. Please also note:
1) Because of using your own
CExtDynamicControlBar
-derived class, it should have its own creatable run-time information:
class CYourDynamicBar : public
{
public:
DECLARE_SERIAL( CYourDynamicBar );
CYourDynamicBar(){}
~CYourDynamicBar(){}
. . .
};
IMPLEMENT SERIAL_SERIAL( CYourDynamicBar . . .
2) You will need to make the
CExtDynamicBarSite
object using the
CYourDynamicBar
type instead of the
CYourDynamicBar
type. So, please use the
RUNTIME_CLASS( CYourDynamicBar )
type information explicitly when allocating your dynamic bars:
CYourDynamicBar * pYourBar =
STATIC_DOWNCAST(
CYourDynamicBar,
pDynamicBarSite->BarAlloc(
_T("bar caption"),
_cmdIcon,
nBarID,
RUNTIME_CLASS( CYourDynamicBar )
)
);