BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: How do I close a Form programmatically?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.components.writing
View previous topic :: View next topic  
Author Message
Brett
Guest





PostPosted: Wed Dec 15, 2004 3:04 pm    Post subject: Re: How do I close a Form programmatically? Reply with quote




Michael Marsden wrote:
Quote:
In article <331392cf.5487980 (AT) news (DOT) ndh.com>, Meikel Weber
[email]m.weber (AT) public (DOT) n-dh.com[/email]> writes

On 19 Feb 1997 03:07:00 GMT, "Steve Treesh" wrote:
....
Form1.close; <--- this doesn't close the window


Why not use "Close" alone without the "Form1." in front of it. But
in
fact I think this wouldn't help ...

I've tried using ModalResult := mrCancel immediately before the
close...no luck
I've hooked an OnClose event...no luck.


I experienced these problems some time ago. It is related to the
fact
that the form is not yet fully created and shown and somehow the
close
message is deleted somewhere (or ignored). I programmed around with
posting a user-defined message.
Instead of "Form1.Close" do a
PostMessage (Handle, WM_USER+101,0, 0);

and then add a message handler
procedure WMUser101 (var Msg : TMessage); message WM_USER+101;

procedure WMUser101;
begin
Close
end;


Try using .Release instead - this basically executes .Close & then
..Free
via a windows message. Its much safer to use in FormCreate & events
than .Close or .Free.

-Mike


-----------------------------------------------------------------------
Michael Marsden [email]mikemars (AT) satan (DOT) demon.co.uk[/email]
[email]mikemars (AT) webcom (DOT) com[/email]
Home page -
http://www.webcom.com/mikemars/index.html
Delphi -
http://www.webcom.com/mikemars/mikedelf.html



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.components.writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.