Jump to content
Sign in to follow this  
IElite

Keeping track of forms

Recommended Posts

Hopfully I haven't missed something and some or all of this already exists :)

Currently in the RTL , you can use the Application's CurrentForm property to keep track of the current form. However, this is a property of type TW3CustomForm. This does not help you when using the Applications Forms array, which requires an integer type. This means I have to create and keep track of my own property for the current index

procedure TApplication.HandleNextClick(Sender: TObject);
begin
 //go to next form
  inc(FFormIndex);
  Application.GotoForm('Form' + intToStr(FFormIndex));
  UpdateGUI
end;

procedure TApplication.HandleBackClick(Sender: TObject);
begin
 //go to previous form
  Dec(FFormIndex);
  //Application.GotoForm('Form' + intToStr(FFormIndex));
  Application.GotoFormByRef(Application.Forms[]);
  UpdateGUI
end;

procedure TApplication.ApplicationStarting;
begin
  inherited;
  FFormIndex:= 1;

end;

It would be nice to have this property all ready created and tracked in the RTL

Maybe call it  FormIndex or CurrentFormIndex property ?

Maybe then you could also create a method GoToFormByIndex ? Allowing users to not have to Concatenate an integer to the string name to navigate between forms :)

e.g.

property FormIndex: Integer read getFormIndex;

procedure GotoFormByIndex(aIndex: integer; Effect: TFormEntryEffect = feNone);

 

Share this post


Link to post
Share on other sites

True, this could be nice to have automated.

What I usually do is just add an array of TW3CustomForm's to TApplication, and then use the Push() and Pop() to keep track.
When you use the array as a stack its much easier and you can move back with a single call:

Application.GotoFromByRef(Application.FormStack.Pop(), feToRight);

Since its such a small thing we havent really given it much attention, but yes - ill keep that in mind!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×