mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
Issue 2443 – Message boxes from secondary windows (like the internal editor) caused application to move to the background when when the main window was minimized
https://winscp.net/tracker/2443 Source commit: 7e4d41de3b099802ec2f4b64d7d7e9dc7d71af6b
This commit is contained in:
@@ -7886,7 +7886,7 @@ void __fastcall TCustomScpExplorerForm::WMQueryEndSession(TMessage & Message)
|
||||
void __fastcall TCustomScpExplorerForm::WMEndSession(TWMEndSession & Message)
|
||||
{
|
||||
AppLog(L"Windows session end");
|
||||
if (Message.EndSession && IsApplicationMinimized())
|
||||
if (Message.EndSession && IsMainFormMinimized())
|
||||
{
|
||||
// WORKAROUND
|
||||
// TApplication.WndProc() calls Application.Terminate() before Halt(),
|
||||
@@ -8182,7 +8182,7 @@ void __fastcall TCustomScpExplorerForm::QueueEvent(TManagedTerminal * ATerminal,
|
||||
UnicodeString Message;
|
||||
TNotifyEvent OnClick = NULL;
|
||||
TObject * UserData = NULL;
|
||||
bool QueueInvisible = !ComponentVisible[fcQueueView] || IsApplicationMinimized();
|
||||
bool QueueInvisible = !ComponentVisible[fcQueueView] || IsMainFormMinimized();
|
||||
switch (Event)
|
||||
{
|
||||
case qeEmptyButMonitored:
|
||||
@@ -10571,7 +10571,7 @@ void __fastcall TCustomScpExplorerForm::LockWindow(bool Force)
|
||||
// minimize is no longer possible
|
||||
// ("keep up to date" dialog - though does not seem to be the case with "find file" -
|
||||
// so it has probably something to do with the semi-modalness of the "keep up to date" dialog)
|
||||
// Shouldn't we use IsApplicationMinimized() here?
|
||||
// Shouldn't we use IsMainFormMinimized() here?
|
||||
if ((FLockSuspendLevel == 0) && !IsIconic(Application->Handle) && (Force || (Screen->ActiveForm == this)))
|
||||
{
|
||||
AppLog(L"Disabling window");
|
||||
|
||||
@@ -115,7 +115,7 @@ __fastcall TProgressForm::~TProgressForm()
|
||||
|
||||
ClearGlobalMinimizeHandler(GlobalMinimize);
|
||||
|
||||
if (IsApplicationMinimized() && FMinimizedByMe)
|
||||
if (IsMainFormMinimized() && FMinimizedByMe)
|
||||
{
|
||||
ShowNotification(
|
||||
NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)),
|
||||
@@ -408,7 +408,7 @@ bool __fastcall TProgressForm::ReceiveData(bool Force, int ModalLevelOffset)
|
||||
// Delay showing the progress until the application is restored,
|
||||
// otherwise the form popups up unminimized.
|
||||
// See solution in TMessageForm::CMShowingChanged.
|
||||
if (!IsApplicationMinimized() &&
|
||||
if (!IsMainFormMinimized() &&
|
||||
(Force || (MilliSecondsBetween(Now(), FStarted) > DelayStartInterval)))
|
||||
{
|
||||
FDataReceived = true;
|
||||
|
||||
@@ -514,7 +514,7 @@ void __fastcall TSynchronizeDialog::Stop()
|
||||
OnlyStop();
|
||||
UpdateControls();
|
||||
Repaint();
|
||||
if (IsApplicationMinimized() && FMinimizedByMe)
|
||||
if (IsMainFormMinimized() && FMinimizedByMe)
|
||||
{
|
||||
FMinimizedByMe = false;
|
||||
ApplicationRestore();
|
||||
|
||||
@@ -55,7 +55,7 @@ __fastcall TSynchronizeProgressForm::~TSynchronizeProgressForm()
|
||||
ReleaseAsModal(this, FShowAsModalStorage);
|
||||
UnhookFormActivation(this);
|
||||
|
||||
if (IsApplicationMinimized() && FMinimizedByMe)
|
||||
if (IsMainFormMinimized() && FMinimizedByMe)
|
||||
{
|
||||
ShowNotification(
|
||||
NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)),
|
||||
@@ -71,7 +71,7 @@ void __fastcall TSynchronizeProgressForm::Start()
|
||||
StartTimeLabel->Caption = FStartTime.TimeString();
|
||||
OperationProgress->Position = OperationProgress->Min;
|
||||
UpdateControls();
|
||||
if (!IsApplicationMinimized())
|
||||
if (!IsMainFormMinimized())
|
||||
{
|
||||
// Do not show the progress when the application is minimized,
|
||||
// otherwise the form popups up unminimized.
|
||||
|
||||
@@ -1026,7 +1026,7 @@ void __fastcall TTerminalManager::QueueStatusUpdated()
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TTerminalManager::ShouldDisplayQueueStatusOnAppTitle()
|
||||
{
|
||||
bool Result = IsApplicationMinimized();
|
||||
bool Result = IsMainFormMinimized();
|
||||
if (!Result && (ScpExplorer != NULL))
|
||||
{
|
||||
HWND Window = GetActiveWindow();
|
||||
|
||||
@@ -1391,16 +1391,22 @@ void __fastcall ApplicationRestore()
|
||||
DoApplicationMinimizeRestore(false);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall IsApplicationMinimized()
|
||||
bool IsMainFormMinimized()
|
||||
{
|
||||
// VCL help recommends handling Application->OnMinimize/OnRestore
|
||||
// for tracking state, but OnRestore is actually not called
|
||||
// (OnMinimize is), when app is minimized from e.g. Progress window
|
||||
// (OnMinimize is), when app is minimized from e.g. Progress window.
|
||||
// Checking Application->Handle might be obsolete.
|
||||
bool AppMinimized = IsIconic(Application->Handle);
|
||||
bool MainFormMinimized = IsIconic(Application->MainFormHandle);
|
||||
return AppMinimized || MainFormMinimized;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool IsApplicationMinimized()
|
||||
{
|
||||
return (Screen->ActiveForm != nullptr) && IsIconic(Screen->ActiveForm->Handle);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall HandleMinimizeSysCommand(TMessage & Message)
|
||||
{
|
||||
TWMSysCommand & SysCommand = reinterpret_cast<TWMSysCommand &>(Message);
|
||||
|
||||
@@ -537,7 +537,8 @@ int __fastcall AdjustLocaleFlag(const UnicodeString & S, TLocaleFlagOverride Loc
|
||||
void __fastcall SetGlobalMinimizeHandler(TCustomForm * Form, TNotifyEvent OnMinimize);
|
||||
void __fastcall ClearGlobalMinimizeHandler(TNotifyEvent OnMinimize);
|
||||
void __fastcall CallGlobalMinimizeHandler(TObject * Sender);
|
||||
bool __fastcall IsApplicationMinimized();
|
||||
bool IsMainFormMinimized();
|
||||
bool IsApplicationMinimized();
|
||||
void __fastcall ApplicationMinimize();
|
||||
void __fastcall ApplicationRestore();
|
||||
bool __fastcall HandleMinimizeSysCommand(TMessage & Message);
|
||||
|
||||
Reference in New Issue
Block a user