如何在主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. CSS3页面布局方案

    CSS3页面布局方案 Web页面中的布局,在css3之前,主要使用float属性或者position属性进行页面中的简单布局,但是使用它们也存在一些缺点,比如两栏或者多栏中如果元素的内容高度不一致,则 ...

  2. jsp操作javabean

    一:介绍 javabean: java语言编写的一个可重用的组件. 狭义上来说就是我们编写的一个普通的java类,例如:User... javabean规范: 1.必须是一个公共具体的类:public ...

  3. Android 给双ListView组织数据源

    需求:现有这样一套原始数据{“A”,"B","C","D","B","A","B" ...

  4. SharePoint2016配置工作流开发环境

    1,下载Web PlatForm5.0  地址:https://www.microsoft.com/web/downloads/platform.aspx 2,保证开发环境能连网,安装Web Plat ...

  5. 线程池原理及python实现

    为什么需要线程池 目前的大多数网络服务器,包括Web服务器.Email服务器以及数据库服务器等都具有一个共同点,就是单位时间内必须处理数目巨大的连接请求,但处理时间却相对较短. 传统多线程方案中我们采 ...

  6. 字典学习(Dictionary Learning, KSVD)详解

    注:字典学习也是一种数据降维的方法,这里我用到SVD的知识,对SVD不太理解的地方,可以看看这篇博客:<SVD(奇异值分解)小结 >. 1.字典学习思想 字典学习的思想应该源来实际生活中的 ...

  7. Codeforces 946D - Timetable (预处理+分组背包)

    题目链接:Timetable 题意:Ivan是一个学生,在一个Berland周内要上n天课,每天最多会有m节,他能逃课的最大数量是k.求他在学校的时间最小是多少? 题解:先把每天逃课x节在学校呆的最小 ...

  8. 解决 配置springmvc拦截所有请求后请求静态资源404的问题

    <servlet-mapping> <servlet-name>spring-servlet</servlet-name> <url-pattern>/ ...

  9. Flask学习-Flask基础之WSGI

    一.WSGI为什么会出现? 在学习一个东西之前,我们肯定想知道:它为什么会出现?那么,WSGI为什么会出现呢? 我们知道,部署一个web应用,经常需要使用nginx.apache或者IIS等web服务 ...

  10. Mysql_临时表

    CREATE TEMPORARY TABLE test_info ( test_name ) NOT NULL, test_totail ,) NOT NULL DEFAULT 0.00, test_ ...