Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Back to home page



Permlink Replies: 7 - Last Post: Feb 23, 2018 4:01 AM Last Post By: Daniel Fields
Pramod Nair

Posts: 105
Registered: 5/21/06
Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 20, 2018 8:35 PM
How we can go back to the home page from a sub page? For example from the home page I open the subpage1 by using the command,

TSubform1.Create(WebApplication).Show;

and from the subopage1 open the subpage2. From the subpage2 i want to go back to the home page. The release command release only the active page. Currently i am releasing the page recreate the home page.

Release
Tmainform.Create(WebApplication).Show;

Instead of recreate is it possible to show? I tired the below but getting access violation

TIWAppForm(Tmainform).Show;
Jose Nilton Pace


Posts: 122
Registered: 5/15/98
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 5:03 AM   in response to: Pramod Nair in response to: Pramod Nair
Hi Pramod, try this:

TSubform1.Create(WebApplication).Show;
-> don't releaseTMainform ok.
TSubform2.Create(WebApplication).Show;
-> Release TSubform1

When finish on TSubform2, Release only ok.
Pramod Nair

Posts: 105
Registered: 5/21/06
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 8:20 PM   in response to: Jose Nilton Pace in response to: Jose Nilton Pace
from the subform2 if click on back button then want to go to subform1 and if click on home button then go to home page

Jose Nilton Pace wrote:
Hi Pramod, try this:

TSubform1.Create(WebApplication).Show;
-> don't releaseTMainform ok.
TSubform2.Create(WebApplication).Show;
-> Release TSubform1

When finish on TSubform2, Release only ok.
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 10:43 PM   in response to: Pramod Nair in response to: Pramod Nair
You should use that code and logic behind every Back and Next button. That will give you the behavior that you want, but you will have to free. the forms elsewhere.

procedure TSubform2.BackBtnAsyncClick(Sender: TObject; EventParams: TStringList);
var AForm : TIWForm;
begin
  if WebApplication.FindComponent('Subform1') <> nil then
    WebApplication.SetActiveForm(WebApplication.FindComponent('Subform1') as TIWContainer)
  else
  begin
    AForm := TSubform1.Create(WebApplication);
    WebApplication.SetActiveForm(AForm);
  end;
end;
 
procedure Tsubform2.HomeBtnAsyncClick(Sender: TObject; EventParams: TStringList);
var AForm : TIWForm;
begin
  if WebApplication.FindComponent('Mainform') <> nil then
    WebApplication.SetActiveForm(WebApplication.FindComponent('Mainform') as TIWContainer)
  else
  begin
    AForm := TMainform.Create(WebApplication);
    WebApplication.SetActiveForm(AForm);
  end;
end;
 
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 22, 2018 12:11 AM   in response to: Daniel Fields in response to: Daniel Fields
Here is an optimized version of the code that works as long as the forms have not been released.


procedure TSubform2.BackBtnAsyncClick(Sender: TObject; EventParams: TStringList);
begin
  WebApplication.SetActiveForm(WebApplication.FindComponent('Subform1') as TIWContainer);  //assumes the form has not been released!
end;
 
procedure Tsubform2.HomeBtnAsyncClick(Sender: TObject; EventParams: TStringList);
var AForm : TIWForm;
begin
  WebApplication.SetActiveForm(WebApplication.FindComponent('Mainform') as TIWContainer);  //assumes the form has not been released!
end;
Pramod Nair

Posts: 105
Registered: 5/21/06
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 23, 2018 3:11 AM   in response to: Daniel Fields in response to: Daniel Fields
Thanks alot Daniel
Its worked

Daniel Fields wrote:
Here is an optimized version of the code that works as long as the forms have not been released.

 
procedure TSubform2.BackBtnAsyncClick(Sender: TObject; EventParams: TStringList);
begin
  WebApplication.SetActiveForm(WebApplication.FindComponent('Subform1') as TIWContainer);  //assumes the form has not been released!
end;
 
procedure Tsubform2.HomeBtnAsyncClick(Sender: TObject; EventParams: TStringList);
var AForm : TIWForm;
begin
  WebApplication.SetActiveForm(WebApplication.FindComponent('Mainform') as TIWContainer);  //assumes the form has not been released!
end;
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 23, 2018 4:01 AM   in response to: Pramod Nair in response to: Pramod Nair
Awesome! You're welcome.
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: Back to home page
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 21, 2018 8:38 AM   in response to: Pramod Nair in response to: Pramod Nair
This code checks for an instance of the form or creates an instance if one is not found.

procedure TIWUserSession.MyBtnAsyncClick(Sender: TObject; EventParams: TStringList);
var AForm : TIWForm;
begin
  if WebApplication.FindComponent('FormDashboard') <> nil then
    WebApplication.SetActiveForm(WebApplication.FindComponent('FormDashboard') as TIWContainer)
  else
  begin
    AForm := TFormDashboard.Create(WebApplication);
    WebApplication.SetActiveForm(AForm);
  end;
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02