From 39a13d91bb6b1f2aef0904628cdb88f369586f66 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Tue, 5 Jul 2022 15:06:47 +0200 Subject: [PATCH] LCL/Win32: Fix opening popup menu when Application.MainForm does not exist. Issue #39451. Patches by DeerLab and Iret Company. --- lcl/interfaces/win32/win32callback.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index 43507a0a22..8c52e9249b 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -2099,7 +2099,8 @@ begin begin TargetObject := GetPopMenuItemObject; // Check if the menu was the maximized icon menu for an MDI child window and ignore it in that case - if (LoWord(LParam)=0) and (lWinControl=Application.MainForm) and (Application.MainForm.FormStyle=fsMDIForm) then + if (LoWord(LParam)=0) and (lWinControl=Application.MainForm) and + Assigned(Application.MainForm) and (Application.MainForm.FormStyle=fsMDIForm) then begin MaximizedActiveChild := False; if SendMessage(Win32WidgetSet.MDIClientHandle, WM_MDIGETACTIVE, 0, Windows.WPARAM(@MaximizedActiveChild)) <> 0 then @@ -2121,7 +2122,8 @@ begin begin TargetObject := GetMenuItemObject((HIWORD(Integer(WParam)) and MF_POPUP) <> 0); // Check if the menu was the maximized icon menu for an MDI child window and ignore it in that case - if (LoWord(Integer(WParam))=0) and (lWinControl=Application.MainForm) and (Application.MainForm.FormStyle=fsMDIForm) then + if (LoWord(Integer(WParam))=0) and (lWinControl=Application.MainForm) and + Assigned(Application.MainForm) and (Application.MainForm.FormStyle=fsMDIForm) then begin MaximizedActiveChild := False; if SendMessage(Win32WidgetSet.MDIClientHandle, WM_MDIGETACTIVE, 0, Windows.WPARAM(@MaximizedActiveChild)) <> 0 then