其他分享
首页 > 其他分享> > 禁止用鼠标拖动窗口的大小 - 回复 "合肥的石头" 的问题

禁止用鼠标拖动窗口的大小 - 回复 "合肥的石头" 的问题

作者:互联网

禁止用鼠标拖动窗口的大小 - 回复 "合肥的石头" 的问题

问题来源: http://www.cnblogs.com/del/archive/2009/05/15/1458017.html#1534170

//方法一, 同 BorderStyle := bsSingle;
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style xor WS_THICKFRAME;
end;

end.

//方法二, 笨办法:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var w,h: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  w := ClientWidth;
  h := ClientHeight;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  ClientWidth := w;
  ClientHeight := h;
end;

end.

//方法三: 使用 OnCanResize 事件
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer;
      var Resize: Boolean);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
begin
  Resize := False;
end;

end.
posted on 2009-05-21 15:50  万一  阅读(2726)  评论(9)  编辑  收藏

标签:end,鼠标,拖动,TForm1,TObject,var,Sender,procedure,合肥
来源: https://blog.51cto.com/u_14617575/2748117