📄 long.pas
字号:
unit long;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Menus, ComCtrls, ToolWin, Buttons, StdCtrls, AppEvnts,
LabelButton, TradeImage, MaskImageButton, MoveImageButton, TrayBarIcon;
type
Tfrm_long = class(TForm)
palUp: TPanel;
palLeftUp: TPanel;
imgLeftUp: TImage;
palRightUp: TPanel;
imgRightUp: TImage;
palUpMid: TPanel;
imgCaption: TImage;
palDown: TPanel;
imgLeftDown: TImage;
imgRightDown: TImage;
imgDownMin: TImage;
palLeft: TPanel;
palRight: TPanel;
imgRight: TImage;
imgCloseButton: TImage;
imgMinButton: TImage;
imgSizeButton: TImage;
imgMaxButton: TImage;
imgRestoreButton: TImage;
imgSysIcon: TImage;
popSystemMenu: TPopupMenu;
N_Restore: TMenuItem;
N_Max: TMenuItem;
N_Min: TMenuItem;
N_Move: TMenuItem;
N_Size: TMenuItem;
N_Speater: TMenuItem;
N_Close: TMenuItem;
palClient: TPanel;
lbCaption: TLabel;
CoolBarMenu: TCoolBar;
ToolBarMenu: TToolBar;
imgLeft: TImage;
imgColorLeftUp: TImage;
imgGrayCaption: TImage;
imgGrayMenuBar: TImage;
imgGrayRightUp: TImage;
imgColorCaption: TImage;
imgGrayLeftUp: TImage;
imgColorRightUp: TImage;
imgRightUp1: TImage;
imgLeftUp1: TImage;
imgColorMenubar: TImage;
Label1: TLabel;
Label2: TLabel;
e_pass: TEdit;
e_zzy: TComboBox;
b_ok: TMoveImgBtn;
blabel_ok: TLabelBtn;
blabel_exit: TLabelBtn;
b_exit: TMoveImgBtn;
b_edit: TMoveImgBtn;
LabelBtn1: TLabelBtn;
procedure imgMinButtonClick(Sender: TObject);
procedure imgSizeButtonClick(Sender: TObject);
procedure imgCloseButtonClick(Sender: TObject);
procedure imgCaptionMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure imgCaptionMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure imgCaptionMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
procedure imgSysIconMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure popSystemMenuPopup(Sender: TObject);
procedure N_SizeClick(Sender: TObject);
procedure N_MoveClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure e_zzyChange(Sender: TObject);
procedure b_okClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure b_exitClick(Sender: TObject);
procedure b_editClick(Sender: TObject);
procedure e_passKeyPress(Sender: TObject; var Key: Char);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
canmove:boolean;
curPoint:TPoint;
oldPoint:TPoint;
Canvas:TCanvas;
i:integer;//密码循环三次
protected
procedure CreateParams(var Params:TCreateParams);override;
procedure WMActivate(var Msg:TWMACTIVATE); message WM_ACTIVATE;
public
{ Public declarations }
end;
var
frm_long: Tfrm_long;
implementation
uses publicvar, passedit, datam, main;
{$R *.dfm}
procedure Tfrm_long.CreateParams(var Params:TCreateParams);
begin
inherited CreateParams(Params);
if BorderStyle<>bsNone then
Params.Style :=WS_THICKFRAME or WS_POPUP or WS_BORDER;
end;
procedure Tfrm_long.imgMinButtonClick(Sender: TObject);
begin
if Application.MainForm =self then
Application.Minimize
else
DefWindowProc(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
procedure Tfrm_long.imgSizeButtonClick(Sender: TObject);
begin
if self.WindowState = wsNormal then
begin
DefWindowProc(Handle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
imgSizeButton.Picture :=imgRestoreButton.Picture;
end
else
begin
DefWindowProc(Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
imgSizeButton.Picture :=imgMaxButton.Picture;
end;
end;
procedure Tfrm_long.imgCloseButtonClick(Sender: TObject);
begin
DefWindowProc(Handle, WM_SYSCOMMAND, SC_CLOSE, 0);
end;
procedure Tfrm_long.imgCaptionMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Button=mbLeft)and(ssLeft in Shift)then
begin
canmove:=true;
Canvas:=TCanvas.Create;
with Canvas do
begin
pen.Style :=psdot;
brush.Style :=bsClear;
pen.Width :=2;
Pen.Mode :=pmNotXor;
Handle :=GetDC(0);
Rectangle(left,top,Left+width,top+height);
curPoint.X :=X;
curPoint.Y :=Y;
oldPoint.X :=Left;
oldPoint.Y :=Top;
end; //end with
end; //end if
end;
procedure Tfrm_long.imgCaptionMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if not canmove then exit;
with Canvas do
begin
Rectangle(oldPoint.x,oldPoint.y,oldPoint.x+Width,oldPoint.y+Height);
oldPoint.x :=Left +X-curPoint.x;
oldPoint.y :=Top +Y-curPoint.y;
Rectangle(oldPoint.x,oldPoint.y,oldPoint.x+Width,oldPoint.y+Height);
end;
end;
procedure Tfrm_long.imgCaptionMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if not canmove then exit;
with Canvas do
begin
Rectangle(oldPoint.x,oldPoint.y,oldPoint.x+Width,oldPoint.y+Height);
Left :=oldPoint.x;
Top :=oldPoint.y;
Free;
end;
canmove:=not canmove;
end;
procedure Tfrm_long.FormCreate(Sender: TObject);
begin
lbCaption.Caption :=Caption;
dm.ado_user.open;
dm.ADO_user.Sort:='编号';
while not dm.ado_user.Eof do
begin
e_zzy.items.add(dm.ADO_user.fieldbyname('操作员').AsString);
dm.ADO_user.Next;
end;
e_zzy.ItemIndex:=0
end;
procedure Tfrm_long.imgSysIconMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
PopSystemMenu.Popup(Left+ImgSysIcon.Left,Top+ImgSysIcon.Top+ImgSysIcon.Height);
end;
procedure Tfrm_long.popSystemMenuPopup(Sender: TObject);
begin
N_Restore.Enabled :=imgSizeButton.Visible and (WindowState =wsMaximized);
N_Max.Enabled :=imgSizeButton.Visible and (WindowState =wsNormal);
n_min.Enabled:=imgMinButton.Visible;
N_Size.Enabled :=imgSizeButton.Visible ;
end;
procedure Tfrm_long.N_SizeClick(Sender: TObject);
begin
DefWindowProc(Handle, WM_SYSCOMMAND, SC_SIZE, 0);
end;
procedure Tfrm_long.N_MoveClick(Sender: TObject);
begin
DefWindowProc(Handle, WM_SYSCOMMAND, SC_MOVE, 0);
end;
procedure Tfrm_long.FormShow(Sender: TObject);
begin
if WindowState=wsNormal then
imgSizeButton.Picture.Bitmap :=imgMaxButton.Picture.Bitmap
else if WindowState=wsMaximized then
imgSizeButton.Picture.Bitmap :=imgRestoreButton.Picture.Bitmap
end;
procedure Tfrm_long.WMActivate(var Msg: TWMACTIVATE);
begin
if (Msg.Active =WA_ACTIVE) or (Msg.Active =WA_CLICKACTIVE) then
begin
imgCaption.Picture.Bitmap :=imgColorCaption.Picture.Bitmap;
imgLeftUp1.Picture.Bitmap :=imgColorLeftUp.Picture.Bitmap;
imgRightUp1.Picture.Bitmap :=imgColorRightUp.Picture.Bitmap;
coolBarMenu.Bitmap :=imgColorMenubar.Picture.Bitmap;
end
else begin
imgCaption.Picture.Bitmap :=imgGrayCaption.Picture.Bitmap;
imgLeftUp1.Picture.Bitmap :=imgGrayLeftUp.Picture.Bitmap;
imgRightUp1.Picture.Bitmap :=imgGrayRightUp.Picture.Bitmap;
coolBarMenu.Bitmap :=imgGrayMenubar.Picture.Bitmap;
end;
end;
procedure Tfrm_long.e_zzyChange(Sender: TObject);
begin
e_pass.Text:='';
e_pass.SetFocus;
end;
procedure Tfrm_long.b_okClick(Sender: TObject);
var
kl:variant;
pass:string;
begin
zzyname:=e_zzy.text;
kl:=dm.ado_user.lookup('操作员',zzyname,'口令');
if varisnull(kl) then pass:='' else pass:=kl;
if e_pass.text<>pass then
begin
i:=i+1;
if i>=3 then
begin
Application.MessageBox(PChar('密码验证错误,拒绝访问!'), PChar('提示'),
MB_ICONEXCLAMATION);
Application.Terminate;
close;
end;
application.messagebox(pchar('密码验证错误,重新录入!'),pchar('提示'),
MB_ICONQUESTION);
e_pass.text:='';
e_pass.SetFocus();
exit;
end;
dm.ADO_user.Close;
frm_long.hide;
frm_main:=tfrm_main.create(application);
frm_main.showmodal;
end;
procedure Tfrm_long.FormActivate(Sender: TObject);
begin
e_pass.SetFocus;
end;
procedure Tfrm_long.b_exitClick(Sender: TObject);
begin
close;
end;
procedure Tfrm_long.b_editClick(Sender: TObject);
begin
zzyname:=e_zzy.text;
frm_passedit:=tfrm_passedit.create(application);
frm_passedit.showmodal;
end;
procedure Tfrm_long.e_passKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
b_ok.OnClick(b_ok);
end;
end;
procedure Tfrm_long.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dm.ado_user.Close;
Application.Terminate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -