I placed a CLOSE command but the form still shows. How can I close the form?
thanks
ash
Try this
PostMessage(Handle, WM_CLOSE, 0, 0);
Regards
Tim
Ash Jones <a...@servocon.co.uk> wrote in message news:38fc1cbb@dnews...
Why create the form at all if there's an error that means it shouldnt be
shown?
alternatively:
procedure TForm1.FormCreate(Sender: TObject);
begin
MessageDlg('Sorry, you cant continue', mtInformation, [mbOK], 0);
Application.Terminate;
end;
Ash Jones wrote:
> In my OnCreate method of my form, I load in an configuration file. if
> there's an error in that file I want to be able to tell the user this and
> also close the form (i.e. stop using the form).
>
> I placed a CLOSE command but the form still shows. How can I close the form?
>
> thanks
>
> ash
--
You can't fight in here gentlemen, this is the War Room!
Dr Strangelove
>In my OnCreate method of my form, I load in an configuration file. if
>there's an error in that file I want to be able to tell the user this and
>also close the form (i.e. stop using the form).
>
>I placed a CLOSE command but the form still shows. How can I close the form?
One way is to send the form a WM_CLOSE message using postmessage.
Instead of creating an OnCreate method, I'd override its constructor and
abort the creation if the error condition arises.
HTH,
Carlos
Ash Jones <a...@servocon.co.uk> wrote in message news:38fc1cbb@dnews...
> In my OnCreate method of my form, I load in an configuration file. if
> there's an error in that file I want to be able to tell the user this and
> also close the form (i.e. stop using the form).
>
> I placed a CLOSE command but the form still shows. How can I close the
form?
>
> thanks
>
> ash
>
>
>Try moving your error detection code to the form's OnShow procedure.
>The Close command should work OK from there.
>
_My_ error detection code ?
The message approach is one way. I prefer a timer which you start
with a very short delay to close the form. Works like a charm.
Andrew
--
Andrew Gabb
email: ag...@tpgi.com.au Adelaide, South Australia
phone: +61 8 8342-1021, fax: +61 8 8269-3280
-----