Search

CMFCStatusBar incorrectly assumes WS_THICKFRAME and SBARS_SIZEGRIP by Marc_75

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 641292
Opened: 2/4/2011 2:25:54 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
MFC feature pack classes:
If you would like to create a 2nd status bar pane INSIDE of a CMdiChildWndEx class while having the feature MDI-tabs enabled (EnableMDITabbedGroups), MFC incorrectly assigns the status bar style SBARS_SIZEGRIP:

BOOL CMFCStatusBar::CreateEx(CWnd* pParentWnd, DWORD /*dwCtrlStyle*/, DWORD dwStyle, UINT nID)
{
......
    if (pParentWnd->GetStyle() & WS_THICKFRAME)
    {
        dwStyle |= SBARS_SIZEGRIP;
    }
......
}

Some window styles will be removed any time later. Probably these should be removed at an earlier stage to avoid this problem.


My workaround:
(class CMyFrame : pubic CMDIChildWndEx)
BOOL CMyFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if (m_pMDIFrame != NULL && m_pMDIFrame->IsMDITabbedGroup())
        cs.style &= ~CMDIChildWndEx::m_dwExcludeStyle | WS_MAXIMIZE | WS_SYSMENU;
    
    return CMDIChildWndEx::PreCreateWindow(cs);
}

NOTE:
probably the code above should have been added to CMDIChildWndEx::PreCreateWindow()??
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

just add a CMFCStatusBar variable in an overridden CMDIChildWndEx class.
and add the following code:
int CMyFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
.....
    if (!m_wndStatusBar.Create(this))
{
    TRACE0("Failed to create status bar\n");
    return -1;     // fail to create
}

static UINT indicators[] = {ID_SEPARATOR};    // status line indicator
VERIFY(m_wndStatusBar.SetIndicators(indicators, _countof(indicators)));
.....
}

Product Language

English

Operating System

Windows Vista

Operating System Language

English

Actual results

The status bar includes a gripper that has no effect at all, but resizing the status bar.

Expected results

I should expect that MFC (feature pack) would handle this situation since it also provides the means to have tabbed MDI child windows that cannot be resized directly at all.

The style SBARS_SIZEGRIP should not be enabled since the new MDI Tabbed feature does not allow the MDI client window to be resized. Therefore, no status bar gripper should be displayed if MDI tabs are used in favour of the older case of multiple MDI child windows.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/9/2011 at 3:58 PM
Hello,

Thanks for the report. This issue has been fixed in MFC for the next major release of Visual Studio.

Pat Brenner
Visual C++ Libraries Development
Posted by Microsoft on 2/4/2011 at 2:58 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by Marc_75 on 2/4/2011 at 2:58 AM
My final workaround. Perhaps there is a better solution, but this will work. For some reason PreCreateWindow is called again, hence the statement: if (cs.hwndParent).

BOOL CMyFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if (cs.hwndParent)
{
    CMDIFrameWndEx* pFrame = dynamic_cast<CMDIFrameWndEx*>(CWnd::FromHandle(cs.hwndParent));
    if (pFrame && pFrame->IsMDITabbedGroup())
     cs.style &= ~CMDIChildWndEx::m_dwExcludeStyle | WS_MAXIMIZE | WS_SYSMENU;
}
    
return CMDIChildWndEx::PreCreateWindow(cs);
}
Marc
Posted by Marc_75 on 2/4/2011 at 2:46 AM
I'm sorry,
the if-statement in my workaround posted will not function since the m_pMDIFrame will only be set later on in CMDIChildWndEx::OnCreate(). But still, the workaround (after the if-condition) works.

regards,
Marc
Sign in to post a workaround.