Article View: comp.lang.pascal.delphi.components.misc
Article #22Re: TForm inside a TThread
From: Sundial Services
Date: Fri, 06 Jul 2001 17:06
Date: Fri, 06 Jul 2001 17:06
47 lines
3029 bytes
3029 bytes
An application can have as many windows open as it wishes; including, if
you like, multiple copies of the same form. (You simply must be sure
that you keep each TForm object separate from the others, e.g. in a
TList. You can't use Delphi's standard trick of creating a global
variable to hold it.)
Intrinsically, a form .. any Windows window .. is dependent upon the
Windows software to draw and maintain it, and this occurs through the
use of Windows messages. Only one thread (the main thread) should be
having anything to do with Windows messages. It can, however, support
any number of windows at the same time. (All the messages for all the
windows flow through it.)
>Sterling Bates wrote:
>
> I'm use several TThreads to spawn instances of the same form multiple times;
> ie:
>
> procedure TSpawnFormThread.Execute;
> begin
> FreeOnTerminate := true;
> with TMyForm.Create(nil) do
> begin
> ShowModal;
> Release;
> end;
> end;
>
> This tends to create interesting errors (window handle no longer valid) on
> the Release of the form, and the message "Canvas does not allow drawing"
> when activating a form (this primarly caused, it seems, by TRichEdit).
>
> Another poster mentioned that only the main VCL thread properly handles
> forms, but need to know if there's an elegant way to work with this.
>
> Note: I *do* need to pop up multiple instances of the same form -- I'm open
> to suggestions on other ideas.
------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:info@sundialservices.com (PGP public key available.)
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R): "Click click, it's fixed!" {tm}
> http://www.sundialservices.com/products/chimneysweep
Technical Details
Message-ID:
<3B45F003.2FA5@sundialservices.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!washdc3-snh1.gtei.net!news.gtei.net!newsfeed.us.prserv.net!prserv.net!news1.prserv.net!32.101.171.213References:
<T1d17.12112$E93.2145422@news1.telusplanet.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1091e5,4265b72517a20f0e X-Google-Attributes: gid1091e5,public X-Google-Thread: 109d99,4265b72517a20f0e X-Google-Attributes: gid109d99,public X-Google-ArrivalTime: 2001-07-06 10:06:10 PST Message-ID: <3B45F003.2FA5@sundialservices.com> Date: Fri, 06 Jul 2001 10:06:11 -0700 From: Sundial Services <info_NS1@sundialservices.com> Reply-To: info_NS1@sundialservices.com Organization: Sundial Services X-Mailer: Mozilla 3.04 (Win95; U) MIME-Version: 1.0 Newsgroups: comp.lang.pascal.delphi.components.misc,borland.public.delphi.winapi Subject: Re: TForm inside a TThread References: <T1d17.12112$E93.2145422@news1.telusplanet.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 32.101.171.213 X-Trace: 6 Jul 2001 17:16:35 GMT, 32.101.171.213 Lines: 47 X-Complaints-To: abuse@prserv.net Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!washdc3-snh1.gtei.net!news.gtei.net!newsfeed.us.prserv.net!prserv.net!news1.prserv.net!32.101.171.213