瀏覽代碼

Bug 1497: Moving Login dialog moves main window disproportionally on some systems

https://winscp.net/tracker/1497
(cherry picked from commit 7132a46fa88451a703f2ad27b5aa9dc3840cc6b1)

Conflicts:
	source/forms/Login.cpp

Source commit: e8b5349de7fbf3cf0ab00b38f5ac405e98c358a7
Martin Prikryl 8 年之前
父節點
當前提交
61f52f5899
共有 2 個文件被更改,包括 10 次插入3 次删除
  1. 9 3
      source/forms/Login.cpp
  2. 1 0
      source/forms/Login.h

+ 9 - 3
source/forms/Login.cpp

@@ -72,6 +72,7 @@ __fastcall TLoginDialog::TLoginDialog(TComponent* AOwner)
   FSortEnablePending = false;
   FSiteSearch = ssSiteName;
   FLinkedForm = NULL;
+  FPrevPos = TPoint(-1, -1);
 
   // we need to make sure that window procedure is set asap
   // (so that CM_SHOWINGCHANGED handling is applied)
@@ -1540,11 +1541,16 @@ void __fastcall TLoginDialog::WMMoving(TMessage & Message)
 
   if (FLinkedForm != NULL)
   {
-    RECT & Rect = *reinterpret_cast<RECT*>(Message.LParam);
+    if (FPrevPos.X < 0)
+    {
+      FPrevPos = BoundsRect.TopLeft();
+    }
+    TRect Rect = *reinterpret_cast<RECT*>(Message.LParam);
     FLinkedForm->SetBounds(
-      FLinkedForm->Left + (Rect.left - Left),
-      FLinkedForm->Top + (Rect.top - Top),
+      FLinkedForm->Left + (Rect.Left - FPrevPos.X),
+      FLinkedForm->Top + (Rect.Top - FPrevPos.Y),
       FLinkedForm->Width, FLinkedForm->Height);
+    FPrevPos = Rect.TopLeft();
   }
 }
 //---------------------------------------------------------------------------

+ 1 - 0
source/forms/Login.h

@@ -308,6 +308,7 @@ private:
   std::unique_ptr<TImageList> FButtonImageList;
   TSiteSearch FSiteSearch;
   TForm * FLinkedForm;
+  TPoint FPrevPos;
 
   void __fastcall LoadSession(TSessionData * SessionData);
   void __fastcall LoadContents();