Solved

how to free or destroy a component on a form before it has been created in delphi

Posted on 2010-11-09
2
439 Views
Last Modified: 2012-05-10
I have 2 applications, Error Processing and Work Order. Both individual applications have dxSpellChecker component in them. The Work Order application calls one of the forms in the Error Processing application and on formCreate I get an exception saying an application can only have 1 instance of dxSpellChecker. So I was going to try to free or destroy the component on create but I can't do it before the create (since it doesnt know it exists yet) and I couldnt do it after create because the exception occurs on the Create line.
Any ideas? Attached code... I get the exception right on the Create(Self)
frmErrorDataEntry1 := TfrmErrorDataEntry1.Create(Self);
  with frmErrorDataEntry1 do begin
    sJobnum      := frmJobErrorsList.sJobnum;
    sPart        := frmJobErrorsList.sPart;
    sContractor  := frmJobErrorsList.sContractor;
    sSalesRep    := frmJobErrorsList.sSalesRep;
    sJobName     := frmJobErrorsList.sJobName;
    sJobLocation := VarNullToString(frmJobErrorsList.sJobLocation);
    sErrorID     := '0';

Open in new window

0
Comment
Question by:Bianca
[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
2 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34095547
Move the dxSpellChecker to a data module and let both forms access it from there.

You can not destroy a component before its created or loaded
0
 
LVL 25

Accepted Solution

by:
epasquier earned 500 total points
ID: 34096692
by application you mean forms, right ? you merged 2 forms coming from 2 different applications, into one single project ?

if so, yes, as ewangoya said the solution is to move the dxSpellChecker to a common unit. A DataModule is generally used to store those kind of non-visual components that are used like global resources by potentially more than one form.

There are many things in your question that tells me that you are not too sure about a few things, like how components are created with the form containing them, the distinction between application and form as I said, and this cryptic line "So I was going to try to free or destroy the component on create but I can't do it before the create (since it doesnt know it exists yet) ". I think I understand it, differently than ewangoya, as 'you would like to destroy the component on the first form before calling create on the second form'.
That would be possible but I won't go into that details and others things that maybe are only a matter of using wrong vocabulary - because the right solution has been said already.
Unless you ask of course.
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

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month7 days, 7 hours left to enroll

621 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