Solved

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

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 156
Delphi 2 91
Press three keys together and trigger a function 3 76
firemonkey keyboard covers the controls 1 83
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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