Solved

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

Posted on 2006-11-27
5
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

617 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