View Issue Details

IDProjectCategoryView StatusLast Update
0005370JEDI VCL00 JVCL Componentspublic2010-10-19 21:37
ReporterjkelleyAssigned Tojfudickar 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.39 
Target VersionFixed in Version 
Summary0005370: RestoreFormPlacement may restore windows off screen
DescriptionIf TJvFormPlacement.RestorePlacement or JvJVCLUtils' RestoreFormPlacement is used to restore a form's position and size, then the form may be positioned off screen, if the screen resolution or number of monitors has been reduced since the form's position was saved. (This can happen with a laptop with an external monitor and when using Remote Desktop.)

The attached patch checks that the form's position and size fit on screen and doesn't restore them if they don't.
TagsNo tags attached.

Activities

2010-10-18 23:30

 

RestoreFormPosition-offscreen.patch (1,059 bytes)
Index: JvJVCLUtils.pas
===================================================================
--- JvJVCLUtils.pas	(revision 4533)
+++ JvJVCLUtils.pas	(working copy)
@@ -4030,6 +4030,17 @@
     end;
   end;
 
+  function IsOnAnyMonitor(ARect: TRect) : Boolean;
+  var
+    BottomRight : TPoint;
+  begin
+    BottomRight := ARect.BottomRight;
+    Dec(BottomRight.X);
+    Dec(BottomRight.Y);
+    Result := (Screen.MonitorFromPoint(ARect.TopLeft, mdNull) <> Nil) and
+        (Screen.MonitorFromPoint(BottomRight, mdNull) <> Nil);
+  end;
+
 begin
   if Options = [fpActiveControl] then
     Exit;
@@ -4090,7 +4101,7 @@
       AppStorage.ConcatPaths([StorePath, siPixels]), Screen.PixelsPerInch));
     if DataFound then
     begin
-      if Placement.rcNormalPosition.Right > Placement.rcNormalPosition.Left then
+      if (Placement.rcNormalPosition.Right > Placement.rcNormalPosition.Left) and IsOnAnyMonitor(Placement.rcNormalPosition) then
       begin
         if not (csDesigning in Form.ComponentState) then
         begin

jfudickar

2010-10-19 21:37

developer   ~0017927

Thanks for this patch!

Added to svn Revision 12869

Issue History

Date Modified Username Field Change
2010-10-18 23:30 jkelley New Issue
2010-10-18 23:30 jkelley File Added: RestoreFormPosition-offscreen.patch
2010-10-19 21:37 jfudickar Note Added: 0017927
2010-10-19 21:37 jfudickar Status new => resolved
2010-10-19 21:37 jfudickar Resolution open => fixed
2010-10-19 21:37 jfudickar Assigned To => jfudickar