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

📄 unit1.pas

📁 delphi实现窗体停靠,希望大家相互学习.
💻 PAS
字号:
{
    TMagnetic VCL DEMO write by ZHONG WAN at 2001.3
    it can worked at D5 excellence,
    if it can not work, it must not write by me :)

      -'`"_         -'`" \
     /     \       /      "
    /     /\\__   /  ___   \       西安科技学院143信箱 710054
   |      | \  -"`.-(   \   |
   |      |  |     | \"  |  |                万  重
   |     /  /  "-"  \  \    |
    \___/  /  (o o)  \  (__/       电邮(email):
         __| _     _ |__           mantousoft@sina.com
        (      ( )      )
         \_\.-.___.-./_/           网址(homepage):
           __  | |  __             http://mantousoft.51.net
          |  \.| |./  |
          | '#.   .#' |            OICQ: 6036742
          |__/ '"" \__|
        -/             \-          2001.3.1

   this demo demonstrate all most TMagnetic property but
   Magnetic1.MagOption.MagTray,cau's it all ueseful for form;
   set it to change whether magnetic with traybar;

   this is shareware, u can used it in ur applicaiton,
   if u want used it in business, u must get my permition;
   u can email me or to my homepage to guest me;

   thanks for use this VCL ,joying it!
}

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Magnetic, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    UpDown1: TUpDown;
    Edit1: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Magnetic1: TMagnetic;
    Button4: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button2Click(Sender: TObject);
begin
  { whether uses it to work }
  { 是否激活控件 }
  Magnetic1.Active:=not Magnetic1.Active;
  if Magnetic1.Active then
    Button2.Caption:='DisActive'
  else
    Button2.Caption:='Active';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  { whether can resize without caption }
  { 是否允许在没有标题栏的时候改变大小 }
  Magnetic1.CanResize:=not Magnetic1.CanResize;
  if Magnetic1.CanResize then
    Button1.Caption:='DisSizeable'
  else
    Button1.Caption:='Sizeable';
end;

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

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
const
  WinampClassName='Winamp v1.x';
begin
  { find winamp hanle }
  { 查找 winamp 的句柄 }
  Magnetic1.CustomMagWnd:=FindWindow(WinampClassName,nil);
  { enable magnetic custom hanlde just winamp here }
  { 允许磁性自定义的窗口,就是上面指定的 winamp }
  Magnetic1.MagOption.MagCustom:=True;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  { draw a egle for this form }
  { 为窗体画边框 }
  Canvas.Pen.Color:=$00555E66;
  Canvas.Pen.Width:=10;
  Canvas.RoundRect(0,0,Width,Height,5,5);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  { repaint form }
  { 重画窗体 }
  RePaint;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  { get magnetic default effect }
  { 得到初始磁力效果大小 }
  UpDown1.Position:=Magnetic1.MagEffect;
  { initialize form minsize }
  { 初始化窗体最小大小 }
  Constraints.MinHeight:=Height;
  Constraints.MinWidth:=Width;
end;

procedure TForm1.Edit1Change(Sender: TObject);
begin
  { set magnetic effect by pix }
  { 设置磁力效果大小 单位为像素 }
  Magnetic1.MagEffect:=UpDown1.Position;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  { whether can magnetic with explorer }
  { 是否允许磁性资源管理器 }
  Magnetic1.MagOption.MagExplorer:=not Magnetic1.MagOption.MagExplorer;
  if Magnetic1.MagOption.MagExplorer then
    Button4.Caption:='Disable Magnetic Explorer'
  else
    Button4.Caption:='Enable Magnetic Explorer'
end;

end.

⌨️ 快捷键说明

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