Article View: borland.public.delphi.language.objectpascal
Article #32426Re: showmodal and do something
From: Peter Below (TeamB)
Date: Fri, 22 Nov 2002 18:43
Date: Fri, 22 Nov 2002 18:43
103 lines
4124 bytes
4124 bytes
In article <3dddd997$1@newsgroups.borland.com>, Grega Loboda wrote:
> I know I've done this before, but...lost it. I want to show a status form.
> It should be shown modal. When form is on the screen, I would like to do
> something, after that, close it. How?
Here is a fragment from a form class i use for this kind of task. The
relevant parts are the constructor and destructor. YOu would use this like
with TPseudomodalWaitform.Create( self, aMessage ) do
try
DoTheLengthyTask
finally
Free
end;
{== PseudomodalWaitformU ==============================================}
{: This form can be used to display a wait message while some processing
is ongoing.
@author Dr. Peter Below
@desc Version 1.0 created 1 Februar 2002<BR>
Current revision 1.0<BR>
Last modified 1 Februar 2002<P>
The form will automatically center over the passed owner form and
adjust in size to the passed message. It will show itself when created
and disable all other forms of the application. The form cannot be
closed by the user. }
{======================================================================}
{$BOOLEVAL OFF}{Unit depends on shortcut boolean evaluation}
Unit PseudomodalWaitformU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Expanel;
type
TPseudomodalWaitform = class(TForm)
ExPanel1: TExPanel;
PaintBox: TPaintBox;
procedure PaintBoxPaint(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
FMessage: String;
FOwner : TForm;
FWindowlist: Pointer;
Procedure MeasureMessage;
procedure SetMessage(const Value: String);
public
Constructor Create( aOwner: TForm; const aMsg: String ); reintroduce;
Destructor Destroy; override;
property Message: String read FMessage write SetMessage;
end;
Implementation
Uses UIHelpers, Styles;
{$R *.DFM}
Constructor TPseudomodalWaitform.Create(aOwner: TForm; const aMsg: String);
Begin
If not Assigned( aOwner ) Then
aOwner := Screen.ActiveForm;
Assert( Assigned( aOwner ),
'TPseudomodalWaitform.Create: aOwner cannot be nil!');
inherited Create( nil );
FOwner := aOwner;
FMessage := aMsg;
HandleNeeded;
MeasureMessage;
Paintbox.Color := Styles.Readonlycolor;
Show;
Update;
Fwindowlist := DisableTaskWindows( handle );
End;
Destructor TPseudomodalWaitform.Destroy;
Begin
OnCloseQuery := Nil;
If Assigned( FWindowlist ) Then
EnableTaskWindows( FWindowlist );
If Assigned( FOwner ) Then
FOwner.Show;
inherited;
End;
procedure TPseudomodalWaitform.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
CanClose := False;
end;
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Technical Details
Message-ID:
<VA.00009663.00864dbe@antispam.compuserve.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!telocity-west!DIRECTV!c02.atl3!news.webusenet.com!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mailReferences:
<3dddd997$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d30,7cfd3117308f184f X-Google-Attributes: gid109d30,public X-Google-ArrivalTime: 2002-11-22 11:15:49 PST Date: Fri, 22 Nov 2002 19:43:32 +0100 Newsgroups: borland.public.delphi.language.objectpascal Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Virtual Access by Atlantic Coast PLC, http://www.atlantic-coast.com/va Organization: TeamB Message-ID: <VA.00009663.00864dbe@antispam.compuserve.com> Subject: Re: showmodal and do something From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Reply-To: 100113.1101@compuXXserve.com References: <3dddd997$1@newsgroups.borland.com> NNTP-Posting-Host: 62.226.189.68 X-Trace: newsgroups.borland.com 1037990601 62.226.189.68 (22 Nov 2002 10:43:21 -0800) Lines: 105 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!telocity-west!DIRECTV!c02.atl3!news.webusenet.com!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail