Hi,

I had the same problem try this
Create a TYourForm class and override DoCreate procedure. Then inherite your
form from it.

interface

type
TChildFormType = (dftUnassigned, dftMdiChild, dftDockableForm, dftModal);


TChildForm = class(TForm)
private
FFormType : TChildFormType;
protected
procedure DoCreate;override;
public
constructor CreateTyped(aOwner: TComponent; aFormType: TChildFormType);
property property p_FormType: TChildFormType read FFormType write FFormType;

end;

implementation

procedure TChildForm.DoCreate;
begin
inherited;

if p_FormType = dftMdiChild then begin
FormStyle := fsMdiChild;
BorderStyle := bsSizeable;
WindowState := wsMaximized;
end;

if p_FormType = dftDockableForm then begin
Visible := false;
FormStyle := fsNormal;
BorderStyle := bsSizeToolWin;
end;
end;


p_FormType is a custom type . I initialize it in a custom construcotor :

constructor TChildForm.CreateTyped(aOwner: TComponent; aFormType:
TChildFormType);
begin
inherited Create(aOwner);
p_FormType := aFormType;
end;

All you have to do is to inherite the new class and to create a form runtime
with CreateTyped constructor:

TForm1 = class( TChildForm )
....
end;

aForm1 := TForm1.CreateTyped(Application, dftDockableForm);
or
aForm1 := TForm1.CreateTyped(Application, dftMdiChild);
etc.

Have in mind that Delphi help says;
"Note: It is not advisable to change FormStyle at runtime."
 :)
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to