Solved

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

Posted on 2010-11-09
2
422 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
2 Comments
 
LVL 32

Expert Comment

by:ewangoya
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 186
indy tidtcpclient threading issue 8 63
Machine not responding during CopyFile() 3 89
Path  to current project in Delphi. 2 72
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

15 Experts available now in Live!

Get 1:1 Help Now