Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Frames question

Hi,

Is it possible to load different frames in a single container, I need to create a wizard, I think using different Forms (frames) will be easier. But When I select the frame container, it asks me what frame to use, and I see no option to load another frame. or unload one.
Or should I create the container at runtime, when needed?? if so how?

Any hints tips or advice, on making wizards is appreciated, Since they will be graphic heavy, I need to keep the memory load low. And I know using panels just eats up memory. because they are all created at runtime. While the forms are not. Is this also the case for Frames?

Thanks
Marc
0
hellfire052497
Asked:
hellfire052497
  • 4
  • 3
  • 2
  • +1
1 Solution
 
EpsylonCommented:
You can dynamically create frames you build in the designer. Below the source of the main unit (unit1). It uses unit2 which has a few components on it.
Button1 creates an instance of the frame (defined in unit2) and shows it on the main form.
Button2 removes it.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    Frame: TFrame;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Frame := TFrame2.Create(Self);
  Frame.SetBounds(150, 100, 200, 200);
  Frame.Parent := Self;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Frame.Free;
end;

end.
0
 
EpsylonCommented:
Please take a look at my plugin-interface demo too:

http://www5.ewebcity.com/epsylon/download.asp?file=PluginInterface.zip


Regards,

Epsylon.
0
 
flooderCommented:
To unload a frame simply delete it.
Two put two frames on one form simply select one put in on the form and select the next one. If you want two frames acting as one, make a third frame that consists of the two previous frames and drop this single third frame on your form. The demo in delphi directory  \\demos\frames\db\...
is also a good example of frame capibilities and mixing frames and databases.

Cheers
Gerhardus
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
flooderCommented:
If your frame is dropped on the form in design time it is created when you start you application because it is then only a fancy container. Epsylon's demo will work fine to create a frame dynamically just make sure that the frames unit is included in the forms uses clause that want to create it.

Weereens Groete
Gerhardus
0
 
tzxie2000Commented:
Using table control with be more easy.
But using table control may need more memory.
If you apreciate with it,I can provide some code for you.
0
 
hellfire052497Author Commented:
Hi all,

Thanks for the info, Epsylon's first solution is exactly what I had in mind. So Epsylon if you want to lock the question, so I can give you the points.

Thanks
Marc
0
 
EpsylonCommented:
Hi Marc, if you need more info, feel free to ask.

Thanks for the points and regards,

Epsylon.
0
 
hellfire052497Author Commented:
Hi Epsylon,

I have one question left. I cannot find an Oncreate event with frames. I normally use this to initialize stuff.

Any idea how to do this with a Frame??

Thanks
Marc
0
 
EpsylonCommented:
Hi Marc, in the frame-unit you can override the constructor and add aditional code like this:


unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TFrame2 = class(TFrame)
    Edit1: TEdit;
  private
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  end;

implementation

{$R *.DFM}

{ TFrame2 }

constructor TFrame2.Create(AOwner: TComponent);
begin
  inherited;
  // out your own stuff here
end;

end.
0
 
hellfire052497Author Commented:
Hi Epsylon,

Thanks for the info. It just reminded me why I love Delphi so much ;-)

Take Care
Marc
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now