Is possible to make a Win32 FMX app works similar to a mobile application? When I click to show a new form (Form2.Show, ie.) it will of course open a new window, floating away the main (1st form).
Is possible to make a Win32 FMX app works similar to a mobile application? When I click to show a new form (Form2.Show, ie.) it will of course open a new window, floating away the main (1st form).
Using Parent don't works (Form2.Parent := Form1; ... )
I read this answer from Brian but was unable to figure out how to make it work, using the same example of the OP did not make the magic :), here: https://community.embarcadero.com/answers/q-best-practices-for-opening-closing-fmx-form
https://community.embarcadero.com/answers/q-best-practices-for-opening-closing-fmx-form
Using Parent don't works (Form2.Parent := Form1; ... )
I read this answer from Brian but was unable to figure out how to make it work, using the same example of the OP did not make the magic :), here: https://community.embarcadero.com/answers/q-best-practices-for-opening-closing-fmx-form
https://community.embarcadero.com/answers/q-best-practices-for-opening-closing-fmx-form
use this code and call ShowForm with the form you would like to display in a contaner
ReplyDeleteIn my case I used a TLayout but Self can be used too
FCurrentForm is of class TForm and Keep track of form displayed.
procedure TForm1.ShowForm(AForm: TForm);
var
Component : TComponent;
i : Integer;
begin
if Assigned(FCurrentForm) then
begin
for i:=0 to FCurrentForm.ComponentCount-1 do
begin
Component:=FCurrentForm.Components[i];
If (Component is TControl) and (TControl(Component).Parent=ClientLayout{Self}) then
TControl(Component).Parent:=FCurrentForm;
end;
FCurrentForm.Close;
end;
FCurrentForm:=AForm;
for i:=0 to FCurrentForm.ComponentCount-1 do
begin
Component:=FCurrentForm.Components[i];
If (Component is TControl) and (TControl(Component).Parent=FCurrentForm) then
TControl(Component).Parent:=ClientLayout; // Self;
end;
Caption:=ExpandStringResource(AForm.Caption);
if Assigned(FCurrentForm.OnShow) then
FCurrentForm.OnShow(Self);
FCurrentForm.SetBounds(0,0,ClientWidth,ClientHeight);
UpdateStyleBook;
// Application.ProcessMessages;
end;
Lots of different ways to do it. Can just use TTabControl and TFrames. Can Hide the Main form when you Show the sub form as long as you make sure their Top and Left are the same.
ReplyDeleteFrames + https://github.com/andrea-magni/TFrameStand for ease of use (plain frames can be pretty difficult to work with, when the content becomes complex)
ReplyDeleteThank you guys!! I will make some tests here. Eli M about hide the main form I did, but it is not elegant lol and the sequent forms appears displaced, user see a flick screen, but the TFrames can be a solution.
ReplyDeleteAlexander Brazda Thanks I will first try this method!
ReplyDelete