Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-02

Parameter types for events

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

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?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mattias Gaertner
to Mark Morgan Lloyd
Show quoted text 13 lines
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);

Mattias

Reply by email

Mark Morgan Lloyd
to Mattias Gaertner
Mattias Gaertner wrote 33 lines
On Thu, 19 Feb 2015 09:34:29 +0000 Mark Morgan Lloyd 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]

Reply by email

zeljko
to Mark Morgan Lloyd: I've got these methods procedure OnAfterShow(afterShowParam: LONGINT); procedure…
Mark Morgan Lloyd wrote 13 lines
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?

You must use PtrInt.

z.

Reply by email