delphi制作登陆界面

合集下载

Delphi_7_用户界面设计

Delphi_7_用户界面设计
无模式对话框: 在它出现在屏幕的同时,用户还可以在 其他的窗口中进行工作。
有模式对话框: 在它出现在屏幕的时,用户一定要先对 它进行对话,关闭后才可以开出其他的工作窗口。
1. OpenDialog对话框 [例7-9] 设计【打开】对话框
2. SaveDialog组件 [例7-10] SaveDialog组件的使用
3.MessageDlgPos函数 function MessageDlgPos(constMag:string; DlgType:TMsgDlgType;Buttons:TmsgDlgButtons; HelpCtx:Longint;x,y:Integer):Word;
4.ShowMessage过程 Procedure ShowMessage(const Msg:string);
Close 和 SpeedBotton2的Click事件代码设成同样:
procedure TForm1.Close1Click(Sender: TObject); begin
Close; end;
状态栏组件栏中Standard卡,取Panel组件,形成长条, 准备作状态的承载面板。Caption: 空, Name: StatusPanel ,
[例7-7]
5. InputBox函数
function InputBox(const Acaption,Aprompt, AdefaultMsg:string;):string;
6. MessageDlgPosHelp函数
function MessageDlgPos(constMag:string; DlgType:TMsgDlgType;Buttons:TmsgDlgButtons; HelpCtx:Longint;x,y:Integer; const HelpFileName:string):Word;

Delphi数据库编程讲座---第十讲 启动窗口,登录窗口设计

Delphi数据库编程讲座---第十讲 启动窗口,登录窗口设计

第十讲启动窗口,登录窗口设计作为一个完整的程序,启动窗口(又称为flash窗口)、用户登录窗口都是应该具备的。

这里登录窗口与数据库有关,启动窗口的设计与数据库无关,但为了整个数据库程序的完整性,心铃还是给大家讲一下如何设计。

1 启动窗口。

现在绝大部分软件在启动时都会首先出现显示版权、公司标志或软件标志的一个窗口,有几秒种的延时,这就是启动窗口。

这个启动窗口一般来说有两个目的,上面说的是其一,是可视的,另外一个目的是对于复杂的软件、大型软件、数据库软件,由于在启动时有大量的初始化工作,有的程序可能需要十几秒的时间,如果不显示启动窗口用户还可能以为电脑死机了呢,显示启动窗口既宣传一下软件又可以让用户在程序初始化期间不致于感到心烦。

我们来研究一下这个启动窗口如何设计和运行。

设计制做一般都是在窗体上放置一个图片组件,让其充满整个窗体,调入已经设计好的图片。

然后设定此窗体的BorderIcons属性,将系统菜单、最大化最小化等按钮都取消,设定borderStyle属性为bsNone,即没有边框,这样运行后外观看来就是一幅图片。

这种设计制做大家可以各显神通。

接下来一个值得思考的问题是如何让这个窗口在其他窗口初始化之前就显示出来。

这需要手工写代码来实现。

我们在Project菜单下执行“View Source”就可以看到程序是如何初始化的,一般是这种形式:program lklb;…beginApplication.Initialize;Application.Title := '劳保管理';Application.CreateForm(TMainForm, MainForm);…Application.CreateForm(Tflashwin, flashwin);Application.Run;end.如果是这种形式肯定是不行的,因为flash窗体不可能在主窗体前运行。

下面是改写后的代码:var mydate:Tdatetime;{$R *.RES}beginflashwin:=Tflashwin.create(application);flashwin.show;flashwin.update;mydate:=gettickcount;while((GetTickCount-mydate) / 1000 <2) do;Application.Initialize;Application.Title := '社区卫生';Application.CreateForm(TMainForm, MainForm);…flashwin.Close;flashwin.free;Application.Run;上面这段代码首先创建启动窗口,并延时两秒种后初始化程序,在主窗口显示出来后再关闭启动窗口并释放内存。

Delphi实现软件中登录用户的操作权限

Delphi实现软件中登录用户的操作权限

Delphi实现软件中登录用户的操作权限经常在坛子里看到有朋友问如何对软件的登录用户,进行权限控制,可以设定到每一个菜单或按钮上,这里来实现一个最普通的方法,通过数据库,维护一个权限列表(里面有一个字段和节目上菜单项或Button等的tag对应),在执行时,通过到数据库去查询与之匹配的记录是否开通,来决定用户是否有权限。

数据库结构:包括两张表BaseData和UserRightData,BaseData中是一张基本表,里面不区分用户,UserRightData是用户权限表,结构和BaseData一样,只是多了用户字段,增加用户时,就是从BaseData表中复制数据到UserRightData中,并标识用户ID。

字段说明:FucCode:该字段与控件tag对应FucName:功能名称IsSel:是否有权限的标志IsFuc:标识该项是否是可以执行的功能FucPID:父节点ID,用来生成树形结构时用权限管理单元:UserRightCenterview plaincopy to clipboardprint?unit UserRightCenter;interfaceusesWindows, Messages, SysUtils, Classes, Forms, Dialogs,ADODB;typeTUserRight = classprivateFConnection : TADOConnection;FData: TADOQuery;FUserID: Integer;publicconstructor Create(AConnection:TADOConnection);overload;//根据用户id创建对应的权限列表function CreateRightListByUserID(uid:Integer):Boolean;//根据用户id取得对应的权限列表function GetRightListByUserID(uid:Integer):Boolean;//根据用户id删除对应的权限列表function DeleteRightListByUserID(uid:Integer):Boolean;//根据记录id设置某个功能是否可用,funid:记录id,uid:用户ID,issel:是否可用procedure SetFunEnable(funid,uid,issel:Integer);//判断某个功能是否可用function IsRightEnable(uid:Integer;fuccode:string):Boolean;procedure ShowUserRigthView(uid:Integer);property Connection: TADOConnection read FConnection;property Data: TADOQuery read FData;property UserID: Integer read FUserID write FUserID;end;implementationusesUserRightView;{ TUserRight }constructor TUserRight.Create(AConnection: TADOConnection);beginFConnection := AConnection;FData := TADOQuery.Create(nil);FData.Connection := FConnection;end;function TUserRight.CreateRightListByUserID(uid: Integer): Boolean;beginResult := False;DeleteRightListByUserID(uid);FData.Close;FData.SQL.Text := 'insert into UserRightData(fucid,fucpid,fuccode,fucname,IsFuc,IsSel,userid) '+'select fucid,fucpid,fuccode,fucname,IsFuc,IsSel,'+IntToStr(uid)+' from BaseData';FData.ExecSQL;Result := True;end;function TUserRight.DeleteRightListByUserID(uid: Integer): Boolean;beginResult := False;FData.Close;FData.SQL.Text := 'delete from UserRightData where userid='+IntToStr(uid);FData.ExecSQL;Result := True;end;function TUserRight.GetRightListByUserID(uid: Integer): Boolean;beginFData.Close;FData.SQL.Text := 'select * from UserRightData where UserID='+IntToStr(uid);FData.Open;end;function TUserRight.IsRightEnable(uid:Integer;fuccode: string): Boolean;beginFData.Close;FData.SQL.Text := 'select * from UserRightData where userid='+IntToStr(uid)+' and fuccode='+fuccode;FData.Open;if (FData.IsEmpty) or (FData.FieldByName('IsSel').AsInteger = 0) thenResult := FalseelseResult := True;end;procedure TUserRight.SetFunEnable(funid,uid,issel: Integer);beginFData.Close;FData.SQL.Text := 'update UserRightData set IsSel='+IntToStr(issel)+' where UserID='+IntToStr(uid)+' and FucID='+IntToStr(funid); FData.ExecSQL;end;//这是现实权限管理界面的,也就是在上面设置用户权限,这个大家可以根据自己的需要用不同的方式去展现procedure TUserRight.ShowUserRigthView(uid: Integer);varfrm: TfrmUserRightView;beginfrm := TfrmUserRightView.Create(nil);tryfrm.Caption := '用户权限列表';frm.SetUserRight(Self);Self.GetRightListByUserID(uid);frm.ShowModal;finallyFreeAndNil(frm);end;end;end.unit UserRightCenter;interfaceusesWindows, Messages, SysUtils, Classes, Forms, Dialogs,ADODB;typeTUserRight = classprivateFConnection : TADOConnection;FData: TADOQuery;FUserID: Integer;publicconstructor Create(AConnection:TADOConnection);overload;//根据用户id创建对应的权限列表function CreateRightListByUserID(uid:Integer):Boolean;//根据用户id取得对应的权限列表function GetRightListByUserID(uid:Integer):Boolean;//根据用户id删除对应的权限列表function DeleteRightListByUserID(uid:Integer):Boolean;//根据记录id设置某个功能是否可用,funid:记录id,uid:用户ID,issel:是否可用procedure SetFunEnable(funid,uid,issel:Integer);//判断某个功能是否可用function IsRightEnable(uid:Integer;fuccode:string):Boolean;procedure ShowUserRigthView(uid:Integer);property Connection: TADOConnection read FConnection;property Data: TADOQuery read FData;property UserID: Integer read FUserID write FUserID;end;implementationusesUserRightView;{ TUserRight }constructor TUserRight.Create(AConnection: TADOConnection);beginFConnection := AConnection;FData := TADOQuery.Create(nil);FData.Connection := FConnection;end;function TUserRight.CreateRightListByUserID(uid: Integer): Boolean;beginResult := False;DeleteRightListByUserID(uid);FData.Close;FData.SQL.Text := 'insert into UserRightData(fucid,fucpid,fuccode,fucname,IsFuc,IsSel,userid) '+'select fucid,fucpid,fuccode,fucname,IsFuc,IsSel,'+IntToStr(uid)+' from BaseData';FData.ExecSQL;Result := True;end;function TUserRight.DeleteRightListByUserID(uid: Integer): Boolean;beginResult := False;FData.Close;FData.SQL.Text := 'delete from UserRightData where userid='+IntToStr(uid);FData.ExecSQL;Result := True;end;function TUserRight.GetRightListByUserID(uid: Integer): Boolean;beginFData.Close;FData.SQL.Text := 'select * from UserRightData where UserID='+IntToStr(uid);FData.Open;end;function TUserRight.IsRightEnable(uid:Integer;fuccode: string): Boolean;FData.Close;FData.SQL.Text := 'select * from UserRightData where userid='+IntToStr(uid)+' and fuccode='+fuccode;FData.Open;if (FData.IsEmpty) or (FData.FieldByName('IsSel').AsInteger = 0) thenResult := FalseelseResult := True;end;procedure TUserRight.SetFunEnable(funid,uid,issel: Integer);beginFData.Close;FData.SQL.Text := 'update UserRightData set IsSel='+IntToStr(issel)+' where UserID='+IntToStr(uid)+' and FucID='+IntToStr(funid); FData.ExecSQL;end;//这是现实权限管理界面的,也就是在上面设置用户权限,这个大家可以根据自己的需要用不同的方式去展现procedure TUserRight.ShowUserRigthView(uid: Integer);varfrm: TfrmUserRightView;beginfrm := TfrmUserRightView.Create(nil);tryfrm.Caption := '用户权限列表';frm.SetUserRight(Self);Self.GetRightListByUserID(uid);frm.ShowModal;finallyFreeAndNil(frm);end;end;end.看一下主窗体的调用view plaincopy to clipboardprint?unit Main;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,UserRightCenter, StdCtrls, DB, ADODB;typeTfrmMain = class(TForm)Button1: TButton;Button2: TButton;Edit1: TEdit;Label1: TLabel;ADOConnection1: TADOConnection;Button3: TButton;procedure Button1Click(Sender: TObject);procedure FormCreate(Sender: TObject);procedure Button2Click(Sender: TObject);procedure Button3Click(Sender: TObject);private{ Private declarations }FUserRight : TUserRight;public{ Public declarations }end;varfrmMain: TfrmMain;implementation{$R *.dfm}//现实用户权限列表procedure TfrmMain.Button1Click(Sender: TObject);beginerID := 1;FUserRight.ShowUserRigthView(1);end;procedure TfrmMain.FormCreate(Sender: TObject);begin//ADOConnection1是你的数据库连接ADOConnection1.Open;FUserRight := TUserRight.Create(ADOConnection1);end;//创建用户权限列表procedure TfrmMain.Button2Click(Sender: TObject);beginFUserRight.CreateRightListByUserID(StrToInt(Edit1.Text));end;//测试,查看权限,Button3的tag设置为10100003procedure TfrmMain.Button3Click(Sender: TObject);beginif FUserRight.IsRightEnable(1,IntToStr(TButton(Sender).Tag)) thenShowMessage('可以使用')elseShowMessage('你没有使用权限')end;end.unit Main;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,UserRightCenter, StdCtrls, DB, ADODB;typeTfrmMain = class(TForm)Button1: TButton;Button2: TButton;Edit1: TEdit;Label1: TLabel;ADOConnection1: TADOConnection;Button3: TButton;procedure Button1Click(Sender: TObject);procedure FormCreate(Sender: TObject);procedure Button2Click(Sender: TObject);procedure Button3Click(Sender: TObject);private{ Private declarations }FUserRight : TUserRight;public{ Public declarations }end;frmMain: TfrmMain;implementation{$R *.dfm}//现实用户权限列表procedure TfrmMain.Button1Click(Sender: TObject);beginerID := 1;FUserRight.ShowUserRigthView(1);end;procedure TfrmMain.FormCreate(Sender: TObject);begin//ADOConnection1是你的数据库连接ADOConnection1.Open;FUserRight := TUserRight.Create(ADOConnection1);end;//创建用户权限列表procedure TfrmMain.Button2Click(Sender: TObject);beginFUserRight.CreateRightListByUserID(StrToInt(Edit1.Text));end;//测试,查看权限,Button3的tag设置为10100003procedure TfrmMain.Button3Click(Sender: TObject);beginif FUserRight.IsRightEnable(1,IntToStr(TButton(Sender).Tag)) thenShowMessage('可以使用')elseShowMessage('你没有使用权限')end;end.以上都是最基本的操作,没有考虑更多的细节,大家可以根据需要填充。

使用Delphi进行Windows应用程序开发教程

使用Delphi进行Windows应用程序开发教程

使用Delphi进行Windows应用程序开发教程第一章: Delphi简介Delphi是一种集成开发环境(IDE),用于编写Windows上的应用程序。

它基于Pascal语言,并提供了丰富的库和组件,使开发人员能够快速构建功能强大的应用程序。

在本教程中,我们将介绍Delphi的基本概念和工具,以帮助您入门。

第二章:环境设置在开始编写Delphi应用程序之前,我们需要设置开发环境。

首先,下载并安装Delphi IDE。

然后,我们将通过设置项目选项来配置编译器和调试器,以确保我们的应用程序能够顺利运行。

第三章:界面设计一个成功的应用程序离不开良好的用户界面设计。

Delphi提供了丰富的可视化设计工具,如窗体设计器和组件面板,帮助开发人员创建吸引人且易于使用的界面。

在本章中,我们将学习如何添加控件、设置属性以及处理事件。

第四章:数据操作应用程序通常需要与数据库进行交互,以存储和检索数据。

Delphi通过提供数据库连接组件和数据集组件,使得数据操作变得轻松。

我们将学习如何连接和配置数据库,以及如何使用数据集组件执行查询和更新操作。

第五章:文件操作文件操作是应用程序中常见的任务之一。

Delphi提供了用于文件操作的各种函数和组件,如文件读写和文件夹操作等。

我们将演示如何使用这些功能来读取、写入和管理文件。

第六章:多媒体处理现代应用程序通常涉及到音频、视频和图像处理。

Delphi提供了用于多媒体处理的组件和库,如音频播放器、视频解码器和图像处理功能。

我们将学习如何使用这些组件来实现音频、视频和图像的播放、录制和编辑。

第七章:网络通讯在互联网时代,网络通讯在应用程序中变得越来越重要。

Delphi提供了强大的网络编程库,如Socket和HTTP组件,使开发人员能够轻松地与服务器进行通讯。

我们将介绍如何使用这些组件来实现网络通讯功能。

第八章:调试和测试调试和测试是开发过程中必不可少的步骤。

Delphi提供了强大的调试工具,如断点和单步调试器,以帮助开发人员快速定位和解决问题。

delphi的精美界面设计

delphi的精美界面设计

Delphi界面设计专辑[前言:]界面的美观和用户亲和性是应用软件成功的首要条件,因此界面往往是程序员最费心的地方。

在这个专辑中,将向读者全面介绍Delphi中界面设计的原则和技巧窗体设计制作固定大小的Form固定的Form像一个对话框,何不试试下面的语句巧用Delphi制作溅射屏幕精心编写的WINDOWS程序显示启动注意事项,称之为溅射屏幕(splash screen)。

利用一点儿小小的内容,即可给程序的显示添加不少色彩LED数码管仿真显示程序在电子设备上广泛地使用LED数码管显示数据,在许多应用软件中也经常模拟LED数码管显示数据,使程序画面看起来很有特色菜单设计DELPHI中自适应表单的实现我们知道,屏幕分辨率的设置影响着表单布局,假设你的机器上屏幕分辨率是800*600,而最终要分发应用的机器分辨率为640*480,或1024*768,这样你原先设计的表单在新机器上势必会走样作非常规程序菜单掌握delphi高级秘籍大家可能见过诸如金山毒霸,瑞星杀毒,以及五笔输入法等等在系统托盘(即右下角有时间和输入法图标的地方)在的控制菜单,而在正常的任务栏(即屏幕最下方的“开始”按钮的右边的各式各样)中却不出现按钮的程序,即我们常说的在后台运行的程序用Delphi制作动态菜单所谓动态菜单是指菜单项随着程序的操作变化而变化。

现在,我们用Delphi来实现这一功能,具体步骤如下工具栏和状态条为Windows窗口标题栏添加新按钮对于我们熟悉的标准windows窗口来讲,标题栏上一般包含有3个按钮,即最大化按钮,最小化按钮和关闭按钮。

你想不想在Windows的窗口标题栏上添加一个新的自定义按钮用Delphi4实现风Word97格的工具栏用过Word97的人对它的工具栏印象很深刻,因为它的风格很“酷”,同样IE4.0的工具栏也有类似的风格,Win98的出现,使这种风格的工具栏得到了推广如何隐藏和显示Windows的任务条如果隐藏和显示Windows的任务条?仅仅调用以下的函数就可以.其他技巧Delphi利用Windows GDI实现文字倾斜在Delphi开发环境中,文字的输出效果一般都是头上脚下的"正统"字符,如何输出带有一定倾斜角度的文字以达到特殊的显示效果呢Delphi之三十六计之界面篇设置状态栏面板对象的Style为OwnerDraw,并在状态栏对象的DrawPanel事件中书写以下代码利用COM技术实现外壳扩展的属性页当用户在资源管理器中调用右键菜单时,会显示一个"属性"菜单项,点击属性菜单项会显示一个属性页,用户可以获得甚至修改文件信息制作固定大小的Form固定的Form像一个对话框,何不试试下面的语句?C++ Builder请参照Delphi的例子Delphi您可以覆写CreateParams() 这个TWinControl 的虚拟程序, 改变form的wc.Stylee, 将WS_SYSMENU 这个旗标解除, 这样, 就不会有左上角的SystemMenuBox 了.至於不能移动.缩小/放大, 可以自已拦下WM_NCHITTEST, 然後一概回应滑鼠点在视窗Client 区域, 相信这个视窗就呆呆的不会动了.详情可以查一下Win32API Help 的CreateWindow() 与WM_NCHITTEST 的说明.unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls,Forms, Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;procedure Button1Click(Sender: TObject);private{ Private declarations }procedure WMNCHitTest(var Msg: TMessage); message WM_NCHITTEST;protectedprocedure CreateParams(var Params: TCreateParams); override;public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}巧用Delphi制作溅射屏幕精心编写的WINDOWS程序显示启动注意事项,称之为溅射屏幕(splash screen)。

delphi:用户登录窗口

delphi:用户登录窗口

delphi:用户登录窗口完成一个用户注册的例子。

界面设计如下:省份组合框的名字为:provinceBox城市组合框的名字为:cityBox要求:(1)省份组合框中输入:江苏省、河南省和山东省在省份的onchange事件中编写代码,当选择某个省份时,把当前选择省份的城市在城市组合框中显示出来。

(2)当点击注册按钮时,能把你所输入的所有信息都给显示出来。

步骤:1.画好上图的对话框,双击省份“ConboBox”添加代码如下:begincityBox.Items.Clear;if provineBox.ItemIndex = 0 thenbegincitybox.Items.Add('南京');citybox.Items.Add('苏州');citybox.Items.Add('扬州');citybox.Items.Add('宿迁');end;if provineBox.ItemIndex = 1 thenbegincitybox.Items.Add('郑州');citybox.Items.Add('岳阳');citybox.Items.Add('洛阳');citybox.Items.Add('商丘');end;if provineBox.ItemIndex = 2 thenbegincitybox.Items.Add('武汉');citybox.Items.Add('襄樊');end;if provineBox.ItemIndex = 3 thenbegincitybox.Items.Add('杭州');citybox.Items.Add('金华');citybox.Items.Add('宁波');citybox.Items.Add('嘉兴');end;end;2.单击“注册”添加余下的代码:3.总的代码如下:procedure TForm1.Button1Click(Sender: TObject);varusername,sex,password,hobby,birthday,phonenumber,provine,city:string;beginusername:=Edit1.Text;password:=Edit3.Text;birthday:=MaskEdit1.Text;phonenumber:=MaskEdit2.Text;provine:=provineBox.Text;city:=cityBox.Text;if RadioButton1.Checked then sex := '男'else if RadioButton2.Checked then sex := '女';//hobby:个人爱好!if CheckBox1.checked then hobby:='计算机编程';if CheckBox4.Checked then hobby:='游戏';if CheckBox2.checked then hobby:='唱歌';if CheckBox3.checked then hobby:='睡觉';//输出信息!showmessage(username + ',' +password + ','+ sex + ','+ hobby +',' + birthday + ',' + phonenumber + ',' + provine + ',' + city);end;procedure TForm1.provineBoxChange(Sender: TObject);begincityBox.Items.Clear;if provineBox.ItemIndex = 0 thenbegincitybox.Items.Add('南京');citybox.Items.Add('苏州');citybox.Items.Add('扬州');citybox.Items.Add('宿迁');end;if provineBox.ItemIndex = 1 thenbegincitybox.Items.Add('郑州');citybox.Items.Add('岳阳');citybox.Items.Add('洛阳');citybox.Items.Add('商丘');end;if provineBox.ItemIndex = 2 thenbegincitybox.Items.Add('武汉');citybox.Items.Add('襄樊');end;if provineBox.ItemIndex = 3 thenbegincitybox.Items.Add('杭州');citybox.Items.Add('金华');citybox.Items.Add('宁波');citybox.Items.Add('嘉兴');end;end;end.。

Delphi语言编写程序启动画面

Delphi语言编写程序启动画面

5280(2(+.=.5"+ 中 加 入 语 句 :,(, 2"?(J 再 为 W=5+1"#2 创建 7+9<.5?=.( 事件 % 8#"<(U:#( XW=5+1"#2D1"#29<.5?=.(F,(+U(#MX7@6(<.LJ @(Z5+ W"?(1"#2D3R"S2"U=0J (+UJ
从 A"28"+(+. 模板的 3/,.(2 类 别 中 选 择 一 个 计 时 器 )X52(# *! 添 加 入 W"?(1"#2 表 格 中 ! 设 置 其 )+.(#?=0 属 性 为 \]]] ) 可 根 据 需 要 自 定 义 *! 再 为 其 7+X52(# 事 件添加语句 <0",( + 加 入 一 个 X52(# 部 件 目 的 是 用 以 控 制 闪 现 窗 口 显 示时间 % 在此 ! W"?(1"#2 显示了 \ 秒钟后关闭 ! 主窗口
用 ^(08R5 语言 编写程序启动画面
徐科 ! 安徽省六安市医保中心 " 六安 !"#$$$ # 在启 动 程 序 之 前 出 现 启 动 或 提 示 画 面 ! 也 叫 做 闪 现窗口 ! 它往往能使编写的程序显得更成熟 " 实现的办 法 很 多 !有 些 是 采 用 窗 口 调 用 方 法 !有 些 是 采 用 #记 时 器 $ 来延时 % 下面介绍几种的方法 ! 给大家作参考 " 方法一 & 建一个启动封面窗体 ! 假设为 !"#$% ! 先设 置 好 &"#’(#)*"+, ’&"#’(#-./0(’1"#23./0( ’4",5.5"+! 接 着 在窗体上加入 图 片 框 ’ 文 本 框 ! 设 置 好 后 在 菜 单 里 选

delphi编程制作程序启动欢迎界面

delphi编程制作程序启动欢迎界面

delphi编程制作程序启动欢迎界面以前没接触过编程的时候,看到一些软件启动的时候总有欢迎界面,如灰鸽子启动界面.就一直很想学会这个,现在这里有个制作欢迎界面的代码的详细分析,大家参考下登陆窗体命名為:loginform.找到工程文件(Project -> View Source),找到如下代碼部分:beginApplication.Initialize;Application.CreateForm(TForm1, Form1);Application.CreateForm(Tloginform, loginform);Application.Run;//到此,程序執行end.登陸窗體可以設置成在程序執行前創建:beginApplication.Initialize;//初始化loginform:=tloginform.Create(application);//動態創建啟動窗體loginform.Show;//顯示loginform.Update;sleep(2000);//系統延時2秒loginform.Hide;//2秒后啟動窗體隱藏Application.CreateForm(TForm1, Form1);Application.CreateForm(Tloginform, loginform);loginform.Free;//釋放啟動窗體Application.Run;end.制作啟動(歡迎)窗體的另一種方法(轉載...當然自己也使用過~~):设置封面窗体属性使之符合启动封面要求。

请修改下列封面窗体属性:Position = PoscreenCenter//运行时居于屏幕中央Autosize = true//自动适应Image控件,使启动图片完整显示BorderStyle = bsnone//窗口无标题栏及最大化、最小化及关闭按钮和边框Name = splashform程序代码解析选择主菜单下的Project/View Scource 命令,打开这个项目的项目文件。

delphi制作登陆界面

delphi制作登陆界面

delphi制作登陆界面/////////////////////(一)项目文件test.dpr ////////////////////// program SerialGet;usesForms,UMain in UMain.pas {frmMain},ULogin in ULogin.pas {frmLogin},UDataModule in UDataModule.pas {DataModule1: TDataModule},{$R *.res}beginApplication.Initialize;if CreateMutex then //创建句柄,判断此应用程序是否在运行begin//调用全局函数,创建并显示登陆界面if doLogin then //登陆成功beginApplication.CreateForm(TfrmMain, frmMain);//数据模块文件不须在这儿创建,因为 ULogin.pas 中已创建//Application.CreateForm(TDataModule1, DataModule1);Application.Run;end else //登陆不成功begintryDataModule1.free;Application.terminate;exceptend;end;end elsebeginDestroyMutex; //释放句柄end;end.////////////////(二)登陆窗体ULogin.pas ULogin.dfm ////////////////// unit ULogin;interfaceuses ......type... ... ...privatefunction checkPsw:integer;publicend;varfrmLogin: TfrmLogin;function doLogIn:boolean; //全项目公用函数function CreateMutex: Boolean; //全项目公用函数procedure DestroyMutex; //全项目公用函数implementationuses UDataModule; //引用数据模块var Mutex: hWnd;{$R *.dfm}function doLogIn:boolean; //由项目文件调用此函数beginwith TfrmLogin.create(application) do //创建并显示登陆界面begin//窗体的ShowModal属性if ShowModal = mrok then result := true else result := false; free;end;procedure DestroyMutex;beginif Mutex <> 0 then CloseHandle(Mutex);end;function CreateMutex: Boolean;varPrevInstHandle: THandle;AppTitle: PChar;beginAppTitle := StrAlloc(100);StrPCopy(AppTitle, Application.Title);Result := True;Mutex := Windows.CreateMutex(nil, False, AppTitle);if (GetLastError = ERROR_ALREADY_EXISTS) or (Mutex = 0) then beginResult := False;SetWindowText(Application.Handle, );PrevInstHandle := FindWindow(nil, AppTitle);if PrevInstHandle <> 0 then beginif IsIconic(PrevInstHandle) thenShowWindow(PrevInstHandle, SW_RESTORE)elseBringWindowT oTop(PrevInstHandle);SetForegroundWindow(PrevInstHandle);end;if Mutex <> 0 then Mutex := 0;end;StrDispose(AppTitle);// -1:密码不对 1:数据库不对 2:没有此用户 3:合法function TfrmLogin.checkPsw:integer;var name,sPsw,SQL,sValue:string;beginApplication.CreateForm(TDataModule1, DataModule1); //此处创建了数据模块if not DataModule1.ConnOK thenbegin result := 1; exit; end;name := lowercase(editName.text); //文本框sPsw := lowercase(editPass.text); //文本框sql := select * from maker where name="+name+";if openSQL(SQL,DataModule1.dsDataSet) <=0 thenbegin result := 2; exit; end;DataModule1.dsDataSet.FirstsValue := lowercase(DataModule1.dsDataSet.fieldbyName(loginPsw). asString);if sValue<>sPsw then result := -1 else result := 3;end;/////////////////////(三)数据模块UDataModule.pas ////////////////////// ... ... ... ...typepublicConnOK:boolean;end;varDataModule1: TDataModule1;function OpenSQL(s: string;query:TADODataSet):integer;function DoSQL(s: string;query:TADOQuery):boolean;implementation{$R *.dfm}procedure TDataModule1.DataModuleCreate(Sender: TObject); //连接ADOConnection var SQL,pwd:string;begintrypwd := deliSerial;SQL := Provider=Microsoft.Jet.OLEDB.4.0;Data Source=+extractfilepath(paramstr(0))+SerialInfo.mdb+Persist Security Info=False; +Jet OLEDB:Database Password="+pwd+";ADOConnection1.Connected := false;ADOConnection1.ConnectionString := SQL;ADOConnection1.Connected := true;ConnOK:=true;exceptConnOK:=false;end;end;function OpenSQL(s: string;query:TADODataSet):integer; //查询SQLvar old_Cursor:TCursor;beginold_Cursor:=screen.cursor;screen.cursor:=crSQLWait;trytrywith query dobeginclose; commandtext:=s; open;result:=query.recordcount; //返回结果集记录数end;exceptresult:=0;end;finallyscreen.cursor:=old_Cursor;end;end;function DoSQL(s: string;query:TADOQuery):boolean; //运行SQL var old_Cursor:TCursor;beginresult:=true;old_Cursor:=screen.cursor;screen.cursor:=crSQLWait;trytrywith query dobeginclose; SQL.Clear; SQL.Add(s); ExecSQL;end;exceptresult:=false;end;finallyscreen.cursor:=old_Cursor;end;end;。

Delphi 第8章 界面设计

Delphi  第8章 界面设计

Win32选项卡的常用组件
在设置windows应用程序用户界面时,常用到: Tabcontrol组件 Pagecontrol组件 RichEdit组件 StatusBar组件 Toolbar组件
Tabcontrol组件
TabControl是一个标准windows风格的组件,通过它能够给 窗体创建选项卡,其为可视化组件。其运行界面如下:
FontDialog对话框主要属性
FontDialog组件的主要属性如下: Font属性:用来指定所需的字体。 MinFontSize:用来设置最小允许的字体大小,如果设为0则表 示 没有字体尺寸大小的限制。 Device:只有设置了此属性才能知道从哪里可以得到可用的字 体,可选择以下值: fdScreen:来源于屏幕字体(默认值) fdPrinter:来源于打印机字体 fdBoth:既可来源于屏幕字体,也可以来源于打印机字体。
第8章 窗体设计
菜单的创建
菜单界面及主菜单设计
弹出型菜单设计
工具栏的创建
状态栏使用 对话框设计
8.1 菜单设计
•创建主菜单 •创建快捷菜单 •使用菜单模板
主菜单设计
MainMenu控件的设计
方法一:选择standard标签页中的 ,用鼠标 右键单击 MainMenu 控件图标,打开一个 弹出式菜单,从中选择MenuDesigner命令, 将打开设计面板。
SaveDialog对话框
SaveDialog组件对应于“另存为“对话框,它的属性.方法 和事件与OpenDialog完全相同,只是Options属性中有一项 OfOverwritePrompt子属性,如果指定的文件名已存在,那 么选中此项,表示要显示一个警告框让用户选择是否要覆盖 已存在文件。其运行界面如下:

delphi的精美界面设计

delphi的精美界面设计

Delphi界面设计专辑[前言:]界面的美观和用户亲和性是应用软件成功的首要条件,因此界面往往是程序员最费心的地方。

在这个专辑中,将向读者全面介绍Delphi中界面设计的原则和技巧窗体设计制作固定大小的Form固定的Form像一个对话框,何不试试下面的语句巧用Delphi制作溅射屏幕精心编写的WINDOWS程序显示启动注意事项,称之为溅射屏幕(splash screen)。

利用一点儿小小的内容,即可给程序的显示添加不少色彩LED数码管仿真显示程序在电子设备上广泛地使用LED数码管显示数据,在许多应用软件中也经常模拟LED数码管显示数据,使程序画面看起来很有特色菜单设计DELPHI中自适应表单的实现我们知道,屏幕分辨率的设置影响着表单布局,假设你的机器上屏幕分辨率是800*600,而最终要分发应用的机器分辨率为640*480,或1024*768,这样你原先设计的表单在新机器上势必会走样作非常规程序菜单掌握delphi高级秘籍大家可能见过诸如金山毒霸,瑞星杀毒,以及五笔输入法等等在系统托盘(即右下角有时间和输入法图标的地方)在的控制菜单,而在正常的任务栏(即屏幕最下方的“开始”按钮的右边的各式各样)中却不出现按钮的程序,即我们常说的在后台运行的程序用Delphi制作动态菜单所谓动态菜单是指菜单项随着程序的操作变化而变化。

现在,我们用Delphi来实现这一功能,具体步骤如下工具栏和状态条为Windows窗口标题栏添加新按钮对于我们熟悉的标准windows窗口来讲,标题栏上一般包含有3个按钮,即最大化按钮,最小化按钮和关闭按钮。

你想不想在Windows的窗口标题栏上添加一个新的自定义按钮用Delphi4实现风Word97格的工具栏用过Word97的人对它的工具栏印象很深刻,因为它的风格很“酷”,同样IE4.0的工具栏也有类似的风格,Win98的出现,使这种风格的工具栏得到了推广如何隐藏和显示Windows的任务条如果隐藏和显示Windows的任务条?仅仅调用以下的函数就可以.其他技巧Delphi利用Windows GDI实现文字倾斜在Delphi开发环境中,文字的输出效果一般都是头上脚下的"正统"字符,如何输出带有一定倾斜角度的文字以达到特殊的显示效果呢Delphi之三十六计之界面篇设置状态栏面板对象的Style为OwnerDraw,并在状态栏对象的DrawPanel事件中书写以下代码利用COM技术实现外壳扩展的属性页当用户在资源管理器中调用右键菜单时,会显示一个"属性"菜单项,点击属性菜单项会显示一个属性页,用户可以获得甚至修改文件信息制作固定大小的Form固定的Form像一个对话框,何不试试下面的语句?C++ Builder请参照Delphi的例子Delphi您可以覆写CreateParams() 这个TWinControl 的虚拟程序, 改变form的wc.Stylee, 将WS_SYSMENU 这个旗标解除, 这样, 就不会有左上角的SystemMenuBox 了.至於不能移动.缩小/放大, 可以自已拦下WM_NCHITTEST, 然後一概回应滑鼠点在视窗Client 区域, 相信这个视窗就呆呆的不会动了.详情可以查一下Win32API Help 的CreateWindow() 与WM_NCHITTEST 的说明.unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls,Forms, Dialogs, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;procedure Button1Click(Sender: TObject);private{ Private declarations }procedure WMNCHitTest(var Msg: TMessage); message WM_NCHITTEST;protectedprocedure CreateParams(var Params: TCreateParams); override;public{ Public declarations }end;varForm1: TForm1;implementation{$R *.DFM}巧用Delphi制作溅射屏幕精心编写的WINDOWS程序显示启动注意事项,称之为溅射屏幕(splash screen)。

Delphi用户界面设计

Delphi用户界面设计
Delphi用户界面设计
• 主要实现的功能
– 查询货物
• 所有人都可以查询货物,无需权限
– 购买
•需要客户输入帐号和密码
– 允许创建新帐号 – 显示该客户的信息和采购情况,并备份
• 购买后生成出库订单
Delphi用户界面设计
• 主要实现的功能
– 入库
• 需要管理员输入用户名和密码 • 修改后显示仓库入库情况,并备份
Delphi用户界面设计
– 页面2
• 可以注册新 用户 • 可以修改原 用户信息
Delphi用户界面设计
– 页面3
• 进行管理员 密码提示 • 密码正确后 可以修改 顾客、供应 商和商品 信息(给出 import表)
– 信息修改
• 客户
– 需要客户输入帐号和密码,然后可以修改自己的信息
• 管理员
– 需要管理员输入用户名和密码,然后可以修改自己和所有 客户的信息
Delphi用户界面设计
• 具体实现方式
– Delphi – 页面1
• 选择类型并 显示商品 • 客户登陆成功 后 可以采购 • 输出该客户的 import表

用户登录与权限设计的报告(delphi)

用户登录与权限设计的报告(delphi)

实验三用户登录与权限设计的报告课题要求:用户登录与权限设计设计实现用户登录和用户权限的管理,实现用户按权限访问资源,管理员按要求授予用户权限,登录程序安全稳定,设计用户菜单及程序调用。

普通用户的信息表主要包括:普通用户编号、用户名、密码、权限。

管理员的信息表有:管理员编号、管理员名称、密码、权限。

当然管理员的权限会比较大一点,能授予普通用户的权限,而普通用户不行。

数据库定义的表或其它对象以及窗体、程序名、程序内公共的变量,我都采用“xg050234_+名称”进行定义。

我用SQL2000里面建立数据库xg050234_database,在数据库里面的表添加有xg050234_auth、xg050234_supauth,运用ADOConnection控件进行数据库的连接,ADOQuery来设置SQL语句查询,需要数据源DataSource来对数据库进行存储。

而且每个窗体都会命名为与之相关的操作。

设计的思路:这个设计比较简单,下面来介绍下我的大概设计思路:首先,我是先设计登录的窗体,在登录的窗体上有edit控件用来输入账号的名称和密码,在设置两个单选RadioButton控件用来选择是普通用户登录还是管理员登录,再设置两个按钮button来进行登录或是关闭。

原来就在设置好了主窗体里面的菜单控件和状态栏控件。

在菜单控件里面设置五栏分别为人员档案管理、仓库物料管理、进出仓单管理、用户权限管理和系统退出,人员管理的子菜单有分别有添加、查询、修改、删除的操作,点击这些子菜单时便可进入到相应窗口进行对xg050234_danan表的添加、查询、修改、删除的操作,物料管理的子菜单分别有添加、查询、修改、删除的操作,当点击这些子菜单时便可进入到相应窗口进行对xg050234_wuliao表的添加、查询、修改、删除的操作,而进出仓单管理的子菜单分别有进出单xg050234_iodan的存储和查询,用户权限管理的子菜单有对授予用户权限,进入窗体可以修改xg050234_auth来修改普通用户权限,系统退出的子菜单有个退回,用来回到登录的界面。

Delphi_7_用户界面设计

Delphi_7_用户界面设计

[例7-7]
5. InputBox函数
function InputBox(const Acaption,Aprompt, AdefaultMsg:string;):string;
6. MessageDlgPosHelp函数
function MessageDlgPos(constMag:string; DlgType:TMsgDlgType;Buttons:TmsgDlgButtons; HelpCtx:Longint;x,y:Integer; const HelpFileName:string):Word;
设计File ->Open Close 对这二个菜单设计工具栏 组件栏中【Standard】卡,取Panel组件,形成长条,准
备作工具的承载面板,快捷工具按钮将建在其上。它是容 器组件。 Caption: 空,Name: ToolPanel,Align: alTop(顶端, 标题、菜单的下方)
在组件栏中【Additional】卡,取两个组件 SpeedBotton 加在ToolPanel上。
BevelIner(内线):bvLowered 在StatusPanel组件上加4个Panel组件和4个Label组件,分 别是:
4 个 Panel 组 件 : InsPanel,DelPanel,CapsPanel,
NumPanel Caption: 空, BevelOuter(外线):None, BevelIner(内线):bvLowered
可视化程序设计语言 Delphi 7
第7 章
用户界面设计
7.1 菜单设计
菜单是Windows应用程序最常用的交互方式,菜单 有下拉式菜单和弹出式快捷菜单,Delphi7提供 了可视化组件TmainMenu和PopupMenu来创建下拉 式菜单和弹出式快捷菜单。

使用Delphi2009构建用户界面

使用Delphi2009构建用户界面

Corporate Headquarters EMEA Headquarters Asia-Pacific Headquarters100 California Street, 12th Floor San Francisco, California 94111 York House18 York RoadMaidenhead, BerkshireSL6 1SF, United KingdomL7. 313 La Trobe StreetMelbourne VIC 3000AustraliaTech NotesBuilding User Interfaces with Delphi 2009 An Improved Visual Component Library Streamlines Modern Windows Application DevelopmentMarco CantùDecember 2008I NTRODUCTION : T HE V ISUAL C OMPONENTL IBRARYThe Visual Component Library (VCL) is one of the cornerstones of Delphi and its architecture has significantly contributed to the success of the tool. Most of the “Delphi experience” relates to the VCL, and this white paper focuses on the development of the user interface of Delphi applications.With four new components (BalloonHint, ButtonedEdit, CategoryPanelGroup, and LinkLabel) plus Ribbon support and countless small enhancements, the VCL has seen a significant update in Delphi 2009. Some of these updates are specific for Windows XP or Windows Vista andfurther enhance the high-quality support for Vista that's been part of the VCL since Delphi 2007. C USTOM H INTS AND B ALLOON H INTSThe Tcontrol class introduces a new property, CustomHint , and its parent property, ParentCustomHint , to let child objects share the value defined by the parent control: property CustomHint: TCustomHint read GetCustomHint write SetCustomHint; property ParentCustomHint: Boolean read FParentCustomHint write SetParentCustomHint default True;CustomHint lets you hook a custom hint object to any visual component that is an object of any class inheriting from TCustomHint . One such class is the new TballoonHint . It is a simple and adds little to what the base TCustomHint class already provides, but itsarchitecture is more flexible than having only balloon hint support, as you can add your own custom hint classes and use them for any control.You can the BalloonHint component out-of-the-box. Simply place this non-visual component in a form and hook it to the CustomHint property of a control to change the way the hint is displayed. You can see a BalloonHint component in Figure 1:Here are the related settings from the DFM file of a button and its custom hint:object btnCustomHint: TButton Hint = 'This is a hint for the button' CustomHint = BalloonHint1 ShowHint = True end objectBalloonHint1: TBalloonHintFigure 1 BalloonHint Component in Delphi 2009Images = ImageList1 endThe BalloonHint component uses the hint provided by the control to which it is hooked. As auser mouses over the button, the hint displays nicer than in the past as shown in Figure 2:Using the ParentShowHint and ParentCustomHint properties you can define this setting on a panel and have balloon hints active on each of the controls hosted by the panel. You might have noticed in the DFM listing previously that the BalloonHint component has an Images property, but no image is displayed. One way to set other runtime properties of the BalloonHint component, including the Title and the ImageIndex , (and have a nicer looking hint) is to manually invoke the hint.As this requires a lot of work, there is another easier way to set the title and the image index of the custom hint object connected with a control. Since the early days of Delphi, the Hint property allowed you to specify a short hint (used as hint) and a longer version (generally for a StatusBar message) separated by the pipe character (|). Using the custom hint association, the Hint property is now interpreted as follows:title|message|imageindexFor example, I've customized a button as follows (the value of the hint is a single string) and the display is shown in Figure 3:object Button3: TButton Hint = 'This is a button|' + 'This is a longer description for the button, ' + 'taking some space|2' CustomHint = BalloonHint1 Caption = 'Button3' endFigure 2 BalloonHint DisplayFigure 3 Custom ButtonE NHANCEMENTS TO B UTTONS AND E DITSAlthough some new features affect all controls, most of the Delphi 2009 improvements in theVCL are specific to individual controls. In this section I'll focus on the enhancements of some ofthe standard Windows controls, like buttons and edit boxes.B UTTONS G ET N EW F EATURESYou might think that the classic Windows push buttons are well-established, stable controls.That's actually not true. Since Windows XP, you can hook an image from an image list to abutton, and have a graphical bitmap button without having to derive a custom owner-drawncontrol as Delphi did since the early days with the BitBtn (bitmap button) control. With Delphi2009 you can now have the same graphical effect with a plain and standard TButton. Image list support comes through a series of properties you can use to determine which image to usein each of various states of the button. Here is the list of the new image-related properties ofthe TCustomButton class, listed with only their types:property DisabledImageIndex: TImageIndex ...property HotImageIndex: TImageIndex ...property ImageAlignment: TImageAlignment ...property ImageIndex: TImageIndex ...property ImageMargins: TImageMargins ...property Images: TCustomImageList ...property PressedImageIndex: TImageIndex ...property SelectedImageIndex: TImageIndex ...Since this feature was introduced in the Win32 API in Windows XP, if your application needs torun on Windows 2000, you should use it with care or avoid using it altogether.Similarly, if your program is meant to run on Vista, you can activate more new features, includingthe command link style used by many Vista dialogs and split-button styles that let you hook adrop-down menu to the button, which is activated by pressing the small drop-down arrow. Theoverall layout of the button is determined by the value of the new Style property of an enumerated type defined as a nested type of the TCustomButton class:typeTButtonStyle = (bsPushButton, bsCommandLink,bsSplitButton);There are further properties you can use, depending on the selected style:z With the split button style (in the API, the BS_SPLITBUTTON style value) you can use the DropDownMenu property (of type TPopupMenu) and customize it in theOnDropDownClick event.•With the command link type (in the API, the BS_COMMANDLINK style value) you can use the default icon (a green arrow) or a specific image (as mentioned earlier) and provide more information about the action with the new CommandLinkHint string property.•The ElevationRequired property, applicable both to a standard button and to a command link one, enables the display of the Windows shield to be used if the button leadsto a UAC-protected operation. The ElevationRequired property sends theBCM_SETSHIELD message to the button.Using all of these new properties can affect the layout of your application quite radically, although you can obtain some of these user interface effects only if the application runs on Windows Vista (or later versions). These properties are not very complex to use, so rather than describing an example in detail, I'll simply list its key elements, after showing you the design-time form in Figure 4:Figure 4 New Button PropertiesThis is the summary of the DFM file of the project:object FormButtonsDemo: TFormButtonsDemoobject Button1: TButtonImageIndex = 0Images = ImageList1PressedImageIndex = 1endobject Button2: TButtonImageIndex = 1Images = ImageList1PressedImageIndex = 2endobject Button3: TButtonDropDownMenu = PopupMenu1Style = bsSplitButtonendobject Button4: TButtonCommandLinkHint = 'This is a command link hint'Style = bsCommandLinkendobject Button5: TButtonCommandLinkHint = 'Another hint'ImageIndex = 1Images = ImageList1Style = bsCommandLinkendobject Button6: TButtonElevationRequired = TrueStyle = bsCommandLinkendobject ImageList1: TImageList...object PopupMenu1: TPopupMenu...endE DITS G ET M ANY N EWF EATURESThe Edit control is another standard and classic control of Windows that over the years got new features (particularly in Windows XP), some of which are now easily accessible using new properties of the TEdit class:z The Alignment property enables the alignment of the text of the edit control, a feature that was previously available only for DBEdit controls (and implemented in native VCL code, as it wasn't available in early versions of the Win32 API). Setting the alignment activates the ES_LEFT, ES_RIGHT, or ES_CENTER Windows styles, eventually requiring the system to recreate the Edit window (so you should try to avoid changing this property at runtime once the Edit box has been displayed).z The NumbersOnly property sets the ES_NUMBER style of the Edit control, which requires Windows XP or later. This applies an input filter that prevents user from typing non-digit keys, but still let's them paste non-numeric text (and lets the program freely set the Text property).z The TextHint property supports in-place text hints displayed when the edit box is empty (again this requires Windows XP or later). The text hint could act as a replacement for a descriptive label, or reinforce one providing a call to action for the user.z The PasswordChar property let's you set a custom password char (replacing the default asterisks, in Windows XP, or round dots, in Windows Vista) with a character or symbol of your own choice. This feature not only requires Windows XP or later but also a themed application.These properties are also available in components that relate to the Edit control, such as LabeledEdit (a combination of an Edit and a Label) and the classic MaskEdit control of the VCL. Alternatively, the DBEdit control doesn't provide the new features of other edit controls. Actually, to be more precise, it inherits the new features from the base TCustomEdit class but doesn't expose them in published properties.In Figure 5 , you can see some of these features (and others I'll explain later) in action:On the left side of the form you can see four edit boxes using some of the new features. The first has its text right aligned, the second displays a text hint, the third allows only numeric input, and the fourth uses Unicode CodePoint 25A0 (Black Square) as its password character. (It is nice that you can use any Unicode symbol for the password character.)This is the most relevant portion of the DFM file, describing the properties those four controls: object edRightAlign: TEdit Alignment = taRightJustify Text = 'Text on the right' end object edTextHint: TEdit TextHint = 'Your name' end object edNumber: TEdit NumbersOnly = True Text = '3' end object edPassword: TEdit PasswordChar = #9632 Text = 'password' endThe button close to the first edit lets you switch the alignment property in a round robin fashion, by increasing the value of the enumeration and computing the modulus (the rest of the division) with the highest possible value:procedure TFormEditFamily.btnAlignClick(Sender: TObject); begin edRightAlign.Alignment := TAlignment ( (Ord(edRightAlign.Alignment) + 1) mod (Ord(High(TAlignment)) + 1)); end;Figure 5 Runtime Example of Edit ControlsT HE N EW B UTTONED E DIT C ONTROLA new control that extends the behavior of the Edit control is the ButtonedEdit component, which is a custom VCL control defined in the ExtCtrls unit. This is basically an edit box that can have small buttons on the left or right side, used to interact with the edit box itself. For example, you can add a Cancel button that empties the edit box, and a search or lookup button that validates the input or looks for some related information. (The Delphi IDE uses this component for the Search option of the Tools Palette.)This component (which requires Windows XP or later) includes all of the new features of the Edit control including the modern-looking text hint. Setting up the buttons on the sides of the edit box is quite simple. The component has a LeftButton and a RightButton property, of type TEditButton, defined as:typeTEditButton = class(TPersistent)publishedproperty DisabledImageIndex: TImageIndex;property DropDownMenu: TPopupMenu;property Enabled: Boolean;property HotImageIndex: TImageIndex;property ImageIndex: TImageIndex;property PressedImageIndex: TImageIndex;property Visible: Boolean;end;All of the image references are to the ImageList component that you can hook to the ButtonedEdit control. You can attach a method to the click either button using the OnLeftButtonClick and OnRightButtonClick events of the ButtonedEdit control. You can also attach a Popup menu to the buttons using the DropDownMenu property of the TEditButton class.I've coded some usage scenarios to give you an idea of how to work with this component. These scenarios also show some of the other new features introduced for edit boxes. The main form of the example uses three ButtonedEdit controls, two with a single button and one with two buttons. The controls have also text hints and one of them has a drop-down menu attached. You can see the form at runtime (with the drop down menu active) in Figure 6:The first control is a numeric edit box with an undo button. TheedUndoRightButtonClick event handler calls the Undo method of the ButtonedEdit control:object edUndo: TButtonedEdit Images = ImageList1 NumbersOnly = True RightButton.ImageIndex = 0 RightButton.Visible = True TextHint = 'A number' OnRightButtonClick = edUndoRightButtonClick endThe second edit control provides two buttons, one for pasting from the clipboard and the second to clear the edit box content (thus restoring the text hint):object edClear: TButtonedEdit Images = ImageList1 LeftButton.ImageIndex = 3 LeftButton.Visible = True RightButton.ImageIndex = 1 RightButton.Visible = True TextHint = 'Some text' OnLeftButtonClick = edClearLeftButtonClick OnRightButtonClick = edClearRightButtonClick endThe third edit box has a history button, and keeps track of the text that is entered in the window, allowing a user to reselect it:object edHistory: TButtonedEdit Images = ImageList1RightButton.DropDownMenu = PopupMenu1Figure 6 Runtime Example of ButtonEditRightButton.ImageIndex = 2RightButton.Visible = TrueTextHint = 'Edit or pick'OnExit = edHistoryExitendThe component works by adding each new text to the popup menu as the user leaves the edit box, provided this text is not already in the menu:procedure TFormButtonEdits.edHistoryExit(Sender: TObject);beginif (edHistory.Text <> '') and(PopupMenu1.Items.Find (edHistory.Text) = nil) then beginPopupMenu1.Items.Add (NewItem (edHistory.Text, 0,False, True, RestoreText, 0, ''));end;end;The predefined menu items and each new menu item added dynamically are connected with the RestoreText event handler which takes the caption of the selected menu items, strips any hot key, and copies it to the edit box:procedure TFormButtonEdits.RestoreText(Sender: TObject);beginedHistory.Text := StripHotkey ((Sender as TMenuItem).Caption);end;G ROUPING IN A L IST V IEWOne common control worth exploring in some more detail is the ListView. In Delphi 2009, that ListView control has direct support for grouping. This feature requires Windows XP or Vista, with the latter providing extended features lacking in the former.There are three new properties in the ListView control. The Boolean GroupView enables this new kind of display, the GroupHeaderImages refers to an ImageList containing the images for the group headers, and the Groups property is a collection of group definitions. Each group can have a main title (Header), a related icon (TitleImage), a longer description (Subtitle), a footer line (Footer), plus some more text elements and alignment properties for headers and footer. A set of options lets you set the group as collapsible, remove the header, hide the group, and so on.You can see an example of grouping in a ListView in the main form of the following runtime example, displayed in Figure 7:This is the definition of the groups inside the ListView control (in DFM format), in which I've set a couple of extra descriptions that will show up only if you center the group headers:object ListView1: TListView Groups = < item Header = 'Arrows' Footer = 'Footer: You can pick any of the arrows ' + 'for the caption' GroupID = 0 State = [lgsNormal, lgsCollapsible] HeaderAlign = taLeftJustify FooterAlign = taLeftJustify Subtitle = 'Subtitle: Arrow group subtitle' TopDescription = 'Top Descr: A group of arrows' TitleImage = 0 SubsetTitle = 'Subset title...' end item Header = 'Houses' Footer = 'Which house would you prefer?' GroupID = 1 State = [lgsNormal, lgsCollapsible]HeaderAlign = taLeftJustifyFigure 7 Runtime Example of ListView Control EnhancementsFooterAlign = taLeftJustifySubtitle = 'Houses with different colors for ' +'the roof...'TitleImage = 1ExtendedImage = -1end>GroupHeaderImages = ImgGroupsGroupView = TrueendThe only code of the example is used to change the alignment of the header and footer of each group. This is the event handler of one of the three toolbar buttons:procedure TFormGroupingList.tbRightClick(Sender: TObject);varaGroup: TCollectionItem;beginfor aGroup in ListView1.Groups dobegin(aGroup as TListGroup).HeaderAlign := taRightJustify;(aGroup as TListGroup).FooterAlign := taRightJustify;end;end;Besides grouping support, the ListView control has another unrelated new event, OnItemChecked, triggered when a user selects an item of the ListView.T HE N EW C ATEGORY P ANEL G ROUP C ONTROLOver the years, the so-called Outlook Sidebar family of components has seen the largest number of VCL controls available, mimicking the well-established interface that was originally introduced by the Microsoft email program.Styles have changed a lot from the original collection of large icons used for the various sections of the program, but the usage of a sidebar with options and commands continues. For the first time, Delphi 2009 offers a similar component out of the box.The CategoryPanelGroup control is a visual container of CategoryPanel controls. You create these category panels using the shortcut menu of the CategoryPanelGroup at design time or calling its CreatePanel method at runtime. The individual CategoryPanels refer to the container using the PanelGroup property, while the grouping controls has a Panel property (a bare-bones TList of pointers) or a list of child controls, in the standard Controls property.If you try adding any other control directly to the CategoryPanelGroup the IDE will show the error “Only CategoryPanels can be inserted into a CategoryPanelGroup.” Of course, once you've defined a few CategoryPanels you can add virtually any control you like to them.Figure 8 shows the user interface of this control, taken from the CategoryPanels demo:The grouping control and the individual panels have a plethora of properties which you can use to customize the user interface, managing headers with multiple images depending on their collapsed or expanded status, activate gradient backgrounds for the headers, change the font and the Chevron colors, and much more.These are the settings of the panels above (from which I've removed details of the hosted controls):object CategoryPanelGroup1: TCategoryPanelGroup VertScrollBar.Tracking = True HeaderFont.Charset = DEFAULT_CHARSET HeaderFont.Color = clWindowText = 'Tahoma' Images = ImageList1 object CategoryPanel1: TCategoryPanel Caption = 'CategoryPanel1' CollapsedImageIndex = 0 ExpandedImageIndex = 0 object Button1: TButton... object Button2: TButton... end object CategoryPanel2: TCategoryPanel Caption = 'CategoryPanel2' Collapsed = TrueCollapsedImageIndex = 2Figure 8 Category Panels ControlExpandedImageIndex = 1object CheckBox1: TCheckBox...object CheckBox2: TCheckBox...object CheckBox3: TCheckBox...endobject CategoryPanel3: TCategoryPanelCaption = 'CategoryPanel3'object GridPanel1: TGridPanelAlign = alClientCaption = 'GridPanel1'ControlCollection = <...>ShowCaption = Falseobject Button3: TButton...object Button4: TButton...object Button5: TButton...object Button6: TButton...endendendIf we look at the header images, the first panel uses the same one for both states, the second uses two different images for the expanded and collapsed states, while the third has no custom images and uses the default Chevron symbol. The third CategoryPanel doesn't host its controls directly, but has a GridPanel (with 4 buttons) aligned to its entire surface. This is an example of how you can combine a CategoryPanel with panels providing custom positioning.I MPROVED G RAPHICS S UPPORTIn the early days, Delphi graphic support was mostly limited to bitmaps. Over the years, there have been extensions to the image formats you could use in the Image component, including JPEG format support. In Delphi 2009, the support for multiple images has been extended to PNG and all formats can now be used with the Image control as well with the ImageList control.Moreover, the ImageList control supports setting a specific color depth, although increasing its value clears all images from the current image list. There have also been enhancements in the ImageList editor and alpha channel support.Additionally, the TBitmap class now supports the alpha channel, using the new AlphaFormat property, while TGraphic class has support for transparent images using the SupportsPartialTransparency property.As there are many changes, I've picked a few worth underlining in the GraphicTest program. I’ll start with the most significant change which is the native support for multiple formats, including PNG (which is new). The support for the formats comes from a set of units that define inherited TGraphic classes that you can selectively include in your application. Here are the units and the graphics classes they make available:Format Unit ClassJPEG jpeg.pas TJPEGImageTGIFImage GIF GIFImg.pasTPngImage PNG pngimage.pasBy including the corresponding unit, you can directly load a file of those formats (plus the standard Bitmap, Icon, and Metafile formats) into an Image component. Because the format is determined by the file extension, you can easily load graphic files with different formats with simple code like:procedure TFormGraphicsTest.btnLoadImageClick(Sender: TObject);varstrFilename: string;begincase fImgNo of0: strFilename := 'adog.jpg';1: strFilename := 'Athene.png';2: strFilename := 'CodeGear.gif';end;Image1.Picture.LoadFromFile(strFileName);fImgNo := (fImgNo + 1) mod 3end;The program also has some code to create an empty bitmap in memory. A user can draw on this bitmap by moving the mouse over the image control. The bitmap can then be saved in the three different formats. For example, the code for saving the file in JPEG format looks like this: varjpgImg: TJPEGImage;beginjpgImg := TJPEGImage.Create;tryjpgImg.Assign(Image1.Picture.Graphic);jpgImg.SaveToFile('test.jpg');finallyjpgImg.Free;end;To avoid repeating this code for the PNG and GIF formats, I've written a simple routine to take care of the various differences:procedure SaveWithClass (graph: TGraphic;graphClass: TGraphicClass; const strFilename: string);vargrapImg: TGraphic;begingrapImg := graphClass.Create;trygrapImg.Assign(graph);grapImg.SaveToFile(strFilename);finallygrapImg.Free;end;end;This works only with the default settings, though, as you'll need to work on the specific TGraphic descendant class to trigger its compression level and other specific options for the given format. In the demo program, the routine is called like this:SaveWithClass (Image1.Picture.Graphic,TPngImage, 'test.png');SaveWithClass (Image1.Picture.Graphic,TGIFImage, 'test.gif');The support for multiple image formats doesn't relate exclusively to the Image component, but it has also been extended to the ImageList component. This means you now have PNG-based image lists. I've already used an ImageList in other demos where I've loaded PNG images from the GlyFX library licensed by CodeGear and included in Delphi (and installed, by default, in the \Program Files\Common Files\CodeGear Shared\Images\GlyFX folder).I NTRODUCING THE F LUENT U SER I NTERFACEThe Fluent User Interface was invented by Microsoft, who is seeking a patent for it. This patent doesn't focus on the code behind the user interface (the ribbon controls used in Office 2007), but on the design of the user interface itself. Microsoft also refers to this user interface as “Microsoft Office Fluent UI.”If the Microsoft patent is granted, it will still apply even if the VCL implementation available in Delphi 2009 is a brand new version of the controls (in no way related with the code that Microsoft uses in Office and other applications, and that Microsoft doesn't license). That's why we have to look at the “legal side” of this component before looking at its use.Unlike other guidelines, the Office Fluent UI Design Guidelines, describing how applications based on the Ribbon should work, are not public, but are “Microsoft’s confidential information”. Microsoft asks anyone that wants to use their Fluent User Interface to accept the terms of their Office UI license. This license is royalty-free, but there are guidelines and limitations related to what you can do. The most significant issue is that you are not allowed to create programs which compete directly with Microsoft Office.For complete information, refer to the web site mentioned in the dialog box that appears while installing Delphi 2009:/officeuiOnce you agree with the license and register your application, you'll be able to download the 119-page PDF with the Office UI design guidelines.A S IMPLE R IBBONMy first Ribbon example is a very bare-bones demo showing how the component works, but actually providing no real user interface. As we'll see in the next section, the only real way to create a complete Ribbon-based user interface is to use the Action Manager architecture along with it. It is technically possible to use the Ribbon component without Actions, but it is very clumsy and extremely limited... so after a very simple example I'll move in that direction.We can, in fact, start some initial experiments with a plain Ribbon component, creating tabs and groups, and placing a couple of standard components into them. To follow my steps, create a new application and place a Ribbon component on its main form. Once you have thatcomponent in place you can use its shortcut menu (selecting it in the form or in the Structure pane) to add a new tab. The same menu will let you remove a tab or add the Application menu and Quick Access toolbar, as we'll see later on.You can also work on the Ribbon Tabs by using the Tabs collection of the Ribbon component (technically a collection of TRibbonTabItem objects, each of which is connected with a TRibbonPage , a sort of panel) and the related AddItem command. This is available in the Structure view as shown in Figure 9Error! Reference source not found.:The header of a Ribbon with two tabs and pages looks like Figure 10Error! Reference source not found.:In this case I've kept on the (default) ShowHelpButton property that shows the question mark in the top right of the control; I've also kept on the UseCustomFrame property (something I'll cover later on). Here are a few other properties of the Ribbon control of the example:object Ribbon1: TRibbon Width = 630 Height = 145 Caption = 'Ribbon Caption' DocumentName = 'Document Name' Tabs = < item Caption ='RibbonPage1'Figure 9 Structure View of Ribbon TabsFigure 10 Design Time View of a Ribbon with Two Tabs。

Delphi制作QQ自动登录器源码

Delphi制作QQ自动登录器源码
17 except
18 end;
19 Break;
20 end;
21 ClickTimes:=ClickTimes+1;
22 end;
23 if QQWnds.QStatusWnd=0 then begin //如果一直没有捕捉到设置状态窗体,顺序则自动退出
Delphi制作QQ自动登录器源码
以TM2009为例,检查了一下,未登录之前一个窗体,上边两个控件,登录以后,窗体捕获到一个控件,根据这个,首先找到QQ登录框,输入用户名,密码的位置,获取窗体句柄的具体代码如下:
这里先定义了一个record类型,
1 TQQWnd= record
2 QQWnd,QStatusWnd: HWND; //QQ窗口句柄,QQ弹出登录状态句柄
21 GetWindowTextAQQWnd.QQWnd, @WinTitle, SizeOfWinTitl;
22 if WinTitle<>'TM2009' then Continue;
23 end;
24 end;
25 end;
26
13 A QQWnd.QQPassWnd:= FindWindowExAQQWnd.QQWnd, 0, 'Edit', nil;
14 if AQQWnd.QQNumWnd<> 0and AQQWnd.QQPassWnd<> 0 then begin
15 Result:= True;
24 m.SendMSG_QQ_ERR, IntToStrQQRect.Left+''+ IntToStrQQRect.Top+ ''+ In

第8章 建立用户界面

第8章  建立用户界面


2. TrackBar
① Frequency属性表示每隔几个数值显示一个刻度。 ② LineSize属性与PageSize属性对应,表示比较小的变化时位置的改变。 ③ PageSize属性表示比较大的变化时位置的改变。 ④ SliderVisible属性用来设置是否显示滑动按钮。 ⑤ ThumbLength属性表示滑动按钮的宽度(或高度)。 ⑥ TickMask属性用来指定标尺显示的位置。

5. RadioButton

通常在使用单选按钮时,总是将其进行分组。在同一组中,只能同时选中一个按钮,其余按钮 自动取消选中。在实现单选按钮的分组时,可以有两种方法:
① 利用分组框组件(GroupBox)和单选按钮组件(RadioButton)实现。 ② 利用单选按钮分组框(RadioGroup)实现。可以通过ItemIndex属性来确定选中哪一个单选按钮。

3. SpeedButton

在加速按钮上可以同时显示图形和文字,用法与位图按钮很相似。
4. CheckBox
① 可以通过Alignment属性设置复选按钮上文字的位置。 ② 可以在设计阶段就设置好复选按钮的状态。通过Checked属性可以将复选按钮设置为“选中”和 “未选中”状态,通过State属性可以将复选按钮设置为“选中”、“未选中”或“部分选中”。
8.1.5 列表组件

4. ListView
① 在ListView中有一些图标,添加图标的方法与TreeView组件一样。 ② 通过对ListView组件的Columns属性进行设置,可以确定将要显示的列数, 并且可以为每一列指定文字的对齐方式、显示的宽度、图标索引号等。

5. ImageList

登录界面的原程序NV

登录界面的原程序NV

登录界面的原程序一个用Delphi开发的软件系统,它的登录界面如下:这个界面通过下述方式画出来,首先打开Delphi,新建一个窗体,调整它的大小如上图,在窗体中增加两个Label控件,名称分别为Label1,Label2;再在窗体中增加两个TEdit组件,名称分别为user,prd;在窗体中增加两个Button按钮,名称分别为CancelBtn,OkBtn;源程序如下:unit uPrd;interfaceuses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,Buttons,Dialogs;typeTPrdDlg = class(TForm)Label1: TLabel;Prd: TEdit;OKBtn: TButton;CancelBtn: TButton;Label2: TLabel;user: TEdit;procedure OKBtnClick(Sender: TObject);procedure CancelBtnClick(Sender: TObject);procedure FormCreate(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varPrdDlg: TPrdDlg;implementationuses umokk;{$R *.dfm}procedure TPrdDlg.OKBtnClick(Sender: TObject); beginif prd.Text =umokk.pprd thenself.Closeelsebeginshowmessage('口令不对!');self.Password.SetFocus ;application.Terminate ;end;end;procedure TPrdDlg.CancelBtnClick(Sender: TObject); beginapplication.Terminate ;end;end.。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

///////////////////// (一)项目文件 test.dpr //////////////////////
program SerialGet;
uses
Forms,
UMain in UMain.pas {frmMain},
ULogin in ULogin.pas {frmLogin},
UDataModule in UDataModule.pas {DataModule1: TDataModule},
{$R *.res}
begin
Application.Initialize;
if CreateMutex then //创建句柄,判断此应用程序是否在运行
begin
//调用全局函数,创建并显示登陆界面
if doLogin then //登陆成功
begin
Application.CreateForm(TfrmMain, frmMain);
//数据模块文件不须在这儿创建,因为 ULogin.pas 中已创建
//Application.CreateForm(TDataModule1, DataModule1);
Application.Run;
end else //登陆不成功
begin
try
DataModule1.free;
Application.terminate;
except
end;
end;
end else
begin
DestroyMutex; //释放句柄 end;
end.
//////////////// (二)登陆窗体 ULogin.pas ULogin.dfm //////////////////
unit ULogin;
interface
uses ......
type
... ... ...
private
function checkPsw:integer;
public
end;
var
frmLogin: TfrmLogin;
function doLogIn:boolean; // 全项目公用函数
function CreateMutex: Boolean; // 全项目公用函数
procedure DestroyMutex; // 全项目公用函数
implementation
uses UDataModule; //引用数据模块
var Mutex: hWnd;
{$R *.dfm}
function doLogIn:boolean; //由项目文件调用此函数begin
with TfrmLogin.create(application) do //创建并显示登陆界面
begin
//窗体的ShowModal属性
if ShowModal = mrok then result := true else result := false;
free;
end;
end;
procedure DestroyMutex;
begin
if Mutex <> 0 then CloseHandle(Mutex);
end;
function CreateMutex: Boolean;
var
PrevInstHandle: THandle;
AppTitle: PChar;
begin
AppTitle := StrAlloc(100);
StrPCopy(AppTitle, Application.Title);
Result := True;
Mutex := Windows.CreateMutex(nil, False, AppTitle);
if (GetLastError = ERROR_ALREADY_EXISTS) or (Mutex = 0) then begin
Result := False;
SetWindowText(Application.Handle, );
PrevInstHandle := FindWindow(nil, AppTitle);
if PrevInstHandle <> 0 then begin
if IsIconic(PrevInstHandle) then
ShowWindow(PrevInstHandle, SW_RESTORE)
else
BringWindowToTop(PrevInstHandle);
SetForegroundWindow(PrevInstHandle);
end;
if Mutex <> 0 then Mutex := 0;
end;
StrDispose(AppTitle);
end;
// -1: 密码不对 1:数据库不对 2:没有此用户 3:合法
function TfrmLogin.checkPsw:integer;
var name,sPsw,SQL,sValue:string;
begin
Application.CreateForm(TDataModule1, DataModule1); //此处创建了数据模块 if not DataModule1.ConnOK then
begin result := 1; exit; end;
name := lowercase(editName.text); //文本框
sPsw := lowercase(editPass.text); //文本框
sql := select * from maker where name="+name+";
if openSQL(SQL,DataModule1.dsDataSet) <=0 then
begin result := 2; exit; end;
DataModule1.dsDataSet.First ;
sValue := lowercase(DataModule1.dsDataSet.fieldbyName(loginPsw).asString);
if sValue<>sPsw then result := -1 else result := 3;
end;
///////////////////// (三)数据模块UDataModule.pas ////////////////////// ... ... ... ...
type
public
ConnOK:boolean;
end;
var
DataModule1: TDataModule1;
function OpenSQL(s: string;query:TADODataSet):integer;
function DoSQL(s: string;query:TADOQuery):boolean;
implementation
{$R *.dfm}
procedure TDataModule1.DataModuleCreate(Sender: TObject); //连接ADOConnection var SQL,pwd:string;
begin
try
pwd := deliSerial;
SQL := Provider=Microsoft.Jet.OLEDB.4.0;Data Source=+
extractfilepath(paramstr(0))+SerialInfo.mdb+
;Persist Security Info=False; +
Jet OLEDB:Database Password="+pwd+";
ADOConnection1.Connected := false;
ADOConnection1.ConnectionString := SQL;
ADOConnection1.Connected := true;
ConnOK:=true;
except
ConnOK:=false;
end;
end;
function OpenSQL(s: string;query:TADODataSet):integer; //查询SQL
var old_Cursor:TCursor;
begin
old_Cursor:=screen.cursor;
screen.cursor:=crSQLWait;
try
try
with query do
begin
close; commandtext:=s; open;
result:=query.recordcount; //返回结果集记录数 end;
except
result:=0;
end;
finally
screen.cursor:=old_Cursor;
end;
end;
function DoSQL(s: string;query:TADOQuery):boolean; //运行 SQL var old_Cursor:TCursor;
begin
result:=true;
old_Cursor:=screen.cursor;
screen.cursor:=crSQLWait;
try
try
with query do
begin
close; SQL.Clear; SQL.Add(s); ExecSQL;
end;
except
result:=false;
end;
finally
screen.cursor:=old_Cursor;
end;
end;。

相关文档
最新文档