Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8241083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:42:54+00:00 2026-06-07T20:42:54+00:00

Delphi part: I have a class with the event and from that event I

  • 0

Delphi part:

I have a class with the event and from that event I need to call a procedure passing the interfaced object to it. It works fine in Delphi but I have problems with declaring it in Pascal Script.

To the background – the IGPGraphics interface is a part of the Delphi GDI+ library and without methods is defined like this:

type
  IGdiplusBase = interface
  ['{24A5D3F5-4A9B-42A2-9F60-20825E2740F5}']
  IGPGraphics = interface(IGdiPlusBase)
  ['{57F85BA4-CB01-4466-8441-948D03588F54}']

The following is just a simplified Delphi pseudocode of what I need to do in Pascal Script:

type
  TRenderEvent = procedure(Sender: TObject; const GPGraphics: IGPGraphics) of object;
  TRenderClass = class(TGraphicControl)
  private
    FOnRender: TRenderEvent;
  public
    property OnRender: TRenderEvent read FOnRender write FOnRender;
  end;

// when the TRenderClass object instance fires its OnRender event I want to call 
// the RenderObject procedure passing the IGPGraphics interfaced object to it; I
// hope I'm doing it right, I'm just a newbie to this stuff - but it works so far
// in Delphi (since I didn't get it to work in Pascal Script)

procedure TForm1.RenderClass1Render(Sender: TObject; const GPGraphics: IGPGraphics);
begin
  RenderObject(GPGraphics, 10, 10);
end;

// what I need in Pascal Script is between these two lines; just pass the interface
// object from the event fired by component to the procedure called from inside it

procedure RenderObject(const GPGraphics: IGPGraphics; X, Y);
begin
  // and here to work with the interfaced object somehow
end;

Pascal Script compilation part:

My aim is to have the class with event available in Pascal Script and need to pass that interfaced object to that procedure just like above, so the first I’ve tried to declare for the compilation time this (but I’m not even sure if that’s the right way to do so):

// the interface
PS.AddInterface(Cl.FindInterface('IUnknown'), StringToGuid('{57F85BA4-CB01-4466-8441-948D03588F54}'), 'IGPGraphics');
// the type for the event
PS.AddTypeS('TRenderEvent', 'procedure(Sender: TObject; const GPGraphics: IGPGraphics)');
// and the class with the event itself
with PS.AddClassN(PS.FindClass('TGraphicControl'), 'TRenderClass') do
begin
  RegisterProperty('OnRender', 'TRenderEvent', iptrw);
end;

Pascal Script runtime part:

Where I’m definitely lost is the runtime part. I can’t figure out how to get the interfaced object from the call stack and pass it to my RenderObject procedure:

function RenderClassProc(Caller: TPSExec; Proc: TPSExternalProcRec; Global, 
  Stack: TPSStack): Boolean;
var
  PStart: Cardinal;
begin
  PStart := Stack.Count-1;
  Result := True;
  if Proc.Name = 'RENDEROBJECT' then
  begin
    // how do I get the interfaced object from Stack (or whatever else) and pass 
    // it to the RenderObject proc here ? I can't find anything related about it
    // except functions that has no parameter index
    RenderObject(Stack.Get ?, Stack.GetInt(PStart-2), Stack.GetInt(PStart-3));
  end;
end;

And the question is:

Can anyone suggest me how to correctly define compilation and runtime part for this case or correct me with passing the interfaced object somehow ?

P.S. sorry for that Inno-Setup tag but maybe someone from there tried to customize InnoSetup this way.

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:42:56+00:00Added an answer on June 7, 2026 at 8:42 pm

    If I understand what you’re asking, you want to pass an interface as a parameter to a method. Unfortunately, I don’t have an exact answer to that, but I do know how to assign an interface to a global variable for PascalScript. Here’s how I do it in Castalia:

    In the PSScript OnCompile event, add the interface with PS.Comp.AddInterface, and then add each of the necessary methods. After that, add a variable of the interface type. It looks like this, for example:

    with PS.Comp.AddInterface(ARunner.Comp.FindInterface('IUnknown'),
      StringToGUID('{0346F7DF-CA7B-4B15-AEC9-2BDD680EE7AD}'),
      'ICastaliaMacroClipboardAccess') do
    begin
      RegisterMethod('function GetText: string', cdRegister);
      RegisterMethod('procedure SetText(AText: string)', cdRegister);
    end;
    PS.AddRegisteredVariable('Clipboard', 'ICastaliaMacroClipboardAccess');
    

    Then, in the OnExectute event, bind the previously created variable to the instance:

    P := PS.GetVariable('Clipboard'); //P is type PIFVariant
    SetVariantToInterface(P, Implementing object as ICastaliaMacroClipboardAccess);    
    

    Having done that, the script has access to the interfaced object through the variable, so in this instance, the script could contain a call to Clipboard.GetText, and it works as you would expect.

    That is tested and works.

    Now, I would speculate that you might be able to use TPSScript.ExecuteFunction, passing in the PIFVariant from above, to get closer to what you want. That is not something I’ve tested, however.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this code works fine: procedure TForm2.Timer1Timer(Sender: TObject); var Text: string; begin SetLength (Text,555); GetWindowText
I have a Delphi app that references a datafile of 28-byte records. The file
I have a Delphi unit that is statically linking a C .obj file using
I have a Delphi 5 executable that calls into a .NET assembly via the
I have a Base64 binary string that is part of an XML document that
I have an application that I have converted to Delphi 2009 I have String
I have a need of implementing two apps that will exchange data with each
This is for Delphi Prism. Say, I have the following enum SET type that
I have TeeChart 8 Standard as part off Delphi XE2, recently asked for advice
I have a binary-only copy of an application written in Delphi 7; as part

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.