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 General Discussion » CMainFrame client area Collapse All
Subject Author Date
Leon Miller Feb 6, 2006 - 8:33 PM

In an MDI app, is there a way to get the CMainFrame (derived from CMDIFrameWnd) client area, minus the docked control bar (CExtControlBar) areas, without having to get each individual rect and subtract them out?

i.e,

CRect aRect;
GetClientRect(aRect);

aRect is the entire size of the CMainFrame, even though there are docked control bars.

Technical Support Feb 7, 2006 - 12:38 PM

The client rectangle of the main frame window is equal to the total window rectangle excluding the caption and border space but including all the child views, bars and MDI client area. The CWnd::RepositionBars() method allows you to compute the rest, free of any bars rectangle used for the MDI client area (or SDI child view) and to reposition bars and the rest middle window depending on the message parameters. The following code computes the desired inner rectangle:

CRect rcFrameInner;
pMainFrame->GetClientRect( &rcFrameInner );
pMainFrame->RepositionBars(
    0,
    0x0FFFF,
    AFX_IDW_PANE_FIRST,
    CWnd::reposQuery, // do not reposition bars, just subtract their areas
    rcFrameInner,
    rcFrameInner
    );

Please note that it is possible to make the size of the main frame window enough small to let the bars at the left intersect with the bars at the right. In this case, rcFrameInner.left can be greater or equal to rcFrameInner.right. The same can occur with the top/bottom fields.