Forum > LCL

How to create single page application for desktop

<< < (2/2)

If you have 20 screens, it may be fine to work with frames. These frames allow you to develop without thousands lines of code to scroll.

F12 shows you the frame the same way as a form.

When you finish your work, you make your frames part of the pageControl by parent:

So the create event of your form will look like this (hope this works for Lazarus, I just dragged this code out of an old Delphi source):

  if Frame_BerichteAufMain = nil then begin
    Frame_BerichteAufMain:=TFrame_Berichte.Create(Form_Main);  // into storage
    Frame_BerichteAufMain.Parent:=Form_Main.TabSheet_Berichte; // display


Basically there is not much memory usage difference using a TPageControl with many pages vs using many TForms.

If you know, using TForm, all the forms will be created and loaded into memory before you show them, unless you disable its auto-create behavior. Even if you close the form, actually it just go hiding, the memory is not freed. Unless you call TForm.Free or set caFree in the CloseAction variable.

Most of the computers nowadays have 4 GB of RAM or more. Memory usage of a form has very little impact in the whole system.

But if you really care, in your case I think you can consider to close the Dataset if you switch to other tab or closing the form, and open or reopen it when needed.

About TFrame, I don't against it. But just what dsiders said, it needs extra effort. It can be tricky in some cases, try it and you would know what I meant.

As a programmer, you should be open, try and learn everything if you have the time. Each of the components has its own pros and cons.

Thank you again, @Nicole and @Handoko. Those are very helpful and informative comments.

I will try TPageControl with and without frames. As Handoko says, I need to learn!


[0] Message Index

[*] Previous page

Go to full version