Delphi 编写漂亮的登录窗口 (支持无边框窗口的拖动)

1. 利用Rectangle 定制漂亮的登录窗口

Delphi 编写漂亮的登录窗口 (支持无边框窗口的拖动)_第1张图片

2.  代码

unit Unit2;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Effects,
  FMX.Objects, System.Beacon, System.Bluetooth, System.Beacon.Components,
  FMX.Controls.Presentation, FMX.Edit, FMX.StdCtrls;

type
  TForm2 = class(TForm)
    Rectangle1: TRectangle;
    ShadowEffect1: TShadowEffect;
    Rectangle2: TRectangle;
    Rectangle3: TRectangle;
    ShadowEffect2: TShadowEffect;
    Label1: TLabel;
    Label2: TLabel;
    Rectangle4: TRectangle;
    Rectangle6: TRectangle;
    Rectangle5: TRectangle;
    Rectangle7: TRectangle;
    Edit1: TEdit;
    Rectangle8: TRectangle;
    Rectangle9: TRectangle;
    Rectangle10: TRectangle;
    Rectangle11: TRectangle;
    Edit2: TEdit;
    记住密码: TCheckBox;
    Rectangle13: TRectangle;
    ShadowEffect4: TShadowEffect;
    SpeedButton2: TSpeedButton;
    Rectangle12: TRectangle;
    ShadowEffect3: TShadowEffect;
    SpeedButton1: TSpeedButton;
    procedure FormShow(Sender: TObject);
    procedure Rectangle1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
    procedure Rectangle1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Single);
    procedure Rectangle1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Single);
    procedure SpeedButton2Click(Sender: TObject);
  private
    var IsDrag: Boolean;
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.fmx}

procedure TForm2.FormShow(Sender: TObject);
begin
     Self.BorderStyle := TFmxFormBorderStyle.None;
end;

procedure TForm2.Rectangle1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
     if ssLeft in Shift then
  begin
   IsDrag := True;
  end;
end;

procedure TForm2.Rectangle1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Single);
begin
    if IsDrag = True then
    Self.StartWindowDrag
 else
  begin
    //
  end;
end;

procedure TForm2.Rectangle1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
     IsDrag := False;
end;

procedure TForm2.SpeedButton2Click(Sender: TObject);
begin
     close;
end;

end.

你可能感兴趣的:(c#,开发语言)