Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…

756 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