Delphi限制窗口大小,本例代碼把窗口限制在長度:400、寬度250的范圍內,如果繼續拖放,也不能放大窗口,可應用在一些需要固定窗口大小的地方,代碼如下:
01
unit
dy214;
02
interface
03
uses
04
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
05
Dialogs, StdCtrls, XPMan, Buttons, ExtCtrls;
06
type
07
TForm1 =
class
(TForm)
08
Label1: TLabel;
09
Label3: TLabel;
10
Label2: TLabel;
11
Label4: TLabel;
12
procedure
FormResize(Sender: TObject);
13
procedure
CancelClick(Sender: TObject);
14
procedure
aa(
var
xx: TWMGetMinMaxinfo); message WM_GetMinMaxinfo;
15
private
16
{ Private declarations }
17
public
18
{ Public declarations }
19
end
;
20
var
21
Form1: TForm1;
22
implementation
23
{$R *.dfm}
24
{ TForm1 }
25
procedure
TForm1
.
aa(
var
xx: TWMGetMinMaxinfo);
26
begin
27
with
xx
.
MinMaxInfo^
do
28
begin
29
ptMinTrackSize := point(
170
,
90
);
30
ptMaxTrackSize := point(
400
,
250
);
31
end
;
32
end
;
33
procedure
TForm1
.
FormResize(Sender: TObject);
34
begin
35
label3
.
Caption:=inttostr(Width);
36
Label4
.
Caption:=inttostr(Height);
37
end
;
38
procedure
TForm1
.
CancelClick(Sender: TObject);
39
begin
40
Close;
41
end
;
42
end
.
本例效果截圖如下: