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

📄 unit1.pas

📁 配件仓库管理系统 DELPHI6开发
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, MyxEdit, Buttons;

type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    Label1: TLabel;
    Label2: TLabel;
    procedure CheckBox1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    move:Boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.CheckBox1Click(Sender: TObject);
var
   WindowStyle: Longint;   // holds the window style
begin
   {get the current styles used by this window}
   WindowStyle:=GetWindowLong(Form1.Handle, GWL_STYLE);

   {toggle the WS_CAPTION style}
   if (CheckBox1.Checked) then
      WindowStyle:=WindowStyle OR WS_CAPTION
   else
      WindowStyle:=WindowStyle AND NOT WS_CAPTION;

   {toggle the WS_BORDER style}
   if (CheckBox2.Checked) then
      WindowStyle:=WindowStyle OR WS_BORDER
   else
      WindowStyle:=WindowStyle AND NOT WS_BORDER;

   {toggle the WS_SYSMENU style}
   if (CheckBox3.Checked) then
      WindowStyle:=WindowStyle OR WS_SYSMENU
   else
      WindowStyle:=WindowStyle AND NOT WS_SYSMENU;

   {toggle the WS_MAXIMIZEBOX style}

   if (CheckBox4.Checked) then
      WindowStyle:=WindowStyle OR WS_MAXIMIZEBOX
   else
      WindowStyle:=WindowStyle AND NOT WS_MAXIMIZEBOX;

   {toggle the WS_MINIMIZEBOX style}
   if (CheckBox5.Checked) then
      WindowStyle:=WindowStyle OR WS_MINIMIZEBOX
   else
      WindowStyle:=WindowStyle AND NOT WS_MINIMIZEBOX;


   {make the window use the new styles}
   SetWindowLong(Form1.Handle, GWL_STYLE, WindowStyle);

   {this little trick forces the entire window to redraw,
    including non-client areas}
   SetWindowPos(Handle, 0, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOACTIVATE or
                SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER);

   {display the current styles used by this window}
   Label1.Caption:='Current Style: '+IntToStr(WindowStyle);
end;



//The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehl

procedure TForm1.FormCreate(Sender: TObject);
var
   WindowStyle: Longint;   // holds the window style information

begin
   {get the current styles used by this window}
   WindowStyle:=GetWindowLong(Form1.Handle, GWL_STYLE);

   {initialize the check boxes according to the styles that are present}
   if (WindowStyle AND WS_CAPTION)>0 then CheckBox1.Checked:=TRUE;
   if (WindowStyle AND WS_BORDER)>0 then CheckBox2.Checked:=TRUE;
   if (WindowStyle AND WS_SYSMENU)>0 then CheckBox3.Checked:=TRUE;
   if (WindowStyle AND WS_MAXIMIZEBOX)>0 then CheckBox4.Checked:=TRUE;

   if (WindowStyle AND WS_MINIMIZEBOX)>0 then CheckBox5.Checked:=TRUE;

   {hook up the OnClick events for the checkboxes. this step is necessary
    because the OnClick event is automatically fired when the Checked
    property is accessed.}
   CheckBox1.OnClick:=CheckBox1Click;
   CheckBox2.OnClick:=CheckBox1Click;
   CheckBox3.OnClick:=CheckBox1Click;
   CheckBox4.OnClick:=CheckBox1Click;
   CheckBox5.OnClick:=CheckBox1Click;
end;

//The Tomes of Delphi 3: Win32 Core API Help File by Larry Diehl

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  move:=true;
  Label2.Caption:='('+IntToStr(X)+','+IntToStr(Y)+')';
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Label2.Caption:='('+IntToStr(X)+','+IntToStr(Y)+')';
  if Move=true then
  begin
    top:=top+Y;
    left:=left+X;
  end;  
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Label2.Caption:='('+IntToStr(X)+','+IntToStr(Y)+')';
  move:=false;
end;

end.

⌨️ 快捷键说明

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