View Issue Details

IDProjectCategoryView StatusLast Update
0035972LazarusLCLpublic2019-08-16 09:08
Reporterdmz73Assigned To 
Status newResolutionopen 
Platformx86_64OSWindowsOS Version10
Product Version2.0.4Product Build 
Target VersionFixed in Version 
Summary0035972: function MenuItemSize calls MeasureItem with 0 values for Width and Height
Descriptionfunction MenuItemSize in lcl\interfaces\win32\win32wsmenus.pp calls AMenuItem.MeasureItem and passes 0 as initial Width and Height.
This means that user must replicate the same code that function MenuItemSize will use if AMenuItem.MeasureItem does not return true.
It would be much better to calculate default values for Width and Height and pass those to AMenuItem.MeasureItem which can then return new values if required.
This way menu items can be enlarged if required and left as default size in other cases.
Alternatively default calculation for Width and Height could be provided in separate function that user could call without having to replicate the code from MenuItemSize function.
Steps To ReproduceCreate GUI application with 1 form and place a MainMenu on the form.
Add few menu items to MainMenu.
Set MainMenu.OwnerDraw to true.
Add event handler for MainMenu.OnMeasureItem.
Do nothing in the event.
Main menu is drawn incorrectly and menu items are not drawn at all.
Additional InformationPossible change:

function MenuItemSize(AMenuItem: TMenuItem; AHDC: HDC): TSize;
  CC: TControlCanvas;
  ParentMenu: TMenu;
  CC := TControlCanvas.Create;
    CC.Handle := AHDC; := 0; := 0;

    if IsVistaMenu then
      if AMenuItem.IsInMenuBar then
        Result := VistaBarMenuItemSize(AMenuItem, AHDC)
        Result := VistaPopupMenuItemSize(AMenuItem, AHDC);
      Result := ClassicMenuItemSize(AMenuItem, AHDC);

TagsNo tags attached.
Fixed in Revision
Attached Files


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2019-08-16 09:08 dmz73 New Issue
2019-08-16 09:08 dmz73 Issue generated from: 0035971