Solved

i want to show a login frame before the main form

Posted on 2004-04-30
7
147 Views
Last Modified: 2010-04-05
hello
i need to show a frame on starting the prog  before the main form
to get the username and the password and if correct it show the other form and close the first
sure also get data from the first to the second.
thx
0
Comment
Question by:mis82
  • 2
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 250 total points
ID: 10960230

   create frmLogin like the example below
   ---------------------------------------------------------------------------

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TfrmLogin = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
    class procedure GetLoginInfo (var Username, password : String);
  end;

var
  frmLogin: TfrmLogin;

implementation

{$R *.DFM}

{ TfrmLogin }

class procedure TfrmLogin.GetLoginInfo(var Username, password: String);
var
  tmp_form : TfrmLogin;
begin
  tmp_Form := TfrmLogin.Create(Application);
  with tmp_Form do
    begin
      if ShowModal = mrOK then
        begin
          UserName := Edit1.Text;
          Password := Edit2.text;
        end;
    end;
end;

end.


   and MainForm as shown :
   ------------------------------------------------------------
   unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    u, p : String;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses Unit2;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TfrmLogin.GetLoginInfo(u, p);
end;

end.
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 10961091
.. or call in from the project source file, just before the Application.Exeucte()
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10967162

  andrewjb, you mean Application.Run :))
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 10984973
Knew it was something like that :-)
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question