重载 CreateParams 方法[1]: 从一个例子开始(取消窗口最大化、最小化按钮的三种方法)
作者:互联网
重载 CreateParams 方法[1]: 从一个例子开始(取消窗口最大化、最小化按钮的三种方法)
方法1: 使用 TForm 的 BorderIcons 属性
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin BorderIcons := BorderIcons - [biMinimize, biMaximize]; end; end.
方法2: 使用 SetWindowLong 函数
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var ws: Integer; begin ws := GetWindowLong(Handle, GWL_STYLE); ws := ws xor WS_MINIMIZEBOX xor WS_MAXIMIZEBOX; SetWindowLong(Handle, GWL_STYLE, ws); end; end.
方法3: 重载 CreateParams 方法
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure CreateParams(var Params: TCreateParams); override; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.CreateParams(var Params: TCreateParams); begin inherited; //inherited CreateParams(Params); Params.Style := Params.Style xor WS_MINIMIZEBOX xor WS_MAXIMIZEBOX; end; end.posted on 2008-09-02 01:56 万一 阅读(4599) 评论(7) 编辑 收藏
标签:end,CreateParams,TForm1,var,重载,Params,最小化,procedure 来源: https://blog.51cto.com/u_14617575/2746666