I have created a screen capture utility, which I use a lot but it has a very annoying behaviour:
- I adjust the rect to capture a certain area
- I make the screenshot and put it into the clipboard
- I paste it into my image editor
So far all works fine.
- Next I scroll the window I am capturing images from so that the next section I want to clip is inside the rect.
- Again I take a screenshot
- I paste it into the image editor and see the
previous capture duplicated!
The only way I have found to get around this is to move and resize the capture rect and then move it back and re-adjust to the same size as before.
Then a capture works to get the correct image!
What am I doing wrong here?
My capture function looks like this:
private
FMyCapture: TBgraBitmap;
...
procedure TfrmMain.miCopyImageClick(Sender : TObject);
begin
Sleep(300); //To let the pop-up menu disappear
CopyScreenRect(0);
end;
procedure TfrmMain.CopyScreenRect(arg: PtrInt);
var
Clip: TRect;
X, Y, W, H: integer;
begin
try
Clip := Bounds(frmMain.Left, frmMain.Top, frmMain.Width, frmMain.Height);
X := frmMain.Left;
Y := frmMain.Top;
W := frmMain.Width;
H := frmMain.Height;
frmMain.Visible := false; //Hide the form defining Clip
FMyCapture.TakeScreenShot(Clip);
frmMain.Visible := true;
frmMain.Left := X;
frmMain.Top := Y;
frmMain.Width := W;
frmMain.Height := H;
Clipboard.Assign(FMyCapture.Bitmap);
except
on E: exception do
Clipboard.AsText := E.Message;
end;
end;