We have implemented automatically measured popup list boxes in toolbars, menus, ribbons and grid cells. The following methods still can be used for measuring popup list box size but they are invoked before creation of popup menu and list box windows:
- CExtCustomizeSite::OnPopupListBoxMeasureTrackSize()
- used in customizable toolbars and menus
- CExtBarTextFieldButton::OnPopupListBoxMeasureTrackSize()
- used in non customizable toolbars and menus
- CExtRibbonPage::OnPopupListBoxMeasureTrackSize()
- used in ribbon bar and ribbon page
- CExtGridCell::OnPopupListBoxMeasureTrackSize()
- used in all the grid cells
We have implemented new list box measurement methods which are invoked when both popup menu and list box windows are already created but not displayed on the screen:
- CExtCustomizeSite::OnPopupListBoxAdjustSize()
- used in customizable toolbars and menus
- CExtBarTextFieldButton::OnPopupListBoxAdjustSize()
- used in non customizable toolbars and menus
- CExtRibbonPage::OnPopupListBoxAdjustSize()
- used in ribbon bar and ribbon page
- CExtGridCell::OnPopupListBoxAdjustSize()
- used in all the grid cells
The new methods are measuring list box sizes via sending the standard WM_MEASUREITEM()
message for list box items. All the popup list boxes in Prof-UIS are owner draw and by default are painted using classic look of list box items.
In case of customizable toolbars/menus and ribbon controls the maximal size of popup list box can be specified in constructor parameters of the CExtCustomizeCmdTreeNode
or CExtRibbonNode
classes:
CExtCustomizeCmdTreeNode(
UINT nCmdIdBasic = 0L,
UINT nCmdIdEffective = 0L,
CExtCustomizeCmdTreeNode * pParentNode = NULL,
DWORD dwFlags = 0L,
__EXT_MFC_SAFE_LPCTSTR strTextInToolbar = NULL,
__EXT_MFC_SAFE_LPCTSTR strTextInMenu = NULL,
__EXT_MFC_SAFE_LPCTSTR strTextUser = NULL,
LPARAM lParam = 0L,
CExtCmdIcon * pIconCustomized = NULL
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
,
INT nTextFieldWidth = 100,
INT nDropDownWidth = -2, // (-1) - auto calc, (-2) - same as button area
INT nDropDownHeightMax = 250
#endif
);
CExtRibbonNode(
UINT nCmdIdBasic = 0L,
UINT nCmdIdEffective = 0L,
CExtRibbonNode * pParentNode = NULL,
DWORD dwFlags = 0L,
__EXT_MFC_SAFE_LPCTSTR strTextInToolbar = NULL,
__EXT_MFC_SAFE_LPCTSTR strTextInMenu = NULL,
__EXT_MFC_SAFE_LPCTSTR strTextUser = NULL,
LPARAM lParam = 0L,
CExtCmdIcon * pIconCustomized = NULL
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
,
INT nTextFieldWidth = 100,
INT nDropDownWidth = -2, // (-1) - auto calc, (-2) - same as button area
INT nDropDownHeightMax = 250
#endif
);
The
nDropDownWidth
parameter is by default set to
-1
what makes popup list box using width of combo box button in toolbar. You can set it to
-1
for using automatically measured list box width. The
nDropDownHeightMax
parameter is used for specifying maximal height of popup list box. The maximal width and height of all the popup list boxes are also limited by width and height of the monitor’s work area where popup list box menu is displayed. These parameters can be also set using the
CExtCustomizeCmdTreeNode::DropDownWidthSet()
and
CExtCustomizeCmdTreeNode::DropDownHeightMaxSet()
methods.
The grid cell classes does not have list box size options. They are always using popup list box size calculation and make list box width always greater or equal to grid cell width. The list box height is limited by monitor’s work area sizes and the new
CExtGridCell::OnPopupListBoxQueryMaxSize()
virtual method. The
CExtGridCell::TrackCellStateInfo_t
data structure which is used for containing properties of grid cell during tracking of its popup menu is now have new properties:
-
m_bAdjustListBoxWidth
- indicates whether the width of the popup list box menu should be computed from widths of list box items; by default is set to
true
-
m_bAdjustListBoxHeight
- indicates whether the height of the popup list box menu should be computed from heights of list box items; by default is set to
true
-
m_bAlingListBoxWidthToCellWidthMin
- indicates whether the width of the popup list box menu should be greater or equal to grid cell width; by default is set to
true
-
m_bAlingListBoxWidthToCellWidthMax
- indicates whether the width of the popup list box menu should be less or equal to grid cell width; by default is set to
false
If two last properties are set to
true
, then widths of the popup list box menu displayed from grid cell’s drop down button with be the equal to grid cell widths. These properties of the
CExtGridCell::TrackCellStateInfo_t
data structure can be set in the overridden
CExtGridCell::OnPopupListBoxMeasureTrackSize
virtual method before invoking parent class method like in the
CExtGridCellHeaderFilter
class does in Prof-UIS 2.84:
CSize CExtGridCellHeaderFilter::OnPopupListBoxMeasureTrackSize(
CExtGridCell::TrackCellStateInfo_t & _tcsi,
CExtPopupListBoxMenuWnd * pPopup
)
{
ASSERT_VALID( this );
_tcsi.m_bAlingListBoxWidthToCellWidthMin = _tcsi.m_bAlingListBoxWidthToCellWidthMax = false;
return CExtGridCellHeader::OnPopupListBoxMeasureTrackSize( _tcsi, pPopup );
}
In conclusion: now all the popup list box menus in Prof-UIS are using automatically computed sizes by default and this is true even if you have implemented custom measured/painted list box items like the style toolbar button in the
StyleEditor sample application. If the list box contains only a few items, then you will not see blank space below the last displayed item. In case of simple list boxes with/without icons, custom item intents and/or check boxes you need only to insert list box items. In case of custom painted/measured list boxes you should implement painting and measuring virtual methods. In both cases you no longer need to compute entire size of popup list box.
You can drop us an e-mail and we will provide you with the source code update.