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

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

问题来源: 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)  编辑  收藏
上一篇:如何把窗体关闭到系统托盘 - 回复 "三足乌" 的问题


下一篇:SendTextMessage 等方便的消息发送函数