[Lazarus] How to hide pop-up menu before taking a screen snapshot?

Bo Berglund bo.berglund at gmail.com
Fri Feb 12 17:39:54 CET 2021


On Fri, 12 Feb 2021 12:51:08 +0100, Luca Olivetti via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>El 12/2/21 a les 11:16, Bo Berglund via lazarus ha escrit:
>ing a bogus extra argument as zero but that just changed to a
>> different error message...
>> 
>> Application.QueueAsyncCall(@CopyScreenRect, 0);
>> 
>> formmain.pas(149,45) Error: Incompatible type for arg no. 1: Got "<procedure
>> variable type of procedure of object;Register>", expected "<procedure variable
>> type of procedure(Int64) of object;Register>"
>
>It's telling you that the expected method should have an integer argument
>> 
>> Copyscreenrect looks like this if that matters:
>> 
>> procedure TfrmMain.CopyScreenRect;
>
>change that to
>
>procedure TfrmMain.CopyScreenRect(dummy:integer);
>
>Bye

  private
    procedure CopyScreenRect(arg: integer);
  public

...

procedure TfrmMain.miCopyImageClick(Sender : TObject);
begin
  //Sleep(300);
  //CopyScreenRect;
  Application.QueueAsyncCall(@CopyScreenRect(0), 0); // <== ERROR here
end;

procedure TfrmMain.CopyScreenRect(arg: integer);
var
  MyCapture : TBgraBitmap;
  Clip: TRect;
begin
  try
    Clip := Bounds(Self.Left, Self.Top, Self.Width, Self.Height);
    Self.Visible := false;
    MyCapture := TBgraBitmap.Create();
    try
      MyCapture.TakeScreenShot(Clip);
      Self.Visible := true;
      Clipboard.Assign(MyCapture.Bitmap);
    finally
      MyCapture.Free;
    end;
  except
    on E: exception do
      Clipboard.AsText := E.Message;
  end;
end;


Now I get this error:
formmain.pas(149,31) Error: Variable identifier expected


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list