delphi中如何制作一个在MDI主窗口之前的登录窗口? |
尚未結案
|
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
|
delphiwww
資深會員 發表:145 回覆:363 積分:368 註冊:2002-03-13 發送簡訊給我 |
|
nachi
初階會員 發表:40 回覆:116 積分:31 註冊:2003-02-26 發送簡訊給我 |
|
banson1716
高階會員 發表:55 回覆:182 積分:167 註冊:2002-04-14 發送簡訊給我 |
public I, Level1, Level2: Integer;
UID, UName: string; end;
var
PassForm1: TPassForm1;
I : Integer;
implementation
{$R *.DFM}
procedure TPassForm1.OKBtnClick(Sender: TObject);
begin with PassWore1 do
begin
if FindKey([UpperCase( EID.Text)]) then
begin file://注意 [] 符號應用{轉大寫}
if FieldByName( 'PASS').AsString = EPass.Text then
begin
ModalResult := mrOK;
UID := FieldByName( 'UID').AsString;
UName := FieldByName( 'UNAME').AsString;
Level1 := FieldByName('LEVEL1').AsInteger;
Level2 := FieldByName('LEVEL2').AsInteger;
end;
end;
end;
if ModalResult <> mrOK then
begin
SScrollText1.Items.Text := '密碼錯誤 , 請從新輸入';
I := I 1;
end;
if I >= 3 then
ModalResult := mrCancel;
end;
procedure TPassForm1.FormCreate(Sender: TObject);
begin I := 0;
Animated1.play := true;
SScrollText1.Items.Text := '請輸入正確密碼';
end;
procedure TPassForm1.EIDClick(Sender: TObject);
begin
SScrollText1.Items.Text := '請輸入正確 ID 密碼';
end;
procedure TPassForm1.EPassClick(Sender: TObject);
begin
SScrollText1.Items.Text := '請輸入正確密碼';
end;
procedure TPassForm1.Animated1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
SScrollText1.Items.Text :='電腦資料庫管理系統';
end;
procedure TPassForm1.EIDKeyPress(Sender: TObject; var Key: Char);
begin
case Key of {按Enter下筆; 按Esc離開}
#13:if (Key = #13{VK_RETURN}) then begin
PostMessage(Handle, WM_KEYDOWN, VK_TAB, 0);end;
#27:ModalResult := mrCancel;
end;
end;
|
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
|
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
还是有问题,下面是我的源代码,只能实现一次密码不正确时就退出程序,而不能实现级三次输入密码的机会!还请各位大侠再指点!多谢!!
这是MDI主窗口的onShow事件。
procedure Tmainform.FormShow(Sender: TObject);
begin
with Tloginform.Create(Self) do
begin
try
if showmodal<>mrok then
Application.Terminate;
finally
Free;
end;
end;
end; 这是登录窗口的‘确定’按钮事件。
procedure TloginForm.yes_ButtonClick(Sender: TObject);
begin
if password_edit.text<>'123' then
begin
application.MessageBox('密码错误!' chr(13) '您无权使用本系统!','错误',mb_ok mb_iconinformation);
modalresult:=mrno;
end
else
modalresult:=mrok;
end; 这是.dpr中的部分代码。
begin
Application.Initialize;
Application.CreateForm(Tmainform, mainform);
Application.Run;
end.
不知还要如何修改?? 發表人 - maxbo 於 2003/05/13 13:26:07
|
banson1716
高階會員 發表:55 回覆:182 積分:167 註冊:2002-04-14 發送簡訊給我 |
dpr中的部分
program FS; uses
Forms,
Controls,
....... var
tmpPassForm: TPassForm1; {$R *.RES} begin
Application.Initialize;
tmpPassForm := TPassForm1.Create(Application);
///////////////////////////////////////
try FrmSplash := TFrmSplash.Create( Application );
FrmSplash.Show;
FrmSplash.Update;
FrmSplash.Timer1.Interval :=5000;
Application.Title := '電腦資料庫管理系統';
finally FrmSplash.Free;end;
/////////////////////////////////////////
if Assigned( tmpPassForm) then
begin
tmpPassForm.ShowModal;
if tmpPassForm.ModalResult = mrOK then
begin
DtCord.UID := tmpPassForm.UID;
DtCord.UName := tmpPassForm.UName;
DtCord.Level1 := tmpPassForm.Level1;
DtCord.Level2 := tmpPassForm.Level2;
tmpPassForm.Free;
try FrmSplash := TFrmSplash.Create( Application );
FrmSplash.Show;
FrmSplash.Update; // Handle any Pending Paint Messages
Application.Title := '電腦資料庫管理系統';
.........
finally FrmSplash.Free;end; Application.Run;
end
else
tmpPassForm.Free;
end; end.
|
banson1716
高階會員 發表:55 回覆:182 積分:167 註冊:2002-04-14 發送簡訊給我 |
參考一下 unit login; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, DB, ADODB; type
Tfrm_login = class(TForm)
Edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Image1: TImage;
Label1: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
PassTime:Byte;
{ Private declarations }
public
{ Public declarations }
end; var
frm_login: Tfrm_login; implementation uses main, data; {$R *.DFM} procedure Tfrm_login.BitBtn2Click(Sender: TObject);
begin
Close;
Application.Terminate;
end; procedure Tfrm_login.BitBtn1Click(Sender: TObject);
begin
inc(PassTime);
if Edit1.Text=MyPass then
begin
frm_main.Logined:=True;
frm_main.WindowState:=wsMaximized;
Close;
end else
begin
Label1.Caption:=Format('密碼錯誤第%d次,請重新輸入:',[PassTime]);
if PassTime>=3 then
begin
// MessageBox(Handle,'連續輸入錯誤密碼超過3次,程序退出!','信息',MB_OK);
BitBtn2Click(Sender);
end else
begin
Edit1.Text:='';
Edit1.SetFocus;
end;
end;
end; procedure Tfrm_login.FormCreate(Sender: TObject);
begin
PassTime:=0;
end; end.
|
banson1716
高階會員 發表:55 回覆:182 積分:167 註冊:2002-04-14 發送簡訊給我 |
引言:
--------------------------------------------------------------------------------
这是.dpr中的部分代码。
begin
Application.Initialize;
Application.CreateForm(Tmainform, mainform);
Application.Run;
end.
不知还要如何修改??
--------------------------------------------------------------------------------
program Project1; uses
Forms,
Controls,
Unit2 in 'Unit2.pas' {Form2}; {$R *.RES} begin
Application.Initialize;
Tloginform := TTloginform.Create(Application);
if Assigned( Tloginform) then
begin
Tloginform.ShowModal;
if Tloginform.ModalResult = mrOK then
begin
Application.Run;
end
else
Tloginform.Free;
end;
end.
|
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
|
banson1716
高階會員 發表:55 回覆:182 積分:167 註冊:2002-04-14 發送簡訊給我 |
在frm_main 主程式宣告的
...... public
Logined:Boolean; ......... ================================= frm_main 主程式片段 ..........
var
frm_main: Tfrm_main;
MyPath:String; const
MyPassW='123'; implementation uses login, table, query, outdata, setup, About; {$R *.dfm} procedure Tfrm_main.FormCreate(Sender: TObject);
begin
MyPath:=ExtractFilePath(ParamStr(0));
ShortDateFormat:='yyyy/mm/dd';
Logined:=False;
Color:=Image1.Canvas.Pixels[0,0];
end; procedure Tfrm_main.SystemExitExecute(Sender: TObject);
begin
Close;
end; procedure Tfrm_main.FormActivate(Sender: TObject);
begin
if not Logined then frm_login.ShowModal;
end; .............. 發表人 - banson1716 於 2003/05/15 00:39:57
|
Justmade
版主 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
引言: 还是有问题,下面是我的源代码,只能实现一次密码不正确时就退出程序,而不能实现级三次输入密码的机会!还请各位大侠再指点!多谢!!發表人 - Justmade 於 2003/05/15 13:32:12这是MDI主窗口的onShow事件。 procedure Tmainform.FormShow(Sender: TObject); begin with Tloginform.Create(Self) do begin try if showmodal<>mrok then Application.Terminate; finally Free; end; end; end; 这是登录窗口的‘确定’按钮事件。 var LoginForm : TLoginForm; FailCount : Integer; procedure TloginForm.FormShow(Sender: TObject); begin FailCount := 0; end; procedure TloginForm.yes_ButtonClick(Sender: TObject); begin if password_edit.text <> '123' then begin application.MessageBox('密码错误!' chr(13) '您无权使用本系统!','错误',mb_ok mb_iconinformation); Password_edit.SetFocus; if FailCount >= 3 then modalresult:=mrno else FailCount := FailCount 1; end else modalresult:=mrok; end; 这是.dpr中的部分代码。 begin Application.Initialize; Application.CreateForm(Tmainform, mainform); Application.Run; end. |
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
|
Justmade
版主 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
|
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
|
Justmade
版主 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
|
maxbo
一般會員 發表:11 回覆:15 積分:5 註冊:2003-05-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |