델파이 부분 :인터페이스 객체를 파스칼 스크립트 함수 호출에 전달하는 방법은 무엇입니까?
나는 이벤트와 클래스를 가지고 그 사건에서 나는 그것에 인터페이스 객체를 전달하는 프로 시저를 호출 할 필요가있다. 그것은 델파이에서 잘 작동하지만 파스칼 스크립트에서 선언하는 데 문제가 있습니다. 배경으로
일 -IGPGraphics
인터페이스는
Delphi GDI+ library
의 일부 및 방법없이 다음과 같이 정의된다 :
type
IGdiplusBase = interface
['{24A5D3F5-4A9B-42A2-9F60-20825E2740F5}']
IGPGraphics = interface(IGdiPlusBase)
['{57F85BA4-CB01-4466-8441-948D03588F54}']
다음은 내가 파스칼 스크립트에서해야 할 일을 단지 단순화 델파이 의사입니다 :
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;
파스칼 스크립트 편집 부분 :
내 목표는 파스칼 스크립트에서 이벤트를 사용할 수있는 클래스를 갖게하고 그 인터페이스 된 객체를 위에서와 같은 프로 시저로 전달해야하기 때문에 처음으로 컴파일 시간을 선언하려고 시도했습니다. (하지만 저는 아닙니다. 심지어는) 그렇게 할 수있는 올바른 방법이 있는지 있다면 :
// 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;
파스칼 스크립트 실행 부분 : 나는 확실히 잃었어요
런타임 부분입니다. 나는 호출 스택에서 인터페이스 객체를 얻는 방법을 알아 내 RenderObject 절차에 전달할 수 없습니다
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;
그리고 질문은 :는
는 사람이 어떻게 저를 제안 할 수 올바르게이 경우에 대한 컴파일 및 런타임 부분을 정의하거나 어떻게 든 인터페이스 객체를 전달하면서 수정합니까?
P. 그 Inno-Setup 태그에 대해 미안하지만 어쩌면 누군가 에서 InnoSetup을 사용자 정의하려고 시도했습니다.
고맙습니다.