Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Password(danmaftei) and me using Parameter

Hi all and danmaftei,

I have done a mistake i should say by using Parameter passing to work like a password. But after seeing danmaftei using the password Dlg, i think that it is a good idea to implement password using his method. What i previous done is in the application unit i type

[code]
begin
Application.Initialize;
Application.CreateForm(TTariffDataBase, TariffDataBase);
Application.CreateForm(TPoolFC, PoolFC);
Application.CreateForm(TDmndFC, DmndFC);
Application.CreateForm(Tlook_up, look_up);
if paramstr(1) <> 'Paradigm' then
Application.Terminate
else
Application.Run;
end.
[/code]

So that if i set Paradigm as a parameter, the form can be loaded.
However, i am thinking of changing to danmaftei method using password Dlg. I try to remove the code from the unit that is
[code]
if paramstr(1) <> 'Paradigm' then
Application.Terminate
else
Application.Run;
[/code]

But when i remove this code and the parameter, the form cannot load up any more. Can anyone help me, so that i can get the form back even without the code. I don't know what has happen.

Thanks to all who help

Regards,
Para

Comments

  • Mark StrijbosMark Strijbos Member Posts: 82
    I try to remove the code from the unit that is
    : [code]
    : if paramstr(1) <> 'Paradigm' then
    : Application.Terminate
    : else
    : Application.Run;
    : [/code]

    perhaps you should leave this bit in:

    [code]
    Application.Run;
    [/code]

    btw: in general it is not a very good idea to put "extra" code here.
    IMHO you'd better code this in the main form handler


  • zibadianzibadian Member Posts: 6,349
    : Hi all and danmaftei,
    :
    : I have done a mistake i should say by using Parameter passing to work like a password. But after seeing danmaftei using the password Dlg, i think that it is a good idea to implement password using his method. What i previous done is in the application unit i type
    :
    : [code]
    : begin
    : Application.Initialize;
    : Application.CreateForm(TTariffDataBase, TariffDataBase);
    : Application.CreateForm(TPoolFC, PoolFC);
    : Application.CreateForm(TDmndFC, DmndFC);
    : Application.CreateForm(Tlook_up, look_up);
    : if paramstr(1) <> 'Paradigm' then
    : Application.Terminate
    : else
    : Application.Run;
    : end.
    : [/code]
    :
    : So that if i set Paradigm as a parameter, the form can be loaded.
    : However, i am thinking of changing to danmaftei method using password Dlg. I try to remove the code from the unit that is
    : [code]
    : if paramstr(1) <> 'Paradigm' then
    : Application.Terminate
    : else
    : Application.Run;
    : [/code]
    :
    : But when i remove this code and the parameter, the form cannot load up any more. Can anyone help me, so that i can get the form back even without the code. I don't know what has happen.
    :
    : Thanks to all who help
    :
    : Regards,
    : Para
    :
    The following code will do the trick:
    [code]
    begin
    if paramstr(1) <> 'Paradigm' then begin // If the parameter is there
    Application.Initialize; // then start to create the program
    Application.CreateForm(TTariffDataBase, TariffDataBase);
    Application.CreateForm(TPoolFC, PoolFC);
    Application.CreateForm(TDmndFC, DmndFC);
    Application.CreateForm(Tlook_up, look_up);
    end; // otherwise do nothing and do standard termination stuff.
    end.
    [/code]
  • ParadigmParadigm Member Posts: 77
    Hi all,

    I don't know why, but after i put a password Dlg box, i cannot close my form. That is, after i enter the correct password, i can access my orignal form.

    But when i click the Close Bitbtn, the form close but the program never terminate. I have to got to Run>program reset.

    Then when i try to run the exe, i can also close the form but the program didn't close fully, as in i cannot complier the program again. Unless i press ctrl-Alt-Del to terminate the program.

    Can anyone help me pls....Thanks a lot

    Regards,
    Para
  • ParadigmParadigm Member Posts: 77
    Hi all,

    I guess its either this two problems. Firstly, i change the initalisation from
    [code]
    begin
    Application.Initialize;
    Application.CreateForm(TTariffDataBase, TariffDataBase);
    Application.CreateForm(TDmndFC, DmndFC);
    Application.CreateForm(Tlook_up, look_up);
    Application.CreateForm(TPasswordDlg, PasswordDlg);
    Application.Run;
    end.
    [/code]
    to
    [code]
    begin
    Application.Initialize;
    Application.CreateForm(TPasswordDlg, PasswordDlg);
    Application.CreateForm(TTariffDataBase, TariffDataBase);
    Application.CreateForm(TDmndFC, DmndFC);
    Application.CreateForm(Tlook_up, look_up);
    Application.Run;
    end.
    [/code]
    so that the password form will show up first. Then in the password form 'ok' button i add
    [code]
    procedure TPasswordDlg.OKBtnClick(Sender: TObject);
    begin
    if password.Text <>'Paradigm' then
    begin
    showmessage('Wrong Password!!!');
    close;
    end
    else begin
    PasswordDlg.Hide;
    TariffDataBase.Show;
    end;
    end;
    [/code]
    With this, if the password is correct, then i can access TariffDataBase. However, i cannot terminate the program but the Close bitbtn now.

    Thanks to all who help.

    Regards,
    Para
  • cycordcycord Member Posts: 148
    im not sure if this will work but worth a try

    [code]
    begin
    Application.Initialize;
    if Application.CreateForm(TPasswordDlg, PasswordDlg) then
    begin
    Application.CreateForm(TTariffDataBase, TariffDataBase);
    Application.CreateForm(TDmndFC, DmndFC);
    Application.CreateForm(Tlook_up, look_up);
    Application.Run;
    end;
    end.
    [/code]

    but if it wont, i think the problem is, the TPasswordDlg has never been close, it just open another form, but the main form [TPasswordDlg] has never been close, that is why you cant close the other forms, maybe the ShowModal or Show can help. i think......
  • cycordcycord Member Posts: 148
    im not sure if this will work but worth a try

    [code]
    begin
    Application.Initialize;
    if Application.CreateForm(TPasswordDlg, PasswordDlg) then
    begin
    Application.CreateForm(TTariffDataBase, TariffDataBase);
    Application.CreateForm(TDmndFC, DmndFC);
    Application.CreateForm(Tlook_up, look_up);
    Application.Run;
    end;
    end.
    [/code]

    but if it wont, i think the problem is, the TPasswordDlg has never been close, it just open another form, but the main form [TPasswordDlg] has never been close, that is why you cant close the other forms, maybe the ShowModal or Show can help. i think......
  • cycordcycord Member Posts: 148
    im not sure if this will work but worth a try

    [code]
    begin
    Application.Initialize;
    if Application.CreateForm(TPasswordDlg, PasswordDlg) then
    begin
    Application.CreateForm(TTariffDataBase, TariffDataBase);
    Application.CreateForm(TDmndFC, DmndFC);
    Application.CreateForm(Tlook_up, look_up);
    Application.Run;
    end;
    end.
    [/code]

    but if it wont, i think the problem is, the TPasswordDlg has never been close, it just open another form, but the main form [TPasswordDlg] has never been close, that is why you cant close the other forms, maybe the ShowModal or Show can help. i think......
  • Shawn CarterShawn Carter Member Posts: 0

    __ { http://forcoder.org } free ebooks and video tutorials about // Objective-C Ruby Delphi Go Scratch C++ Visual Basic C# PL/SQL JavaScript R Swift PHP C Visual Basic .NET Java Python MATLAB Assembly Perl Kotlin Transact-SQL Erlang Dart LabVIEW Scheme COBOL Ada ABAP F# Scala Fortran SAS Alice Hack Clojure Lua Awk Crystal VBScript Julia FoxPro Logo ML Rust Lisp Apex Bash Prolog D //

Sign In or Register to comment.