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 » CExtControlBar or CExtPanelControlBar? Collapse All
Subject Author Date
Norman Tellinot Nov 12, 2006 - 11:16 PM

I want to create a control bar that is permanently docked to the top, has a fixed height, but spans the entire width of the frame.

A CExtPanelControlBar has a fixed height, but unfortuantely the width is also fixed, so when I make the frame window wider, it doesn’t grow.

A CExtControlBar spans to the entire width of the frame window, but its height is resizable, which I don’t want.

Can you think of a way to achieve what I want?

thanks!

Norman Tellinot Nov 15, 2006 - 10:46 PM

Thanks for the WM_SIZEPARENT tip, that works!

Norman Tellinot Nov 13, 2006 - 12:49 AM

Also, now I added a CExtToolControlBar to the CExtResizableDialog I host within the CExtPanelControlBar. This results in an infinite loop and the stack overflows:

    CExtResizableDialog::PreTranslateMessage(tagMSG * pMsg=0x00176d20) Line 188 + 0xd    C++
    CExtControlBar::PreTranslateMessage(tagMSG * pMsg=0x00176d20) Line 20011 + 0x14    C++
    CExtControlBar::DoCustomModePreTranslateMessage(CWnd * pWndPretranslateSrc=0x01fb61bc, tagMSG * pMsg=0x00176d20) Line 7706 + 0x14    C++
    CExtResizableDialog::PreTranslateMessage(tagMSG * pMsg=0x00176d20) Line 188 + 0xd    C++
    CExtControlBar::PreTranslateMessage(tagMSG * pMsg=0x00176d20) Line 20011 + 0x14    C++
    CExtControlBar::DoCustomModePreTranslateMessage(CWnd * pWndPretranslateSrc=0x01fb61bc, tagMSG * pMsg=0x00176d20) Line 7706 + 0x14    C++

It looks like it’s because the CExtControlBar asks its owner, the CExtResizableDialog, to PreTranslateMessage, and then the dialog in turn asks all its children.
Should I not be doing that?

Technical Support Nov 14, 2006 - 3:44 AM

In fact, you described a control bar that acts like the status bar. You could implement this contol bar’s behavior in any window: simply handle the WM_SIZEPARENT window message, which is an MFC internal message. The handler receives a pointer to the AFX_SIZEPARENTPARAMS data structure in LPARAM parameter. Please do not forget to include AfxPriv.h file so you can handle this message. So add the following method and message map entry to the CWnd-based C++ class that should be docked inside the main frame window:

afx_msg LRESULT OnSizeParent( WPARAM wParam, LPARAM lParam );
 
ON_MESSAGE( WM_SIZEPARENT, OnSizeParent )
 
LRESULT CYourClass::OnSizeParent( WPARAM wParam, LPARAM lParam )
{
    ASSERT_VALID( this );
    wParam; // unused
AFX_SIZEPARENTPARAMS * lpLayout = (AFX_SIZEPARENTPARAMS *) lParam;
    ASSERT( lpLayout != NULL );
CRect rcFrameRest = &lpLayout->rect;
DWORD dwWndStyle = GetStyle();
    if( (dwWndStyle&WS_VISIBLE) == 0 )
        return 0;
<span class="newred">int nHeight = 345;</a>
CRect rcOwnLayout( rcFrameRest );
    lpLayout->rect.top += nHeight;
    rcOwnLayout.bottom = rcOwnLayout.top + nHeight;
    lpLayout->sizeTotal.cy += nHeight;
    if( lpLayout->hDWP != NULL )
        ::AfxRepositionWindow( lpLayout, m_hWnd, &rcOwnLayout );
    return 0;
}
The relative position of this and other windows inside the frame window depends on their Z-orders.