1
0
Эх сурвалжийг харах

Minimizing command-line operation now correctly minimizes all windows

Like clicking "Minimize" on Progress window over Synchronization progress window over Synchronization checklist window.

Problem revealed after 6f2e21efc9d.

Source commit: dbf9620443433ca4e391182e025825863db5edac
Martin Prikryl 7 жил өмнө
parent
commit
9411a657e2

+ 1 - 0
source/forms/CustomScpExplorer.cpp

@@ -821,6 +821,7 @@ void __fastcall TCustomScpExplorerForm::RefreshQueueItems()
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::SetTaskbarListProgressState(TBPFLAG Flags)
 {
+  // Could now use Application->MainFormHandle, now that we implement Application->OnGetMainFormHandle
   FTaskbarList->SetProgressState(GetMainForm()->Handle, Flags);
 }
 //---------------------------------------------------------------------------

+ 1 - 0
source/windows/VCLCommon.cpp

@@ -378,6 +378,7 @@ void __fastcall ReadOnlyControl(TControl * Control, bool ReadOnly)
   }
 }
 //---------------------------------------------------------------------------
+// Some of MainFormLike code can now be obsolete, thanks to Application->OnGetMainFormHandle.
 static TForm * MainLikeForm = NULL;
 //---------------------------------------------------------------------------
 TForm * __fastcall GetMainForm()

+ 14 - 0
source/windows/WinInterface.cpp

@@ -1378,6 +1378,7 @@ static void __fastcall DoApplicationMinimizeRestore(bool Minimize)
     if (Minimize)
     {
       PreviousWindowState = MainLikeForm->WindowState;
+      // This works correctly with child windows thanks to Application->OnGetMainFormHandle
       MainLikeForm->WindowState = wsMinimized;
     }
     else
@@ -1554,6 +1555,18 @@ HANDLE TCallstackThread::DoCreateEvent()
 //---------------------------------------------------------------------------
 std::unique_ptr<TCallstackThread> CallstackThread;
 //---------------------------------------------------------------------------
+static void __fastcall AppGetMainFormHandle(void * /*Data*/, HWND & Handle)
+{
+  TForm * MainForm = GetMainForm();
+  // This, among other, causes minimizing of the top-level non-MainForm minimize other child windows.
+  // Like clicking "Minimize" on Progress window over Synchronization progress window over Synchronization checklist window.
+  // Would also have a lot of other effects (hopefully possitive) and may render lot of existing MainFormLike code obsolete.
+  if ((MainForm != NULL) && IsMainFormLike(MainForm) && MainForm->HandleAllocated())
+  {
+    Handle = MainForm->Handle;
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall WinInitialize()
 {
   if (JclHookExceptions())
@@ -1567,6 +1580,7 @@ void __fastcall WinInitialize()
   SetErrorMode(SEM_FAILCRITICALERRORS);
   OnApiPath = ApiPath;
   MainThread = GetCurrentThreadId();
+  Application->OnGetMainFormHandle = MakeMethod<TGetHandleEvent>(NULL, AppGetMainFormHandle);
 
 #pragma warn -8111
 #pragma warn .8111