Solved

Creating ActiveX objects on the fly

Posted on 1998-07-10
4
180 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
  • 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 100 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

Highfive Gives IT Their Time Back

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

Suggested Solutions

Title # Comments Views Activity
Master Detail with TADODataset 4 97
JSON on ISAPI REST Server using Delphi 2 210
Delphi XE10, MySQL Query 4 109
Delphi selector screen 2 58
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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

21 Experts available now in Live!

Get 1:1 Help Now