Solved

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

Posted on 2006-11-27
5
320 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

23 Experts available now in Live!

Get 1:1 Help Now