Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 有没有一种方法可以绕过Delphi VCL表单而不丢失本机windows边框_User Interface_Delphi_User Experience_Vcl - Fatal编程技术网

User interface 有没有一种方法可以绕过Delphi VCL表单而不丢失本机windows边框

User interface 有没有一种方法可以绕过Delphi VCL表单而不丢失本机windows边框,user-interface,delphi,user-experience,vcl,User Interface,Delphi,User Experience,Vcl,我这里有回购协议 这是一个非常好的库,它允许bsSisezable表单看起来像,吸引我注意的是,当我调整此表单的大小时,它仍然调整为bsresizeable表单,而不是bsNone表单 我需要确切知道的是: 有没有一种方法可以在不丢失本机windows边框的情况下创建一个平滑的圆角Delphi VCL表单?我有一个解决方法,但我不知道它是否适合您的需要。解决方法包括定义一个圆角矩形区域来剪裁窗口以删除标题栏和边框。这样,窗口就是一个圆角矩形 然后,要返回标题栏和边框,您必须(例如)检测鼠标是否靠

我这里有回购协议

这是一个非常好的库,它允许
bsSisezable
表单看起来像,吸引我注意的是,当我调整此表单的大小时,它仍然调整为
bsresizeable
表单,而不是
bsNone
表单

我需要确切知道的是:
有没有一种方法可以在不丢失本机windows边框的情况下创建一个平滑的圆角Delphi VCL表单?

我有一个解决方法,但我不知道它是否适合您的需要。解决方法包括定义一个圆角矩形区域来剪裁窗口以删除标题栏和边框。这样,窗口就是一个圆角矩形

然后,要返回标题栏和边框,您必须(例如)检测鼠标是否靠近其中一条边,如果靠近,则删除该区域,以便标题栏和边框再次可见并可以使用

所有这些都涉及到处理一些消息

代码如下:

unit RegionDemoMain;

interface

uses
    Winapi.Windows, Winapi.Messages,
    System.SysUtils, System.Variants, System.Classes,
    Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
    TRoundedForm = class(TForm)
        CloseButton: TButton;
        HelpLabel: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure CloseButtonClick(Sender: TObject);
        procedure WMMouseMove(var Msg : TWMMouseMove); message WM_MOUSEMOVE;
        procedure WMNCMouseLeave(var Msg : TMessage); message WM_NCMOUSELEAVE;
        procedure WMNCButtonDown(var Msg : TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
        procedure WMNCButtonUp(var Msg : TWMNCLButtonUp); message WM_NCLBUTTONUP;
        procedure WMSYSCommand(var Msg : TWMSysCommand); message WM_SYSCOMMAND;
    private
        FRgnHandle       : HRGN;
        FRgnTop          : Integer;
        FRgnBottom       : Integer;
        FRgnRight        : Integer;
        FRgnLeft         : Integer;
        FRgnCorner       : Integer;
        FMouseLeaveCount : Integer;
        FNCLButtonDown   : Boolean;
        procedure DeleteRegion;
        procedure CreateRegion;
    end;

var
  RoundedForm: TRoundedForm;

implementation

{$R *.dfm}

procedure TRoundedForm.FormCreate(Sender: TObject);
begin
    FRgnTop    := GetSystemMetrics(SM_CYCAPTION) +
                  GetSystemMetrics(SM_CYFRAME) +
                  GetSystemMetrics(SM_CYFRAME); 
    FRgnBottom := GetSystemMetrics(SM_CYFRAME) +
                  GetSystemMetrics(SM_CYFRAME);
    FRgnRight  := GetSystemMetrics(SM_CXFRAME) +
                  GetSystemMetrics(SM_CXFRAME);
    FRgnLeft   := GetSystemMetrics(SM_CXFRAME) +
                  GetSystemMetrics(SM_CXFRAME);
    FRgnCorner := 15;
    CreateRegion;
end;

procedure TRoundedForm.CreateRegion;
begin
    if FRgnHandle <> 0 then
        DeleteObject(FRgnHandle);
    FRgnHandle := CreateRoundRectRgn(FRgnLeft,
                                     FRgnTop,
                                     Width  - FRgnRight,
                                     Height - FRgnBottom,
                                     FRgnCorner,
                                     FRgnCorner);
    SetWindowRGN(Handle, FRgnHandle, True);
end;

procedure TRoundedForm.CloseButtonClick(Sender: TObject);
begin
    Close;
end;

procedure TRoundedForm.DeleteRegion;
begin
    if FRgnHandle <> 0 then begin
        SetWindowRGN(Handle, 0, True);
        DeleteObject(FRgnHandle);
        FRgnHandle := 0;
    end;
end;

procedure TRoundedForm.WMMouseMove(var Msg: TWMMouseMove);
begin
    if (Msg.YPos < GetSystemMetrics(SM_CYSIZEFRAME)) or
       (Msg.YPos > (Height - 55)) or
       (Msg.XPos < 10) or
       (Msg.XPos > (Width - 25)) then
        DeleteRegion
    else if (FRgnHandle = 0) and (Msg.YPos > 10) then
        CreateRegion;
    inherited;
end;

procedure TRoundedForm.WMNCButtonDown(var Msg: TWMNCLButtonDown);
begin
    FNCLButtonDown := TRUE;
    inherited;
end;

procedure TRoundedForm.WMNCButtonUp(var Msg: TWMNCLButtonUp);
begin
    FNCLButtonDown := FALSE;
    inherited;
end;

procedure TRoundedForm.WMNCMouseLeave(var Msg : TMessage);
begin
    Inc(FMouseLeaveCount);
    if (FRgnHandle = 0) and (not FNCLButtonDown) then
        CreateRegion;
    inherited;
end;

procedure TRoundedForm.WMSYSCommand(var Msg: TWMSysCommand);
begin
    if Msg.CmdType = SC_RESTORE then
        CreateRegion;
    inherited;
end;

end.

VCL样式是在DelphiXE3中引入的(如果内存可用)。有些样式的上角是圆角的,有些样式的所有角都是圆角的。甚至在Windows10上。但目前还不清楚您使用的是什么Delphi版本,以及您的目标Windows版本(如果不是Windows 10)。请澄清。你不能在这里要求图书馆推荐书,指南明确规定了这一点。我已经从你的问题中删去了。我认为具体问题的答案是否定的。你要求同时有两个相互冲突的要求。本机窗口边框不是圆形的。因此答案是否定的。@DavidHeffernan |很抱歉。。我只是在想,也许delphi vcl表单可以通过一些Trik或变通API来实现(非常尊重和感谢)|这正是我搜索的内容,我认为这对解决我上面的请求非常有用(非常感谢)@Roberto很高兴能帮助你。请使用我答案左侧的勾号将我的答案标记为“已接受”。|不,仍然不完整。。。我仍然需要找到一个解决方案,在本地窗口边框出现时隐藏它们。。。。我必须找到一个技巧,使本机边界看起来像隐藏的,但它们不是…我确实用TUForm(TRoundedForm=class(TUForm))替换了代码中的类TForm并且工作正常,但仍然缺少代码或技巧,本地窗口边框可以隐藏,而不会丢失任何TForm选项,如本地阴影等…@Roberto你说“这正是我要搜索的”,现在你想要更多。。。我建议你接受我的回答,提出一个新问题,并正确解释新要求。使用Paint,创建一个图像,并根据需要对其进行注释。
object RoundedForm: TRoundedForm
  Left = 0
  Top = 0
  Caption = 'RoundedForm'
  ClientHeight = 299
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object HelpLabel: TLabel
    Left = 200
    Top = 96
    Width = 222
    Height = 13
    Caption = 'Move the cursor near one edge of the window'
  end
  object CloseButton: TButton
    Left = 268
    Top = 132
    Width = 75
    Height = 25
    Caption = 'CloseButton'
    TabOrder = 0
    OnClick = CloseButtonClick
  end
end