To set the height of the tip bar in the property grid control, you should change the height of bar’s window and recompute the control’s layout:
void ChangeTipHeight(
CExtPropertyGridCtrl & _PGC,
int nHeightOfTipBar
)
{
ASSERT( _PGC.GetSafeHwnd() != NULL );
CWnd * pWnd =
_PGC.GetChildByRTC(
RUNTIME_CLASS(
CExtPropertyGridTipBar
)
);
if( pWnd == NULL )
return;
CRect rcWnd;
pWnd->GetWindowRect( &rcWnd );
if( rcWnd.Height()
== nHeightOfTipBar
)
return;
pWnd->SetWindowPos(
NULL,
0,
0,
rcWnd.Width(),
nHeightOfTipBar,
SWP_NOACTIVATE
|SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOOWNERZORDER
|SWP_NOCOPYBITS
);
if( (pWnd->GetStyle()&WS_VISIBLE) != 0 )
_PGC.RecalcLayout();
}
The
CExtPropertyGridCtrl
window contains one or more
CExtPropertyGridWnd
windows. By default, it creates
CExtPropertyGridWndCategorized
and
CExtPropertyGridWndSorted
windows. So, the following code displays which grid is currently displayed in the property grid control:
CExtPropertyGridCtrl & _PGC = . . .
. . .
ASSERT( _PGC.GetSafeHwnd() != NULL );
CWnd * pGridCategorized =
_PGC.GetChildByRTC(
RUNTIME_CLASS(
CExtPropertyGridWndCategorized
)
);
ASSERT_VALID( pGridCategorized );
if( (pGridCategorized->GetStyle()&WS_VISIBLE) != 0 )
::AfxMessageBox( _T("Categorized mode.") );
else
::AfxMessageBox( _T("Sorted mode.") );
You can also use that code to save/restore property grid items. To show the categorized or sorted grid grid, use the following code:
CExtPropertyGridCtrl & _PGC = . . .
. . .
ASSERT( _PGC.GetSafeHwnd() != NULL );
// Show categorized grid
_PGC.SendMessage( WM_COMMAND, __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED );
// Show sorted grid
_PGC.SendMessage( WM_COMMAND, __EXT_MFC_ID_PROPERTY_GRID_SORTED );