[Lazarus] Parameter types for events

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Thu Feb 19 11:02:04 CET 2015


Mattias Gaertner wrote:
> On Thu, 19 Feb 2015 09:34:29 +0000
> Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk> wrote:
> 
>> I've got these methods
>>
>>    procedure OnAfterShow(afterShowParam: LONGINT);
>>    procedure OnAfterOverridesVisibleClick(count: LONGINT);
>>
>> which are used like this
>>
>>    Application.QueueAsyncCall(@OnAfterShow, startParam)
>> end { TMainForm.FormCreate } ;
>>
>> On 32-bit systems the parameter type is a longint, but x64 requires Int64.
>>
>> What's the correct type to ensure portability in this case?
> 
> Use "Find declaration" to find out:
> 
>     procedure QueueAsyncCall(const AMethod: TDataEvent; Data: PtrInt);
> 
>   TDataEvent = procedure (Data: PtrInt) of object;
> 
> Or simply let the IDE generate the method for you:
> 
> 1. type the line
> Application.QueueAsyncCall(@MyFunc, Param);
> 
> 2. place cursor on MyFunc
> 3. press complete code (Ctrl+Shift+C)
> 
> This will create the method
>    procedure MyFunc(Data: PtrInt);

Thanks, I was in the middle of tracking down TDataEvent :-)


-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list