Forum > LCL

How to create single page application for desktop

(1/2) > >>

bruce.button:
This is very much a beginner question, but I haven’t been able to find an answer or work it out. If I have an application with a few document windows, each of which shows one of the main areas of the app, how do I change seamlessly between them while keeping the main menu (and maybe a header area) the same? In other words, to make an application with the familiar type of interface that most desktop applications have these days.

As far as I can work out, I can't put the same menu on two different forms. I've tried putting the menu into a frame and putting the frame onto the two forms, but that doesn't seem to work. Using different menus is obviously not an option since one would have to repeat the same code on all of them; and it something on the menu changes you have to change it for the main menu on every form — that's definitely not DRY programming!

I'm accustomed to doing this in Filemaker Pro with different layouts, but I can't seem to find out how to do it in Lazarus.

Thank you in advance for the assistance!

dsiders:

--- Quote from: bruce.button on August 05, 2022, 03:23:17 pm ---This is very much a beginner question, but I haven’t been able to find an answer or work it out. If I have an application with a few document windows, each of which shows one of the main areas of the app, how do I change seamlessly between them while keeping the main menu (and maybe a header area) the same? In other words, to make an application with the familiar type of interface that most desktop applications have these days.

As far as I can work out, I can't put the same menu on two different forms. I've tried putting the menu into a frame and putting the frame onto the two forms, but that doesn't seem to work. Using different menus is obviously not an option since one would have to repeat the same code on all of them; and it something on the menu changes you have to change it for the main menu on every form — that's definitely not DRY programming!

I'm accustomed to doing this in Filemaker Pro with different layouts, but I can't seem to find out how to do it in Lazarus.

Thank you in advance for the assistance!

--- End quote ---

You can use TPageControl to display pages of content. Set its ShowTabs property to False to hide the navigation tabs if you prefer to use  menu items to activate the pages.

You can use a TFrame descendant for each page if you're comfortable with the extra effort required.

Nicole:
Here is a nice tutorial which shows everything from the first click

https://lazplanet.blogspot.com/2013/12/create-rich-text-editor-for-yourself.html

Handoko:

--- Quote from: bruce.button on August 05, 2022, 03:23:17 pm ---If I have an application with a few document windows, each of which shows one of the main areas of the app, how do I change seamlessly between them while keeping the main menu (and maybe a header area) the same?

--- End quote ---

There are many solutions for it. You can use TPageControl or TFrame as suggest by dsiders. Or you can use MDI.

Learn more about MDI:
https://en.wikipedia.org/wiki/Multiple-document_interface
https://wiki.lazarus.freepascal.org/MultiDoc
https://wiki.freepascal.org/LMDI
https://forum.lazarus.freepascal.org/index.php?topic=45486.0

You can use TNotebook, example can be found in "Text File Demo #2". Not the best, you can even use TPanel. See the demo "simple transition effects". The demos can be get in the link below:
https://wiki.freepascal.org/Portal:HowTo_Demos#File_handling

bruce.button:
Thank you for all the helpful comments.

It seems to me that the TPageControl solution would best serve my needs. Would it be safe to use this for all the screens of a medium-sized application? I'm thinking of an application with about 20 screens, each one having a couple of grids drawing data from a database.

When I say "safe", I'm thinking about perhaps overloading the memory or something like that.

Thanks again!

Navigation

[0] Message Index

[#] Next page

Go to full version