I've a simple IntraWeb test project, My Unit1 has an IWform with 3 regions: header, body & footer as below:
type
TIWForm1 = class(TIWAppForm)
Body_Region: TIWRegion;
Header_Region: TIWRegion;
Footer_Region: TIWRegion;
public
end;
implementation
{$R *.dfm}
initialization
TIWForm1.SetAsMainForm;
end.
My Unit2 and Unit3 are an IWFrame and they have a button only as below:
type
TIWFrame2 = class(TFrame)
IWFrameRegion: TIWRegion;
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
end.
(unit3 same as unit2)
Now, I can assign a frame to the body region easily at design time by dropping Frames form the tool plate to that region.
The problem is how can I change it at runtime to unit3 Frame?
If I try to add it to type section like this
type
TIWForm1 = class(TIWAppForm)
Body_Region: TIWRegion;
Header_Region: TIWRegion;
Footer_Region: TIWRegion;
MyFram2: TIWFrame2; // added here
procedure IWAppFormShow(Sender: TObject);
public
end;
the system tries to remove it!
if I force to keep it to use it as
Body_Region.Parent := MyFram2;
I got nothing in the body region!
if I add it manually at design time I got the same declaration, I got it working but I cannot change it!
am I missing something here or it is impossible to do so?
btw I'm on Delphi Berlin 10.1 and IW14.1.12.
The "removal" of the declared field is not an IntraWeb thing, but a Delphi "feature". Declare it like this, inside a "private" section otherwise it will be treated as published:
Remove OnShow event and use OnCreate event instead. Create your frame instances inside the OnCreate event, like this:
Then you can make one visible and the other invisible setting Frame.IWFrameRegion visibility as shown above.