我想在program 模块里把创建的窗体统一改成一个模式的(比如:禁止最大化),如何实现?(100分)

  • 主题发起人 SevenOrient
  • 开始时间
S

SevenOrient

Unregistered / Unconfirmed
GUEST, unregistred user!
program Test;
uses
Forms,
Dialogs,
Classes,
TypInfo,
Windows,
Messages,
Unit1 in 'Unit1.pas' {frmFace},
Unit2 in 'Unit2.pas' {frmSubmain};
{$R *.res}
var
vi_Counter1:integer;
begin
Application.Initialize;
with TfrmFace.Create(Application) do
begin
ShowModal;
end;
Application.CreateForm(TfrmSubmain, frmSubmain);
with Application do begin
//我想在这里实现。
for vi_Counter1 := 0 to ComponentCount-1 do
begin
//Find all the Auto-create forms
if Components[vi_Counter1]is TForm then
with (Components[vi_Counter1]as TForm)do
begin
//我想在这里调用函数实现,但是函数怎么写?
//我已经写了一个,但是不行,在最底下。
end;
end;
end;
Application.Run;

end.
//禁止窗体大小改变:
procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo;Sender:TObject); //enable change form size
begin
inherited; //这行出错!
with Msg.MinMaxInfo^ do begin
ptMinTrackSize.x:= TForm(Sender).width;
ptMaxTrackSize.x:= TForm(Sender).width;
ptMinTrackSize.y:= TForm(Sender).height;
ptMaxTrackSize.y:= TForm(Sender).height;
end;
 
是报什么错误?
 
不用那么麻烦
(Components[vi_Counter1]as TForm).WindowState :=wsMaximized
 
提示错误好像是必须继承来一个窗体。
(Components[vi_Counter1]as TForm).WindowState :=wsMaximized ?
我不想最大化每一个窗体;另外:
(Components[vi_Counter1]as TForm).BorderIcons := BorderIcons - [biMaximize];
也不行:
提示:[Error] Undeclared identifier: 'BorderIcons'!晕……,
我已经Uses Forms了!

 
if Components[vi_Counter1]is TForm then
with (Components[vi_Counter1]as TForm)do
begin
bordericons:=[biSystemMenu,biMinimize];
//我想在这里调用函数实现,但是函数怎么写?
//我已经写了一个,但是不行,在最底下。
end;
 
是在你不让它改变大小的窗体里这样写:
TForm1=Class(TForm)
private
procedure WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo); message WM_GetMinMaxInfo;
end;

procedure TForm1.WMGetMinMaxInfo(var Msg: TWMGetMinMaxInfo);
begin
inherited;
with Msg.MinMaxInfo^ do begin
ptMinTrackSize.x:= width;
ptMaxTrackSize.x:= width;
ptMinTrackSize.y:= height;
ptMaxTrackSize.y:= height;
end;
end;
 
多人接受答案了。
 
顶部