Board index » delphi » Delphi 1 closing the main form on creation

Delphi 1 closing the main form on creation

This is Delphi 1 under Win 3.1. Help please, I want my mainform on the
create event  to prompt for a password (easy enough) but then I want to
close down the application if it is wrong. I use a 'close' command but that
seems to have no effect!

If I use free or release then it terminates but I then get a GPF. If I use
application.terminate then it goes into some kind of wacky loop and I have
to ctrl-alt-del to finish it off.

While you're at it, do you know of a call similar to InputBox but which
uses a PassWordChar so I can hide the users typing?

Any help gratefully received, on an email please. Thank you!

--
Best regards
Neale Gray
gray...@patrol.i-way.co.uk
http://www.i-way.co.uk/~graynet

 

Re:Delphi 1 closing the main form on creation


On 11 Apr 1997 17:20:59 GMT, "Neale Gray" <gray...@patrol.i-way.co.uk>
wrote:

Quote
>This is Delphi 1 under Win 3.1. Help please, I want my mainform on the
>create event  to prompt for a password (easy enough) but then I want to
>close down the application if it is wrong.

Perhaps there are nicer solutions, but this works for me:

After getting a wrong password I assign a value to Application.Tag. In
the the source of the project I check for this value as a condition
for Application.Run:

  if Application.Tag <> 13 then
    Application.Run;

Hope this helps,

Harry

Anansi, a freeware project-centered HTML-editor:
http://www.xs4all.nl/~hbosma/anansi/index.html

Re:Delphi 1 closing the main form on creation


or you can use halt, or exit from the main procedure or also
application.terminate

eg

program thingy;

uses
{usual}
   password;

begin
  FormLogIn := TFormLogIn.create(application);
  FormLogIn.execute;
  if not(FormLogIn.okuser) then BEGIN
    showmessage('Unknown User. Application terminating');
{    application.terminate;      }
{exit}
     halt;
  end
  else FormLogIn.free;

end;

I personally like halt cos it gets rid of the thingy pdq !

--
Boris Ingram, Cyborg Software
boris...@iafrica.com
100076.3...@compuserve.com
http://www.pcb.co.za/users/borising/cyborg.htm

Harry Bosma <hbo...@xs4all.nl> wrote in article
<3352db33.4929...@news.xs4all.nl>...

Quote
> On 11 Apr 1997 17:20:59 GMT, "Neale Gray" <gray...@patrol.i-way.co.uk>
> wrote:

> >This is Delphi 1 under Win 3.1. Help please, I want my mainform on the
> >create event  to prompt for a password (easy enough) but then I want to
> >close down the application if it is wrong.

> Perhaps there are nicer solutions, but this works for me:

> After getting a wrong password I assign a value to Application.Tag. In
> the the source of the project I check for this value as a condition
> for Application.Run:

>   if Application.Tag <> 13 then
>     Application.Run;

> Hope this helps,

> Harry

> Anansi, a freeware project-centered HTML-editor:
> http://www.xs4all.nl/~hbosma/anansi/index.html

Re:Delphi 1 closing the main form on creation


This is a multi-part message in MIME format.

------=_NextPart_000_01BC49B8.A94C6EE0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

hi,

after the login session faild try to execute the following code

PostMessage(Self.Handle, WM_CLOSE,0,0);
exit;

rafi

------=_NextPart_000_01BC49B8.A94C6EE0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D3 =
color=3D"#000000" face=3D"Arial">hi, <br><br>after the login session =
faild try to execute the following code<br><br>PostMessage(Self.Handle, =
WM_CLOSE,0,0);<br>exit;<br><br>rafi<br><br></p>
</font></body></html>
------=_NextPart_000_01BC49B8.A94C6EE0--

Other Threads