Solved

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

Posted on 2010-11-09
2
419 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

12 Experts available now in Live!

Get 1:1 Help Now