Solved

i want to show a login frame before the main form

Posted on 2004-04-30
7
145 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now