Author: Jonas Bilinkevicius
Does anyone know if it is possible to change the Parent of the Mainform's client
window in such a way that MDI forms are correctly displayed within (for instance) a
panel?
Answer:
Here is a class that we use to place forms in panels:
1 unit oSubForm;
2 3 interface4 5 uses6 Forms, Controls;
7 8 type9 TSubForm = class(TForm)
10 public11 procedure CreateParams(var Params: TCreateParams); override;
12 { ... }13 function SetUp: boolean; virtual;
14 function Activate: boolean; virtual;
15 function Deactivate: boolean; virtual;
16 function Validate: boolean; virtual;
17 function AddKnockOnChanged(Sender: TObject): boolean; virtual;
18 { ... }19 procedure SetAllChanged; virtual;
20 end;
21 22 type23 TDfEE_Form = class(TForm)
24 private25 protected26 public27 function PageValidate(nPage: integer): boolean; virtual;
28 published29 end;
30 31 implementation32 33 uses34 WinTypes;
35 36 procedure TSubForm.CreateParams(var Params: TCreateParams);
37 begin38 inherited CreateParams(Params);
39 with Params do40 begin41 WndParent := TWinControl(Owner).Handle;
42 Params.Style := WS_CHILD or WS_CLIPSIBLINGS or WS_CLIPCHILDREN;
43 end;
44 Align := alClient;
45 Parent := TWinControl(Owner);
46 end;
47 48 function TSubForm.SetUp: boolean;
49 begin50 end;
51 52 function TSubForm.Activate: boolean;
53 begin54 end;
55 56 function TSubForm.Deactivate: boolean;
57 begin58 end;
59 60 procedure TSubForm.SetAllChanged;
61 begin62 end;
63 64 function TSubForm.Validate: boolean;
65 begin66 end;
67 68 function TSubForm.AddKnockOnChanged(Sender: TObject): boolean;
69 begin70 end;
71 72 function TDfEE_Form.PageValidate(nPage: integer): boolean;
73 begin74 result := True;
75 end;
76 77 end.