From 273be3746990403cd16f7d44f21754a6460841e6 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 23 Jul 2019 13:22:30 +0200 Subject: [PATCH] Reapply image list fix for extra space besides top items in main menu, after form translation has taken place --- source/extra_controls.pas | 18 ++++++++++++++++-- source/main.dfm | 1 + source/main.pas | 4 ---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/source/extra_controls.pas b/source/extra_controls.pas index 297db8fd..337e2cb7 100644 --- a/source/extra_controls.pas +++ b/source/extra_controls.pas @@ -4,7 +4,7 @@ interface uses Classes, SysUtils, Forms, Windows, Messages, System.Types, StdCtrls, Clipbrd, - SizeGrip, apphelpers, Vcl.Graphics, Vcl.Dialogs, gnugettext; + SizeGrip, apphelpers, Vcl.Graphics, Vcl.Dialogs, gnugettext, Vcl.ImgList; type // Form with a sizegrip in the lower right corner, without the need for a statusbar @@ -32,11 +32,25 @@ implementation { TExtForm } constructor TExtForm.Create(AOwner: TComponent); +var + OldImageList: TCustomImageList; begin inherited; + InheritFont(Font); HasSizeGrip := False; - TranslateComponent(Self); + + // Translation and related fixes + // Issue #557: Apply images *after* translating main menu, so top items don't get unused + // space left besides them. + if (Menu <> nil) and (Menu.Images <> nil) then begin + OldImageList := Menu.Images; + Menu.Images := nil; + TranslateComponent(Self); + Menu.Images := OldImageList; + end else begin + TranslateComponent(Self); + end; end; diff --git a/source/main.dfm b/source/main.dfm index e5588764..fb86adaa 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -1985,6 +1985,7 @@ object MainForm: TMainForm end object MainMenu1: TMainMenu AutoHotkeys = maManual + Images = VirtualImageListMain Left = 424 Top = 152 object MainMenuFile: TMenuItem diff --git a/source/main.pas b/source/main.pas index b7ea10de..35ec1bb5 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1682,10 +1682,6 @@ begin // Load preferred ImageCollection into VirtualImageList PrepareImageList; - // Issue #557: Apply images *after* translating main menu, so top items don't get unused - // space left besides them. - MainMenu1.Images := VirtualImageListMain; - if AppSettings.ReadBool(asToolbarShowCaptions) then begin for i:=0 to ToolBarMainButtons.ButtonCount-1 do begin if ToolBarMainButtons.Buttons[i].Style = tbsSeparator then