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

Bo Berglund bo.berglund at gmail.com
Fri Feb 12 22:34:45 CET 2021


On Fri, 12 Feb 2021 21:23:19 +0100, Jean SUZINEAU via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>Le 12/02/2021 à 17:39, Bo Berglund via lazarus a écrit :
>>    Application.QueueAsyncCall(@CopyScreenRect(0), 0); // <== ERROR here
>
>I'm not sure, but QueueAsyncCall just need the address of your callback:
>
>Application.QueueAsyncCall(@CopyScreenRect, 0);
>
>The 0 given to QueueAsyncCall will end up as the Value passed as arg 
>parameter to your CopyScreenRect method when it will called.

I changed the code by removing the argument and it resulted in this error
message:

formmain.pas(149,45) Error: Incompatible type for arg no. 1: Got "<procedure
variable type of procedure(LongInt) of object;Register>", expected "<procedure
variable type of procedure(Int64) of object;Register>"

Code:

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

After changing the argument to int64 as follows:

procedure TfrmMain.CopyScreenRect(arg: int64);

then the code built and the shadow of the menu item was no longer present in the
snatched image!

So thanks for the suggestion, I will take out the sleep() command.

-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list