有没有办法绕过Delphi VCL表单边界?
我希望VCL表格具有下图所示的圆角: (现在不需要阴影,只需要圆角) 我已经尝试了一些代码,但似乎没有任何更改有没有办法绕过Delphi VCL表单边界?,delphi,border,frame,Delphi,Border,Frame,我希望VCL表格具有下图所示的圆角: (现在不需要阴影,只需要圆角) 我已经尝试了一些代码,但似乎没有任何更改 unit UMainWindow; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs; type TFMainWi
unit UMainWindow;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
type
TFMainWindow = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
FMainWindow: TFMainWindow;
implementation
procedure TFMainWindow.FormCreate(Sender: TObject);
var
rgn: HRGN;
begin
rgn := CreateRoundRectRgn(0, 0,ClientWidth,ClientHeight,40,40);
SetWindowRgn(Handle, rgn, True);
end;
end.
这是我的结果:
我不知道您的设置窗口RGN为什么不工作。它是否返回0?OI中的任何非默认属性?
OnCreate
事件不是创建HRGN
的最佳位置。替代虚拟CreateWnd()
或CreateWindowHandle()
方法。表单的HWND
可以在OnCreate
事件之后重新创建。此外,如果表单可调整大小,请使用OnResize
事件为新维度重新创建HRGN
。检查api调用是否存在错误非常重要。文档解释了它们是如何表示成功和失败的。@Matthias,我试过按原样在10.2 VCL上编写代码,它工作得很好。然而,在以前的版本中,我曾经遇到过一些问题,这些问题通过禁用StyleElemens的一些优先级(可能是seClient)来解决,但我不记得了。