Dear ProfUIS-Team,
adding a new option page does not ensure resizing of the ribbon option dialog. The original ProfUIS code does not take care about the size of option pages. To create a ribbon’s option dialog the dialog template IDD_EXT_RIBBON_OPTIONS_DIALOG is taken from resources. If the size of a custom option page exceeds that of the dialog control IDC_EXT_RIBBON_STATIC_FRAME, then the problem is passed to the user.
Therefore we needed to customize ExtRibbonBar.cpp
in order to deal with that problem:
BOOL CExtRibbonOptionsDialog::OnInitDialog()
{
m_wndOptionsTabs.ResetContent();
if( m_pRibbonBar->GetSafeHwnd() == NULL
|| ( ! CExtNCW < CExtResizableDialog > :: OnInitDialog() )
)
{
ASSERT( FALSE );
return FALSE;
}
ASSERT_VALID( m_pRibbonBar );
m_strCommandProfileName =
g_CmdManager->ProfileNameFromWnd( m_pRibbonBar->m_hWnd );
ASSERT( ! m_strCommandProfileName.IsEmpty() );
g_CmdManager->ProfileWndAdd(
LPCTSTR( m_strCommandProfileName ),
m_hWnd
);
CWnd * pWnd = CExtControlBar::stat_GetWndForPlacement( m_pRibbonBar );
HICON hIcon = NULL;
if( pWnd->GetSafeHwnd() != NULL )
{
hIcon = (HICON)
::SendMessage(
pWnd->m_hWnd,
WM_GETICON,
ICON_BIG,
0L
);
if( hIcon == NULL )
{
hIcon = (HICON)
::SendMessage(
pWnd->m_hWnd,
WM_GETICON,
ICON_BIG,
0L
);
if( hIcon == NULL )
{
hIcon = (HICON)
::GetClassLong(
pWnd->m_hWnd,
__EXT_MFC_GCL_HICON
);
if(hIcon == NULL)
hIcon = ::AfxGetApp()->LoadStandardIcon( IDI_WINLOGO );
} // if( hIcon == NULL )
} // if( hIcon == NULL )
} // if( pWnd->GetSafeHwnd() != NULL )
if( hIcon != NULL )
{
SetIcon( hIcon, TRUE );
SetIcon( hIcon, FALSE );
} // if( hIcon != NULL )
AddAnchor( IDC_EXT_RIBBON_LIST_BOX_TABS, __RDA_LT, __RDA_LB );
AddAnchor( IDC_EXT_RIBBON_STATIC_FRAME, __RDA_LT, __RDA_RB );
AddAnchor( IDOK, __RDA_RB );
AddAnchor( IDCANCEL, __RDA_RB );
CRect rcWnd;
GetWindowRect( &rcWnd );
CSize _sizeMinTrack(
::MulDiv( rcWnd.Width(), 5, 6 ),
::MulDiv( rcWnd.Height(), 7, 8 )
);
SetMinTrackSize( _sizeMinTrack );
CRect rcPage;
m_labelEmptyFrame.GetWindowRect( &rcPage );
ScreenToClient( &rcPage );
m_pRibbonBar->OnRibbonOptionsDialogInitPageRTCs( *this );
HWND hWndSelPage = NULL;
HWND hWndInsertAfter = m_wndOptionsTabs.m_hWnd;
INT nPageIndex, nPageCount = INT( m_arrPageRTCs.GetSize() );
for( nPageIndex = 0; nPageIndex < nPageCount; nPageIndex ++ )
{
CRuntimeClass * pRTC = m_arrPageRTCs[ nPageIndex ];
if( pRTC == NULL
|| ( ! pRTC->IsDerivedFrom( RUNTIME_CLASS( CExtRibbonOptionsPage ) ) )
)
{
ASSERT( FALSE );
return FALSE;
}
CObject * pObject = pRTC->CreateObject();
if( pObject == NULL )
{
ASSERT( FALSE );
return FALSE;
}
CExtRibbonOptionsPage * pPage =
STATIC_DOWNCAST( CExtRibbonOptionsPage, pObject );
UINT nPageID = pPage->RibbonOptionsPage_GetID();
if( ! pPage->Create( nPageID, this ) )
{
ASSERT( FALSE );
return FALSE;
}
pPage->ShowWindow( SW_HIDE );
if( ! m_wndOptionsTabs.AddPage( pPage ) )
{
ASSERT( FALSE );
return FALSE;
}
if( hWndSelPage == NULL )
hWndSelPage = pPage->m_hWnd;
else if( m_nSelectedPageID == nPageID )
hWndSelPage = pPage->m_hWnd;
// ----------- START OF INSERTED CODE ------------
CRect pageRect;
CRect newRect(rcWnd);
pPage->GetWindowRect(&pageRect);
int difX = pageRect.Width() - rcPage.Width();
if (0 < difX )
{
newRect.right += difX;
rcPage.right += difX;
}
int difY = pageRect.Height()- rcPage.Height();
if (0 < difY )
{
newRect.bottom += difY;
rcPage.bottom += difY;
}
if ( !newRect.EqualRect(rcWnd))
{
MoveWindow(&newRect);
rcWnd = newRect;
}
// ----------- END OF INSERTED CODE ------------
::SetWindowPos(
pPage->m_hWnd,
hWndInsertAfter,
rcPage.left,
rcPage.top,
rcPage.Width(),
rcPage.Height(),
SWP_NOACTIVATE|SWP_NOOWNERZORDER
);
AddAnchor( pPage->m_hWnd, __RDA_LT, __RDA_RB );
hWndInsertAfter = pPage->m_hWnd;
} // for( nPageIndex = 0; nPageIndex < nPageCount; nPageIndex ++ )
pWnd = GetWindow( GW_CHILD );
for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
{
CExtRibbonOptionsPage * pPage =
DYNAMIC_DOWNCAST( CExtRibbonOptionsPage, pWnd );
if( pPage == NULL )
continue;
if( ! pPage->RibbonOptionsPage_InitContent() )
{
ASSERT( FALSE );
return FALSE;
} // if( ! pPage->RibbonOptionsPage_InitContent() )
} // for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
if( m_nSelectedPageID == __EXT_RIBBON_OPTIONS_DIALOG_PAGE_DEFAULT )
m_nSelectedPageID = __EXT_RIBBON_OPTIONS_DIALOG_PAGE_CQATB;
CExtRibbonOptionsPage * pSelectedPage = NULL;
pWnd = GetDlgItem( m_nSelectedPageID );
if( pWnd != NULL )
pSelectedPage = DYNAMIC_DOWNCAST( CExtRibbonOptionsPage, pWnd );
if( pSelectedPage == NULL )
{
pWnd = GetWindow( GW_CHILD );
for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
{
pSelectedPage = DYNAMIC_DOWNCAST( CExtRibbonOptionsPage, pWnd );
if( pSelectedPage != NULL )
break;
} // for( ; pWnd != NULL; pWnd = pWnd->GetWindow( GW_HWNDNEXT ) )
} // if( pSelectedPage == NULL )
if( pSelectedPage != NULL )
m_wndOptionsTabs.SelectPage( pSelectedPage );
m_wndOptionsTabs.OnSwUpdateScrollBars();
if( hWndSelPage != NULL )
{
m_labelEmptyFrame.ShowWindow( SW_HIDE );
::ShowWindow( hWndSelPage, SW_SHOW );
}
return TRUE;
}
Would you please provide for such kind of resize functionality in future releases?
Best regards,
Martin