diff --git a/lcl/interfaces/win32/win32proc.pp b/lcl/interfaces/win32/win32proc.pp index 00bbb4487e..f161789d30 100644 --- a/lcl/interfaces/win32/win32proc.pp +++ b/lcl/interfaces/win32/win32proc.pp @@ -48,6 +48,7 @@ Type List: TStrings; StayOnTopList: TFPList; // a list of windows that were normalized when showing modal MaxLength: integer; + RestoreState: LongInt; // restore window state MouseX, MouseY: smallint; // noticing spurious WM_MOUSEMOVE messages DispInfoTextA: array [0..LV_DISP_INFO_COUNT-1] of AnsiString; // buffer for ListView LVN_GETDISPINFO notification DispInfoTextW: array [0..LV_DISP_INFO_COUNT-1] of WideString; // it's recommended to keep buffer unchanged diff --git a/lcl/interfaces/win32/win32wsforms.pp b/lcl/interfaces/win32/win32wsforms.pp index 5d48ec0c89..a12465d71c 100644 --- a/lcl/interfaces/win32/win32wsforms.pp +++ b/lcl/interfaces/win32/win32wsforms.pp @@ -365,6 +365,32 @@ begin SetMinMaxInfo(WinControl, PMINMAXINFO(LParam)^); Exit(CallDefaultWindowProc(Window, Msg, WParam, LParam)); end; + WM_SHOWWINDOW: + begin + // this happens when parent window is being minized/restored + // an example of parent window can be an Application.Handle window if MainFormOnTaskBar = False + case LParam of + SW_PARENTCLOSING: + begin + if IsIconic(Window) then + Info^.RestoreState := SW_SHOWMINNOACTIVE + else + if IsZoomed(Window) then + Info^.RestoreState := SW_SHOWMAXIMIZED + else + Info^.RestoreState := SW_SHOWNOACTIVATE; + end; + SW_PARENTOPENING: + begin + if Info^.RestoreState <> 0 then + begin + Windows.ShowWindow(Window, Info^.RestoreState); + Info^.RestoreState := 0; + Exit(CallDefaultWindowProc(Window, Msg, WParam, LParam)); + end; + end; + end; + end; end; Result := WindowProc(Window, Msg, WParam, LParam); end;