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

Patrick Chevalley pch at ap-i.net
Fri Feb 12 22:43:02 CET 2021


The declaration of QueueAsyncCall is:
procedure QueueAsyncCall(const AMethod: TDataEvent; Data: PtrInt);

You must use "arg: PtrInt" otherwise it will fail on a 32bit system.

Patrick


12 février 2021 22:34 "Bo Berglund via lazarus" <lazarus at lists.lazarus-ide.org> a écrit:

> 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
> 
> --
> _______________________________________________
> lazarus mailing list
> lazarus at lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus


More information about the lazarus mailing list