Solved

Delphi ActiveX OCX, how to get access to public variables without chaning the CLSID

Posted on 2006-11-27
5
318 Views
Last Modified: 2010-04-05
Hello all,

I have an ActiveX object  and I want to know how I can get access to its publicly declared variables.  This OCX is already deployed so I don't want to make changes that would affect the CLSID.  

If I embed this object in Microsoft PowerPoint I only get access to the published properties and public methods.  I don't see the public variables from the design mode in PowerPoint.  What changes can be made to access these public variables without causing a change in the CLSID?  

Thank you.
0
Comment
Question by:cyman73
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 18026790
go to project -> import TypeLibrary or Component -> Import Component -> ActiveX (BDS2006)
delphi will generate everything You need.

ziolko.
0
 

Author Comment

by:cyman73
ID: 18049289
Thank you Ziolko for the suggestion.  How does this help with the ActiveX deployment?  How does this help me with Powerpoint?









0
 
LVL 21

Expert Comment

by:ziolko
ID: 18066841
ActiveX components are deployed by using regsv32 xxxx.ocx or xxxx.dll this makes it accessible by delphi type library importer.
when You import type library delphi generates xxxx_TLB.pas file with including all objects and its properties that ActiveX export
those objects are accessible as interfaces or regular delphi objects (if You select Genreate Component Wrapper during import).

If it comes to PowerPoint, check "Server" tab on Your component palette TPowerPointApplication should be there.

ziolko.
0
 

Author Comment

by:cyman73
ID: 18069060
Thanks,

So when you say ..."including all objects and its properties that ActiveX export
those objects are accessible as interfaces or regular delphi objects (if You select Genreate Component Wrapper during import).", this means that the object's properties are not available if the Component Wrapper is not specifically exposing them?

I have the MyActiveX.ocx, I open Microsoft Powerpoint and I place this ActiveX on a slide, now I want to setup the object's properties so I easily have access to them via the Properties Window.  But I also want access to this object's public variables.  So if the Component Wrapper did not expose these variables, you are saying that I cannot get to them otherwise?

If one of the properties was a public boolean bValid I would like to be able to say MyActiveX.bValid := True;, I can't access it unless this was defined as in the properties section?

Thank you.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 18069382
Only way to access public variables is via properties, as I understand MyActiveX.ocx is some library that You wrote. open MyActiveX.tlb editor and add some properties (read/write) delphi will generate Get_ Set_ methods implement them to read/write You variables, this should look like this

in xxx_TLB.pas file:
type
   
     ISampleobject2 = interface(IDispatch)
       ['{FC9618C2-E6F4-4425-AADB-239781C10EDE}']
       function Get_MyProperty: Integer; safecall;
       procedure Set_MyProperty(Value: Integer); safecall;
       property MyProperty: Integer read Get_MyProperty write Set_MyProperty;
    end;


in implementation file:

interface

uses
  ComObj, ActiveX, Project1_TLB, StdVcl;

type
  TSampleobject2 = class(TAutoObject, ISampleobject2)
  private
    FPublicVariable: Integer; <- it's in private section but thanks to property it's accessible as public one
  protected
    function Get_MyProperty: Integer; safecall;
    procedure Set_MyProperty(Value: Integer); safecall;

  end;

implementation

uses ComServ;

function TSampleobject2.Get_MyProperty: Integer;
begin
  Result := FPublicVariable;
end;

procedure TSampleobject2.Set_MyProperty(Value: Integer);
begin
  FPublicVariable := Value;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TSampleobject2, Class_Sampleobject2,
    ciMultiInstance, tmApartment);
end.

ziolko.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now