On 2015-03-13 13:35, Dmitry Boyarintsev wrote:
> BUT, it would only work, if you're using COM interfaces (wont work corba).
Sorry, but that is a false statement. It works for both COM and CORBA
interfaces. Simply don't use the 'as' syntax - just cast it.
Attached is an example project showing both COM and CORBA works fine.
Simply toggle the DEFINE at the top of the code.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
program test;
{$mode objfpc}{$H+}
// Which interface type are we using. Enable for COM interface
{.$define UseCom}
{$ifdef UseCom}
{$interfaces com}
{$else}
{$interfaces corba}
{$endif}
uses
Classes,
SysUtils;
type
IMyInterface = interface
end;
TMyObject = class({$ifdef UseCom}TInterfacedObject{$else}TObject{$endif}, IMyInterface)
public
procedure SayHello;
end;
procedure TMyObject.SayHello;
begin
writeln('Hello from the object');
end;
var
LIntfRef: IMyInterface;
LObj: TMyObject;
begin
{ Create an interfaced object and extract an interface from it. }
LIntfRef := TMyObject.Create();
{ Cast the interface back to the original object. }
LObj := TMyObject(LIntfRef);
if Assigned(LObj) then
begin
writeln('Pass: we got the object');
LObj.SayHello;
end
else
writeln('Fail: we could not get the object instance');
end.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus