A.M. Hoornweg 144 Posted April 5, 2022 Hello all, I have the problem that tMainmenu often fails to re-scale properly if I drag a window from a low-dpi screen to a high-dpi screen. This happens especially if it is a complex menu and it happens with or without a tVirtualImageList attached. The problem occurs on both Windows 10 and 11 (but more frequent on Windows 11). The compiler I use is Delphi 11.1 Alexandria. I am looking for workaround, is there a way to manually re-initialize or re-build the tMainmenu after scaling ? Share this post Link to post
A.M. Hoornweg 144 Posted April 7, 2022 I managed to create a workaround for this. See code below. The mainmenu of the form can be re-initialized by calling "menu.rebuild" . It works best if this is done ~100 ms after the form is re-scaled to the new dpi. type tMenuItemHack = class helper for tMenuItem procedure RebuildMenu; end; tMainmenuHack = class helper for tMainmenu procedure Rebuild; end; procedure tMenuItemHack.RebuildMenu; begin menuchanged(True); //"Protected" method end; procedure tMainmenuHack.Rebuild; var cnt: Integer; item: tMenuItem; begin cnt := items.Count; if cnt > 0 then begin item := items[cnt-1]; item.RebuildMenu;// trigger "menuchanged(True)" on rightmost item (minimize flicker) end; end; 1 Share this post Link to post
Lars Fosdal 1792 Posted April 7, 2022 Do you know if there is a QP report for this issue? Share this post Link to post
A.M. Hoornweg 144 Posted April 7, 2022 I don't know, i'll check it out tomorrow. Share this post Link to post