gpt4 book ai didi

delphi - 调整表单大小,即使它是无边框的 - 删除斜角边缘

转载 作者:行者123 更新时间:2023-12-03 15:51:40 27 4
gpt4 key购买 nike

使用以下代码使无边框表单可调整大小非常有效:

type
TForm1 = class(TForm)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
BorderStyle := bsNone;
inherited;
Params.ExStyle := Params.ExStyle or WS_EX_STATICEDGE;
Params.Style := Params.Style or WS_SIZEBOX;
end;

但是,请看图片:

enter image description here为什么顶部边缘有一个斜角?有什么建议可以删除它吗?

最佳答案

这是绝对的答案。也适用于 win 7,8 win10。出现的奇怪的薄顶栏也消失了。
(如果您使用现代主题,请删除表单的样式元素(sefont、seclient、seborder))

是的,如果您有一个面板设置与所有客户端对齐,它就可以工作。只需修改 panel.alignwithmargins:=true;和 panel.margins>1

(注意:不要忘记将 form.borderstyle 设置为 bsNone;)

 protected
procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;

..

procedure Tfmmain.WMNCHitTest(var Message: TWMNCHitTest);
const
EDGEDETECT = 7; // adjust
var
deltaRect: TRect;
begin
inherited;
if BorderStyle = bsNone then
with Message, deltaRect do
begin
Left := XPos - BoundsRect.Left;
Right := BoundsRect.Right - XPos;
Top := YPos - BoundsRect.Top;
Bottom := BoundsRect.Bottom - YPos;
if (Top < EDGEDETECT) and (Left < EDGEDETECT) then
Result := HTTOPLEFT
else if (Top < EDGEDETECT) and (Right < EDGEDETECT) then
Result := HTTOPRIGHT
else if (Bottom < EDGEDETECT) and (Left < EDGEDETECT) then
Result := HTBOTTOMLEFT
else if (Bottom < EDGEDETECT) and (Right < EDGEDETECT) then
Result := HTBOTTOMRIGHT
else if (Top < EDGEDETECT) then
Result := HTTOP
else if (Left < EDGEDETECT) then
Result := HTLEFT
else if (Bottom < EDGEDETECT) then
Result := HTBOTTOM
else if (Right < EDGEDETECT) then
Result := HTRIGHT
end;
end;

关于delphi - 调整表单大小,即使它是无边框的 - 删除斜角边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38023579/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com