作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法暂时暂停表单上所有锚定控件的移动或调整大小?即:
procedure ScaleFormBy(AForm: TForm; n, d: Integer);
begin
AForm.SuspendAnchors();
try
AForm.ScaleBy(n, d);
finally
AForm.ResumeAnchors();
end;
end;
我需要这样做,因为我正在打电话
AForm.ScaleBy(m, d);
它不能正确处理锚定控件。 (它将左+右或上+下锚定控件推离表单边缘。
注意:我想禁用 anchor ,而不是对齐。
最佳答案
SuspendAnchors 听起来像是一个基本方法,但我不认为它是基本 Delphi 语言的一部分:)下面是一些可以实现这一目的的代码:
<小时/>var aAnchorStorage: Array of TAnchors;
procedure AnchorsDisable(AForm: TForm);
var
iCounter: integer;
begin
SetLength(aAnchorStorage, AForm.ControlCount);
for iCounter := 0 to AForm.ControlCount - 1 do begin
aAnchorStorage[iCounter] := AForm.Controls[iCounter].Anchors;
AForm.Controls[iCounter].Anchors := [];
end;
end;
procedure AnchorsEnable(AForm: TForm);
var
iCounter: integer;
begin
SetLength(aAnchorStorage, AForm.ControlCount);
for iCounter := 0 to AForm.ControlCount - 1 do
AForm.Controls[iCounter].Anchors := aAnchorStorage[iCounter];
end;
procedure TForm1.btnAnchorsDisableClick(Sender: TObject);
begin
AnchorsDisable(Self);
end;
procedure TForm1.btnAnchorsEnableClick(Sender: TObject);
begin
AnchorsEnable(Self);
end;
<小时/>
享受
关于德尔福5 : How to suspend anchor layouts?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/587957/
我是一名优秀的程序员,十分优秀!