Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-27
5
Medium Priority
?
363 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

721 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