Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: searching menus and sub menus


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Jan 17, 2018 10:55 PM Last Post By: Peter Below Threads: [ Previous | Next ]
Lex Dean

Posts: 132
Registered: 3/26/07
searching menus and sub menus  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 16, 2018 2:45 AM
1st thanks you Peter Below and Remy Lebeau

I have used many of your suggestions to complete quite a large OOP project
It now runs very smoothly and feels very sharp to the user too.
but with a lot of patients error testing and getting my head around things but I'm their at last.

I want to explain my self with this question
I have a Popupmenu with over 50 sub Items (That's heaps) its also quite complex
I need to make some invisible while they are not in Use!!!!!!!! and at times they will be in use
I find the 'find' statement only looks at the TMenuitems below it and not sub menus as well that I need.
So I need to build a better find statement and see even find the TMenuitem by object name would be better.
So I have to find the tools to work with the issue, as i'm moving into sub items (side ways) 3 columns
Only I would do that

Now Do I have this correct?
a) a TMenuitem contain's a .Items list (TList) of all the TMenuitems below it? and every TMenuitem holds a parent back to the first TMenuitem that lists it.
b) how do I find sub-menu's expressed commonly to the left of a TMenuitem?

Thanks
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: searching menus and sub menus [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 16, 2018 9:25 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

1st thanks you Peter Below and Remy Lebeau

I have used many of your suggestions to complete quite a large OOP
project It now runs very smoothly and feels very sharp to the user
too. but with a lot of patients error testing and getting my head
around things but I'm their at last.

I want to explain my self with this question
I have a Popupmenu with over 50 sub Items (That's heaps) its also
quite complex I need to make some invisible while they are not in
Use!!!!!!!! and at times they will be in use I find the 'find'
statement only looks at the TMenuitems below it and not sub menus as
well that I need. So I need to build a better find statement and see
even find the TMenuitem by object name would be better. So I have to
find the tools to work with the issue, as i'm moving into sub items
(side ways) 3 columns Only I would do that

If you know a menu items Name (the content of the Name property) you
can find it by using the form's FindComponent method. All components
owned by the form can be found this way, so you don't need to navigate
the menu tree.


Now Do I have this correct?
a) a TMenuitem contain's a .Items list (TList) of all the TMenuitems
below it? and every TMenuitem holds a parent back to the first
TMenuitem that lists it. b) how do I find sub-menu's expressed
commonly to the left of a TMenuitem?

A submenu is a TMenuitem that has a Count > 0.

--
Peter Below
TeamB

Lex Dean

Posts: 132
Registered: 3/26/07
Re: searching menus and sub menus [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 16, 2018 7:22 PM   in response to: Peter Below in response to: Peter Below
Peter Below That is a good idea to use the form's FindComponent
its simple that way
Lex Dean

Posts: 132
Registered: 3/26/07
Re: searching menus and sub menus [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 17, 2018 10:25 PM   in response to: Lex Dean in response to: Lex Dean
This to me is basic code
But 'Form1.Components[I] is TMenuItem' leaks Components that are not TMenuItem objects
And the caption is not found to read.
What am I doing wrong?

for I := 0 to Form1.ComponentCount - 1 do
If Form1.Components[I] is TMenuItem then
begin
Str := TMenuItem(Form1.Controls[I]).Caption;
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: searching menus and sub menus [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 17, 2018 10:55 PM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

This to me is basic code
But 'Form1.Components[I] is TMenuItem' leaks Components that are not
TMenuItem objects And the caption is not found to read.
What am I doing wrong?

for I := 0 to Form1.ComponentCount - 1 do
If Form1.Components[I] is TMenuItem then
begin
Str := TMenuItem(Form1.Controls[I]).Caption;

Open your eyes <g>. You are referring to the Controls array on the
bottom line, where you should use the Components array.

--
Peter Below
TeamB
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02