Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 17 of 17 total
Thread How to find or go to a Page by its name
Fri, Jun 3 2016 12:14 PMPermanent Link

Uli Becker

I have been using FindComponent for a quite long time without problems.
My Cinedisk application wouldn't work without that. Smile

procedure TForm1.Button1Click(Sender: TObject);
var
   TestComponent: TLabel;
begin
   TestComponent := TLabel(FindComponent('Label1'));
   ShowMessage(TestComponent.caption);
end;

Just try it. It works!

Uli
Sun, Jun 5 2016 2:36 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Question: Is it possible to find a tab in an Application by its name?  >>

Do you mean "tab" or "page" ?  Tabs are contained within a TPage component instance and don't have a "name", so you would have to look for the name of the TPage, not the tab.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jun 6 2016 12:52 PMPermanent Link

Trinione

@Uli, yes, it works. However, I am trying to find a component on another form.

@ Tim, yes I mean page.

Basically, pages are created dynamically at Run-time. They are named and based on this name I need to see if the page exists, and then 'jump' to it by showing it to the user.
Tue, Jun 7 2016 4:22 AMPermanent Link

Matthew Jones

Trinione wrote:

> Basically, pages are created dynamically at Run-time.

When I do this, I keep a record of the components created so that I
don't have to spend time finding them later. A TObjectList is ideal,
with a matching TStringList if you need to reference by text. One day
we may get a list with both string and object like the Delphi
TStringList's Object property, but that would probably be better done
as a dictionary or something anyway, and if one is getting fancy, the
better option still is to create an object to represent the data, and
have the reference string and the UI component stored as properties,
and then put that in a TObjectList. Wrap that in a controller and we
reach the ideal.

Sorry, got a bit carried away there, but that's what I have found so
good about EWB - there is no limit to doing things properly. I have
been so happy using it to write my current application as I just write
nice OOP code and it handles it without problem.

--

Matthew Jones
Tue, Jun 7 2016 7:12 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Tim, yes I mean page. >>

Yes, you can find a TPage instance by name on another form using FindComponent, provided that the form was created with the global Application instance as its owner.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jun 7 2016 7:13 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

In case it's not clear, you would use something like this:

Application.FindComponent('MyPage',True);

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jun 8 2016 11:15 AMPermanent Link

Trinione

Thank you both. I will give this a go.
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image