📄 ualigndialog.pas
字号:
unit uAlignDialog;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
THorizAlign = (hatNo, hatLeft,hatCenter,hatRight,hatEqually,hatWindow);
TVertAlign = (vatNo, vatTop,vatCenter,vatBottom,vatEqually,vatWindow);
TAlignDialog = class(TForm)
GroupBox1: TGroupBox;
hNoChange: TRadioButton;
hLeftSides: TRadioButton;
hCenters: TRadioButton;
hRightSides: TRadioButton;
hSpaceEqual: TRadioButton;
hCenterInWindow: TRadioButton;
GroupBox2: TGroupBox;
vNoChange: TRadioButton;
vTops: TRadioButton;
vCenters: TRadioButton;
vBottoms: TRadioButton;
vSpaceEqual: TRadioButton;
vCenterInWindow: TRadioButton;
OKButton: TButton;
CancelButton: TButton;
HelpButton: TButton;
procedure OKButtonClick(Sender: TObject);
procedure HelpButtonClick(Sender: TObject);
private
{ Private declarations }
procedure HorizAlignControl(Align:THorizAlign);
procedure VertAlignControl(Align:TVertAlign);
public
{ Public declarations }
end;
var
AlignDialog: TAlignDialog;
implementation
uses Proxy, utype, Uconst, utils;
{$R *.DFM}
procedure TAlignDialog.HorizAlignControl(Align:THorizAlign);
var
I,Left,Width,Width1,Center,Left1,Dif,TotalDif:Integer;
begin
case Align of
hatLeft:
begin
Left:= TControl(ProxyDesigner.SelectList[0]).Left;
for I:=1 to ProxyDesigner.SelectList.Count - 1 do
TControl(ProxyDesigner.SelectList[I]).Left:= Left;
end;
hatCenter:
begin
Left:= TControl(ProxyDesigner.SelectList[0]).Left;
Width:= TControl(ProxyDesigner.SelectList[0]).Width;
Center:= Left + (Width div 2);
for I:=1 to ProxyDesigner.SelectList.Count - 1 do begin
Width1:= TControl(ProxyDesigner.SelectList[I]).Width;
TControl(ProxyDesigner.SelectList[I]).Left:=
Left + ((Width - Width1) div 2);
end;
end;
hatRight:
begin
Left:= TControl(ProxyDesigner.SelectList[0]).Left;
Width:= TControl(ProxyDesigner.SelectList[0]).Width;
for I:=1 to ProxyDesigner.SelectList.Count - 1 do begin
Width1:= TControl(ProxyDesigner.SelectList[I]).Width;
TControl(ProxyDesigner.SelectList[I]).Left:=
Left + ((Width - Width1) );
end;
end;
hatEqually:
begin
TotalDif:=0;
Left:= TControl(ProxyDesigner.SelectList[0]).Left;
Width:= TControl(ProxyDesigner.SelectList[0]).Width;
for I:=1 to ProxyDesigner.SelectList.Count - 1 do begin
Left1:= TControl(ProxyDesigner.SelectList[I]).Left;
Dif:= Abs(Left - Left1);
TotalDif:= TotalDif + Dif;
Left:= TControl(ProxyDesigner.SelectList[I]).Left;
Width:= TControl(ProxyDesigner.SelectList[I]).Width;
end;
end;
end;
ProxyDesigner.UpdateGrabHandle;
end;
procedure TAlignDialog.VertAlignControl(Align:TVertAlign);
var
I,Top,Height,Height1,Center,Left1,Dif,TotalDif:Integer;
begin
case Align of
vatTop:
begin
Top:= TControl(ProxyDesigner.SelectList[0]).Top;
for I:=1 to ProxyDesigner.SelectList.Count - 1 do
TControl(ProxyDesigner.SelectList[I]).Top:= Top;
end;
vatCenter:
begin
Top:= TControl(ProxyDesigner.SelectList[0]).Top;
Height:= TControl(ProxyDesigner.SelectList[0]).Height;
for I:=1 to ProxyDesigner.SelectList.Count - 1 do begin
Height1:= TControl(ProxyDesigner.SelectList[I]).Height;
TControl(ProxyDesigner.SelectList[I]).Top:=
Top + ((Height - Height1) div 2);
end;
end;
vatBottom:
begin
Top:= TControl(ProxyDesigner.SelectList[0]).Top;
Height:= TControl(ProxyDesigner.SelectList[0]).Height;
for I:=1 to ProxyDesigner.SelectList.Count - 1 do begin
Height1:= TControl(ProxyDesigner.SelectList[I]).Height;
TControl(ProxyDesigner.SelectList[I]).Top:=
Top + ((Height - Height1) );
end;
end;
end;
ProxyDesigner.UpdateGrabHandle;
end;
procedure TAlignDialog.OKButtonClick(Sender: TObject);
begin
if hLeftSides.Checked then HorizAlignControl(hatLeft)
else if hCenters.Checked then HorizAlignControl(hatCenter)
else if hRightSides.Checked then HorizAlignControl(hatRight)
else if hSpaceEqual.Checked then HorizAlignControl(hatEqually);
if vTops.Checked then VertAlignControl(vatTop)
else if vCenters.Checked then VertAlignControl(vatCenter)
else if vBottoms.Checked then VertAlignControl(vatBottom)
else if vSpaceEqual.Checked then VertAlignControl(vatEqually);
end;
procedure TAlignDialog.HelpButtonClick(Sender: TObject);
begin
ShowKeywordHelp('Align command');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -