Browse Source

check index of monitor

circular17 3 years ago
parent
commit
27f6d2c39b
1 changed files with 8 additions and 1 deletions
  1. 8 1
      lazpaint/ucommandline.pas

+ 8 - 1
lazpaint/ucommandline.pas

@@ -5,7 +5,7 @@ unit UCommandline;
 
 
 interface
 interface
 
 
-uses classes, LazpaintType, uresourcestrings;
+uses classes, LazpaintType, uresourcestrings, LCLStrConsts;
 
 
 {$IFDEF WINDOWS}
 {$IFDEF WINDOWS}
   {$DEFINE SHOW_MANUAL_IN_WINDOW}
   {$DEFINE SHOW_MANUAL_IN_WINDOW}
@@ -237,6 +237,13 @@ var
         errorEncountered := true;
         errorEncountered := true;
         exit(false);
         exit(false);
       end;
       end;
+      if (screenIndex < 0) or (screenIndex >= Screen.MonitorCount) then
+      begin
+        instance.ShowError('Screenshot', '"Screenshot" ' +
+                                         lclstrconsts.rsListIndexExceedsBounds.Replace('%d', inttostr(screenIndex)));
+        errorEncountered := true;
+        exit(false);
+      end;
       r := Screen.Monitors[screenIndex].BoundsRect;
       r := Screen.Monitors[screenIndex].BoundsRect;
       r := rect(r.Left*CanvasScale, r.Top*CanvasScale,
       r := rect(r.Left*CanvasScale, r.Top*CanvasScale,
                 r.Right*CanvasScale, r.Bottom*CanvasScale);
                 r.Right*CanvasScale, r.Bottom*CanvasScale);