?
Solved

Creating ActiveX objects on the fly

Posted on 1998-07-10
4
Medium Priority
?
187 Views
Last Modified: 2010-05-18
I wish to create ActiveX objects on the fly using Delphi 3 using only their GUID. If I create a form containing a TOleContainer object I can use this to host an ActiveX object. However I don't know the number of ActiveX objects I wish to host at design time and creating TOleContainer objects on the fly using TOleContainer.Create seems to fail. How can I solve this problem ?
0
Comment
Question by:rowem
[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
4 Comments
 
LVL 2

Expert Comment

by:freter
ID: 1357661
Hi rowem! Try this:

procedure TForm1.Button1Click(Sender: TObject);
var Cont: TOleContainer;
begin
  Cont := TOleContainer.Create(self);
  with cont do begin
    parent := self;
    left := 50;
    top := 50;
    width := 200;
    height := 300;
    visible := true;
    CreateObject('word.application', false);
    DoVerb(ovShow);
  end;
end;

This code creates OleContainers without any problems.
Cheers,
Freter
0
 
LVL 2

Expert Comment

by:freter
ID: 1357662
Ah, BTW: The DoVerb(ovShow) doesn't work with Word.Application... Sorry!
Check it out with any ActiveForm that you have created using Delphi. It works out alright, I have tried it myself.

Regards, Freter
0
 

Author Comment

by:rowem
ID: 1357663
Freter,

If you would like the points please feel free to submit this as the answer. The Parent:=Self is what I hadn't done. I would have thought that the parent should be set in the Create constructor though, since we pass it through as a parameter....

Regards, Michael
0
 
LVL 2

Accepted Solution

by:
freter earned 200 total points
ID: 1357664
Hi Michael!

To set the parent is always neccessary and to forget it is the most common mistake when creating objects on the fly ;-)

Nevertheless, glad I could help.

Freter
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

762 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