UniGUI is SPA – single page application, but, emulation is possible.
One option – use frames.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
unit uPagesFramesDM; interface uses SysUtils, Classes, uPage1Frame, uPage2Frame; type TPagesFramesDM = class(TDataModule) private FCurrentPage: integer; FPage1: TPage1Frame; FPage2: TPage2Frame; FSomeParent: TObject; FHistory: TArray<integer>; procedure SetCurrentPage(const Value: integer); procedure KillFrames(); procedure AddHistory(AValue: integer); procedure SetMainForm(const Value: TObject); procedure SetHistory(const Value: TArray<integer>); { Private declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; procedure Back(); procedure Next(); procedure Load(aIndex: integer); property SomeParent: TObject read FSomeParent write SetMainForm; property CurrentPage: integer read FCurrentPage write SetCurrentPage; property History: TArray<integer> read FHistory write SetHistory; end; implementation uses Vcl.Controls, Main, uniGUIApplication; {$R *.dfm} { TDataModule1 } procedure TPagesFramesDM.AddHistory(AValue: integer); begin SetLength(FHistory, length(FHistory) + 1); FHistory[high(FHistory)] := AValue; end; procedure TPagesFramesDM.Back; begin if FCurrentPage > 0 then begin FCurrentPage := FCurrentPage - 1; Load(CurrentPage); end; end; constructor TPagesFramesDM.Create(AOwner: TComponent); begin inherited; // loadCurrentPage FHistory := [0, 1]; end; procedure TPagesFramesDM.Next; begin if FCurrentPage < High(FHistory) then begin FCurrentPage := FCurrentPage + 1; Load(CurrentPage); end; end; procedure TPagesFramesDM.KillFrames; begin if assigned(FPage1) then FreeAndNil(FPage1); if assigned(FPage2) then FreeAndNil(FPage2); end; procedure TPagesFramesDM.Load(aIndex: integer); begin case aIndex of 0: begin // load first page killFrames(); FPage1 := TPage1Frame.Create(MainForm); with FPage1 do begin Parent := MainForm; Align := alClient; Show(); end; end; 1: begin // load second page killFrames(); FPage2 := TPage2Frame.Create(MainForm); with FPage2 do begin Parent := MainForm; Align := alClient; Show(); end; end; end; end; procedure TPagesFramesDM.SetCurrentPage(const Value: integer); begin FCurrentPage := Value; end; procedure TPagesFramesDM.SetHistory(const Value: TArray<integer>); begin FHistory := Value; end; procedure TPagesFramesDM.SetMainForm(const Value: TObject); begin FSomeParent := Value; end; end. |
Then call its in main like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniPanel, uniButton, uniBitBtn, uPagesFramesDM; type TMainForm = class(TUniForm) pMainMenuTop: TUniPanel; bPrevious: TUniBitBtn; bNext: TUniBitBtn; bPage1: TUniBitBtn; bPage2: TUniBitBtn; procedure bPreviousClick(Sender: TObject); procedure bNextClick(Sender: TObject); procedure bPage1Click(Sender: TObject); procedure bPage2Click(Sender: TObject); procedure UniFormAfterShow(Sender: TObject); private { Private declarations } FPages: TPagesFramesDM; public { Public declarations } constructor Create(AOwner: TComponent); override; end; function MainForm: TMainForm; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication; function MainForm: TMainForm; begin Result := TMainForm(UniMainModule.GetFormInstance(TMainForm)); end; { TMainForm } procedure TMainForm.bPage1Click(Sender: TObject); begin FPages.Load(0); end; procedure TMainForm.bPage2Click(Sender: TObject); begin FPages.Load(1); end; procedure TMainForm.bPreviousClick(Sender: TObject); begin FPages.Back(); end; constructor TMainForm.Create(AOwner: TComponent); begin inherited; FPages := TPagesFramesDM.Create(UniApplication); FPages.SomeParent := Self; end; procedure TMainForm.UniFormAfterShow(Sender: TObject); begin FPages.Load(0); end; procedure TMainForm.bNextClick(Sender: TObject); begin FPages.Next() end; initialization RegisterAppFormClass(TMainForm); end. |