如何在主Form出现之前,弹出密码验证From,Cancel就退出程序,Ok后密码正确才出现主Form
本文地址 :CodeGo.net/5175478/ 
------------------------------------------------------------------------------------------------------------------------- 
1.我给你一个LOGINFORM的例子:
unit LoginFrm;
interface
uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls;
type
TLoginForm = class(TForm)
lblEnterPassword: TLabel;
lblEnterName: TLabel;
edtName: TEdit;
edtPassword: TEdit;
btnOK: TButton;
btnCancel: TButton;
public
end;
function GetLoginParams(ALoginParams: TStrings): Boolean;
implementation
{$R *.DFM}
function GetLoginParams(ALoginParams: TStrings): Boolean;
var
LoginForm: TLoginForm;
begin
Result := False;
LoginForm := TLoginForm.Create(Application);
try
if LoginForm.ShowModal = mrOk then
begin
ALoginParams.Values['USER NAME'] := LoginForm.edtName.Text;
ALoginParams.Values['PASSWORD'] := LoginForm.edtPassWord.Text;
Result := True;
end;
finally
LoginForm.Free;
end;
end;
end. 
2. 自己先做个登录窗体
在工程文件里先USES 那个单元
再写......
Application.Initialize;
frmlogon:= Tfrmlogon.Create(Application);
frmlogon.ShowModal;
frmlogon.Update;
if frmlogon.ModalResult = mrOK then
begin
frmlogon.Free;
frmlogon.Hide;
Application.CreateForm(TForm1, Form1);
Application.Run;
end 
3. procedure TLoginForm.btnLoginClick(Sender: TObject);
var
ComputerName: String;
CNameBuffer : PChar;
fl_loaded : Boolean;
CLen : ^DWord;
intLogin:Integer;
begin
//取得计算机名称
GetMem(CNameBuffer,255);
New(CLen);
CLen^:= 255;
fl_loaded := GetComputerName(CNameBuffer,CLen^);
if fl_loaded then
ComputerName := StrPas(CNameBuffer)
else
ComputerName := 'Unknown';
FreeMem(CNameBuffer,255);
Dispose(CLen);
//登录系统
if edtUser.Text='' then
begin
MessageBox(Self.Handle,'输入用户!','提示',MB_OK+MB_ICONEXCLAMATION);
edtUser.SetFocus;
exit;
end;
if ComboBox1.items.Count>0 then
begin
if ComboBox1.ItemIndex=-1 then
begin
MessageBox(Self.Handle,'选择帐套!','提示',MB_OK+MB_ICONEXCLAMATION);
ComboBox1.SetFocus;
exit;
end;
end;
//登录系统
if blnFirstLogin=False then dmlPreserve.scPreserve.AppServer.LogoutStatus(CurUserID);
dmlPreserve.scPreserve.AppServer.LoginStatus(edtUser.Text,edtPwd.Text,ComputerName,intLogin,curUserName);
Case intLogin of
0: //成功登录
begin
MessageBox(Self.Handle,'登录成功!','提示',MB_OK+MB_ICONEXCLAMATION);
Fini.WriteString('Preserve','LastUser',edtUser.Text);
Fini.WriteString('Preserve','LastAccount',ComboBox1.Text);
curAccount:=ComboBox1.Text;
MDIMainForm.sbrMain.Panels[3].Text:='当前帐套:'+ComboBox1.Text;
curUserID:=edtUser.Text;
MDIMainForm.sbrMain.Panels[2].Text:='操作用户:'+curUserName;
dmlPreserve.cdsusrUser.Close;
if blnFirstLogin=True then blnFirstLogin:=False;
Close;
end;
1:
begin
MessageBox(Self.Handle,'该用户不存在!','提示',MB_OK+MB_ICONEXCLAMATION);
edtUser.SetFocus;
end;
2:
begin
MessageBox(Self.Handle,'该用户不允许在此计算机上登录!','提示',MB_OK+MB_ICONEXCLAMATION);
edtUser.SetFocus;
end;
3:
begin
MessageBox(Self.Handle,'密码错误!','提示',MB_OK+MB_ICONEXCLAMATION);
edtPwd.SetFocus;
end;
4:
begin
MessageBox(Self.Handle,'该用户已经登录!','提示',MB_OK+MB_ICONEXCLAMATION);
edtUser.SetFocus;
end;
5:
begin
if MessageBox(Self.Handle,'该用户已经登录,是否强行登录?','提示',MB_YESNO+MB_ICONQUESTION)=mrNO then
edtUser.SetFocus;
end;
6:
begin
MessageBox(Self.Handle,'登录中遇到未知错误!','错误',MB_OK+MB_ICONEXCLAMATION);
edtUser.SetFocus;
end;
end;
end 
4. procedure TMDIMainForm.MDIMainFormOnActivate(Sender: TObject);
begin
LoginForm:=TLoginForm.Create(Self);
LoginForm.ShowModal ;
end;
procedure TLoginForm.btnCancelClick(Sender: TObject);
begin
Application.Terminate
end 
5. program Project1;
uses
Forms,
Dialogs,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
Var
Pass:String;
begin
Application.Initialize;
InputQuery('密码','输入密码',Pass);
if Pass<>'OK' then Application.Terminate;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
本文标题 :如何在主Form出现之前,弹出密码验证From,Cancel就退出程序,Ok后密码正确才出现主Form
本文地址 :CodeGo.net/5175478/

如何在主Form出现之前,弹出密码验证From,Cancel就退出程序,Ok后密码正确才出现主Form的更多相关文章

  1. iOS 沙盒购买,弹出“需要验证”,“继续登录”的问题?

    点击购买后,能弹出 确认购买的对话框, 您想以xxx的价格买一个xxx吗? [environment:sandbox] 点击确认购买后,弹出"需要验证" 点击继续,输入密码后.竟然 ...

  2. 关于MFC主菜单和右键弹出菜单

    一.主菜单.弹出菜单和右键菜单的概念: 主菜单是窗口顶部的菜单,一个窗口或对话框只能有一个主菜单,但是主菜单可以被更改(SetMenu()更改): 创建方式:CMenu::CreateMenu(voi ...

  3. Winform form窗体已弹出框的形式出现并回传值

    From2(弹出框)回传数据到From1 Form1(数据接收form): public string Sstr; private void button1_Click(object sender, ...

  4. bootstrap popover 如何在hover状态移动到弹出上不消失

    bootstrap中的popover其实就是对tooltip做了一定升级,拥有了标题和内容 概要 使用的时候依赖第三方插件 依赖tooltip插件 必须初始化 title 和 content 可以在p ...

  5. Duilib 实现右下角弹出像QQ新闻窗口,3秒后自动关闭(一)

    转载:https://blog.twofei.com/667/ 自绘或子类化控件时,有时需要处理鼠标进入(MouseEnter)/鼠标离开(MouseLeave)/鼠标停留(MouseHover)消息 ...

  6. 使用form 表单 弹出登录框,只传递数据,不刷新界面

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. Duilib 实现右下角弹出像QQ新闻窗口,3秒后窗口透明度渐变最后关闭,若在渐变过程中鼠标放到窗口上,窗口恢复最初状态(二)

    效果: 1.定义两个个定时器ID #define ID_TIMER_DISPLAY_DELAY 30 #define ID_TIMER_DISPLAY_CLOSE 40 2.添加一个成员函数和成员变量 ...

  8. myeclipse新建jsp文件时弹出默认模板,怎么改成自己修改后的

    (1)打开Window——Preferences (2)选择MyEclipse——Filed andEditors——JSP——JSP Source——Templates 看到右边的New Jsp编辑 ...

  9. Windows打开软件老是弹出无法验证发布者

    使用组策略管理器 gpedit.msc 用户配置-管理模板-Windows组件-附件管理器-中等风险文件类型的包含列表 .exe;.cmd;.bat;.js即可

随机推荐

  1. PNS settings

    Before PNS,some settings should be ready: firstly,make sure that the power/ground nets exist,if not, ...

  2. PAT B1025 反转链表 (25 分)

    给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转.例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该为 3→2→1→6→5→4:如果 K 为 4,则输出应该 ...

  3. 转自:strcmp函数实现及详解

    strcmp函数是C/C++中基本的函数,它对两个字符串进行比较,然后返回比较结果,函数形式如下:int strcmp(constchar*str1,constchar*str2);其中str1和st ...

  4. php中经常使用的string函数

    strpos() ---返回字符串在另一字符串中首次出现的位置 strrpos() ---查找字符串在另一字符串中最后出现的位置 strchr()   ===  strstr()    ---找到字符 ...

  5. 实测—fft IP核使用(包括ifft的配置使用)

    Vivado xilinx fft9.0 使用笔记: ****注 仿真实测1024点的转换需要经过1148个时钟周期才能得到转换结果: 模块配置信号含义请参考pg109文档手册(写的贼烂会看晕),不详 ...

  6. 浅析arm的异常、中断和arm工作模式的联系

    说到异常向量,会让人联想到中断向量.其实,中断是属于异常的子集的,也就是说中断其实是异常其中的一种. 回到异常向量,他其实是一张表格,每个格子里存放的是一个地址,或者是一个跳转命令,不管是哪个,其目的 ...

  7. 变量内存空间的释放---c语言

    堆栈内存释放: 栈的内存是由编译器自动分配.释放,出了作用域就释放. 堆的内存由程序员分配.释放,他的作用域是整个程序,如果程序没有释放,程序结束时会自动释放.

  8. identityServer4 中的概念(Scope,claim)

    在IdentityServer中好多地方出现这几个词,这单词的解释也有好多大神解释过: chaim: ASP.NET Core 之 Identity 入门(一),这个是asp.net identity ...

  9. 安装loadrunner11出现Microsoft Visual c++2005 sp1安装失败

    本文转至别处,网上大神多

  10. Nuke Linux Crack

    安装 破解 解压安装FLT7停止Foundry License Server服务 /usr/local/foundry/LicensingTools7.0/FoundryLicenseUtility ...