Re: [Lazarus] ActiveX, TOLEControl

2016-11-28 Thread Jesus Reyes A. via Lazarus
En Wed, 19 Oct 2016 11:07:35 -0500, Dennis via Lazarus  
 escribió:





LacaK via Lazarus wrote:






Hi *,

I need help with OCX component (not visual I guess), which I need use  
in Lazarus application (to control another application, which  
supplies this OCX control).
I have imported type library using importtl.exe (new unit was created  
successfully)


Then in program I have created instance:
  v := CreateOleObject('SCAPS.ScSamlightClientCtrl');
or
  intf := CreateComObject(CLASS_ScSamlightClientCtrl) as  
_DSamlight_client_ctrl_ocx;

What is the type of your V or intf  variable?


V: OLEVariant;
intf: _DSamlight_client_ctrl_ocx;

I am wild guessing maybe they are not proper referenced type so the  
object is created and then immediately freed.


There is something strange behind scene. I have tried various methods:
I remember in Delphi, I sometimes have to call CoInitialize and  
CoUninitialize.

Not sure if FPC has to do the same.
Have you tried that?

Dennis



--
Usando el cliente de correo de Opera: http://www.opera.com/mail/
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] ActiveX, TOLEControl

2016-10-19 Thread LacaK via Lazarus






Hi *,

I need help with OCX component (not visual I guess), which I need use 
in Lazarus application (to control another application, which 
supplies this OCX control).
I have imported type library using importtl.exe (new unit was created 
successfully)


Then in program I have created instance:
  v := CreateOleObject('SCAPS.ScSamlightClientCtrl');
or
  intf := CreateComObject(CLASS_ScSamlightClientCtrl) as 
_DSamlight_client_ctrl_ocx;

What is the type of your V or intf  variable?


V: OLEVariant;
intf: _DSamlight_client_ctrl_ocx;

I am wild guessing maybe they are not proper referenced type so the 
object is created and then immediately freed.


There is something strange behind scene. I have tried various methods:

var
  v1: OLEVariant;
  v2: ScSamlightClientCtrl;
  v: variant;
  ax: TActiveXContainer;
  disp: IDispatch;
  i: integer;

begin
  v1 := CreateOLEObject('SCAPS.ScSamlightClientCtrl');
  i := v1.scIsRunning;  // exception here

  v2 := CoScSamlightClientCtrl.Create;
  i := v2.scIsRunning;  // exception here

  ax := TActiveXContainer.Create(Self);
  //ax.OleClassName := 'SCAPS.ScSamlightClientCtrl';
  CoCreateInstance(CLASS_ScSamlightClientCtrl, nil, 
CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IDispatch, disp);

  ax.ComServer:=disp;
  ax.Active := True;
  v := disp;
  i := v.scIsRunning;  // exception here

So in every case it returns exception when I try call first time 
interface method ...

I am not familiar with ActiveX technology so I have no idea what is wrong ?

-Laco.

--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] ActiveX, TOLEControl

2016-10-19 Thread Dennis via Lazarus



LacaK via Lazarus wrote:

Hi *,

I need help with OCX component (not visual I guess), which I need use 
in Lazarus application (to control another application, which supplies 
this OCX control).
I have imported type library using importtl.exe (new unit was created 
successfully)


Then in program I have created instance:
  v := CreateOleObject('SCAPS.ScSamlightClientCtrl');
or
  intf := CreateComObject(CLASS_ScSamlightClientCtrl) as 
_DSamlight_client_ctrl_ocx;

What is the type of your V or intf  variable?
I am wild guessing maybe they are not proper referenced type so the 
object is created and then immediately freed.


I would try
  v : OLEVariant;
or V :  _DSamlight_client_ctrl_ocx;

Dennis
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] ActiveX, TOLEControl

2016-10-18 Thread LacaK via Lazarus

Hi *,

I need help with OCX component (not visual I guess), which I need use in 
Lazarus application (to control another application, which supplies this 
OCX control).
I have imported type library using importtl.exe (new unit was created 
successfully)


Then in program I have created instance:
  v := CreateOleObject('SCAPS.ScSamlightClientCtrl');
or
  intf := CreateComObject(CLASS_ScSamlightClientCtrl) as 
_DSamlight_client_ctrl_ocx;


But all next attampts using any interface method fail with EOleSysError 
"Catastrophic failure" (ErrorCode=-2147418113)


In Delphi it works, but only when I use TOLEControl descendant created 
by Delphi's import of ActiveX (into _TLB unit)

In Delphi I have :

TScSamlightClientCtrl = class(TOleControl)
...

but in Lazarus I have no equivalent? (When I Delphi I do same as in 
Lazarus I get same error also in Delphi)


I do not know exacly what to ask here ?
What is purpose of TOleControl and what TOleControl did more than I can 
do in Lazarus ?

Can I somehow workaround it in Lazarus ?

In short what I have imported from type lib in Lazarus is interface:
 _DSamlight_client_ctrl_ocx = dispinterface
   ['{05D31AA6-1306-4DA0-9AE2-A8771FF6FA94}']
   function ScIsRunning:Integer;dispid 1;
  ... etc.
end;

and CoClass:
  Class Function CoScSamlightClientCtrl.Create: _DSamlight_client_ctrl_ocx;
  begin
Result := CreateComObject(CLASS_ScSamlightClientCtrl) as 
_DSamlight_client_ctrl_ocx;

  end;

I can create instance calling CoScSamlightClientCtrl.Create, but as I 
wrote I can not use any method ...


Can somebody give any help ?

Thanks

-Laco.


--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus