⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 建立立体感强的界面源代码
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Buttons;

type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    ShadowWidth:integer;//主要用于确定阴影的宽度或高度,也可以设计成Const类型
    RightShadow:TForm;//主窗口的右边产生一个阴影窗口
    BottomShadow:TForm;//主窗口的下部产生一个阴影窗口
    procedure WMWindowPosChanged(var Msg:TWMWindowPosChanged);message wm_windowposchanged;

    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
const
  //在函数for SetLayeredWindowAttributes中用到的常量
  lwa_Alpha =2;
  //窗口布局的扩展
  ws_ex_layered =$80000;//关键


{$R *.dfm}

{ TForm1 }

procedure TForm1.WMWindowPosChanged(var Msg: TWMWindowPosChanged);
begin
    inherited;
    if Assigned(RightShadow) and RightShadow.Visible then
       FormResize(nil);

end;

procedure TForm1.FormResize(Sender: TObject);
begin
  RightShadow.Height := Height;
  RightShadow.Left :=Left + Width;
  RightShadow.Top :=Top + ShadowWidth;
  BottomShadow.Width :=Width - ShadowWidth;
  BottomShadow.Left :=Left + ShadowWidth;
  BottomShadow.Top :=Top+Height;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShadowWidth:=10;


  RightShadow:=TForm.Create(self);
  with RightShadow do
  begin
    parent :=Application.MainForm;
    BorderStyle :=bsNone;
    Width :=ShadowWidth;
    Color :=clBlack;
    Visible :=true;
  end;
  //
  SetWindowLong(RightShadow.Handle,gwl_exstyle,GetWindowLong(RightShadow.Handle,gwl_exstyle)or ws_ex_layered);  SetLayeredWindowAttributes(RightShadow.Handle,0,150,lwa_Alpha);


  BottomShadow:=TForm.Create (self);  with BottomShadow do
  begin
    parent :=Application.MainForm;
    BorderStyle :=bsNone;
    Height :=ShadowWidth;
    Color :=clBlack;
    Visible :=true;
  end;
  SetWindowLong(BottomShadow.Handle,gwl_exstyle,GetWindowLong(BottomShadow.Handle,gwl_exstyle)or ws_ex_layered);  SetLayeredWindowAttributes(BottomShadow.Handle,0,150,lwa_Alpha);
  //将背景
  FormResize(Sender);

end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -