Avatar of Norm-al
Norm-al
Flag for United States of America asked on

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

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

Delphi

Avatar of undefined
Last Comment
Emmanuel PASQUIER

8/22/2022 - Mon
Ephraim Wangoya

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
ASKER CERTIFIED SOLUTION
Emmanuel PASQUIER

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck