Solved

How to destroy an activex object?

Posted on 2011-03-16
3
927 Views
Last Modified: 2012-05-11
Hi,

I am using an imaging ActiveX control called TImageMan.  I've placed one TImageMan control on the form.  From that  component, I create many instances "on the fly."  I add a row and column number to the end of "IM" ( e.g IM11, IM12, IM21,IM22) to make each instance unique.  See code  below.


How do I destroy the instances of TImageMan (IM11, IM12, IM21, IM22, etc...?) so I can rerun the program multiple times without closing it down?

Thanks.
type
TForm1 = class(TForm)
    IM: TImageMan;

procedure....
var
  IM : TImageMan;
.
.
.
IM :=  TImageMan.Create(self);
IM.Name := 'IM'+IntToStr(i)+IntToStr(j);
.
.
end;

Open in new window

0
Comment
Question by:IT79637
[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 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
ID: 35148994
Use for loop and free all of them:

procedure....
var
  IM : TImageMan;
.
.
.
IM :=  TImageMan.Create(self);
IM.Name := 'IM'+IntToStr(i)+IntToStr(j);
.
.
//var
//  k,l : integer;
for k := 1 to i do
  for l := 1 to j do
    begin
      (FindComponent('IM'+IntToStr(k)+IntToStr(l)) as TImageMan).Free;
    end;
end;
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35149767

You dont need to destroy the components since the are owned by the form

IM :=  TImageMan.Create(self);

When the form is destroyed, the component is destroyed as well, so you dont have to worry about it
0
 
LVL 1

Author Closing Comment

by:IT79637
ID: 35160118
Works for me!
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
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…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

623 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