Delphi popup menu?
Hi
I'm having a bit of bother with popup menu objects which are spawned by right clicking on TTreeView menu object options.
The popup menu objects are transient. As soon as you move elsewhere on the screen, they vanish, so getting much in the way of info about properties/methods on them is kind of tricky.
I can make a selection from them no problem. Right click the item in the TTreeView menu (which causes the popup menu to be generated), then "PopUpMenu" is a property of it (it being the TTreeView - I never act on the popup menu as an object in it's own right) 0and you can select from the popup using pipe separators to as many levels deep as you need. In much the same way as you select items in the TTreeView.
However, I'm struggling to find any way of doing anything other than select items as I can't spy the object to get any further detail on what, if anything, I can do with it.
CTRL+SHIFT+A in object spy does allow me to capture it. But it then immediately disappears and doesn't leave me with any useful information in the object spy details.
I've looked up the object documentation and tried a few of the properties and methods mentioned on it, but most don't work or return a dummy context menu rather than anything useful
It's these popup objects it's generating: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Menus_TPopupMenu.html
Debug build options are switched on for the Delphi module so I have access to all the underlying methods and properties.
Any suggestions on how to do stuff like validating that a specific menu option exists within the menu once it's brought up? It's things along those lines I'd like to do rather than just driving it blind and hoping the selections I give it (data driven test functions) are valid .....
Thanks in advance.
** FINAL UPDATE **
OK. I have it working now.
Was not able to use the index. Even with three levels of menu open (all of type "Popup") they all report an index of 1 and it always finds the first level container? No idea why. But thats what was happening.
So, I ended up using the "Name" property. As each new level container is spawned, it's name appears to be dynamically generated based on the selection prior to it. With the first level always having the name "Context".
So to find each level, I search for a container of type "Popup" with "Name" properties of:
Level 1 - ["Popup"]("Context") - pre-populated
Level 2 - ["Popup"]("Level 1 selection text") - Selection text based on the user input
Level 3 - ["Popup"]("Level 2 selextion text") - Same as above ...
And so on. For as few or many levels deep as requirted. (It's in a loop obviously) As it finds each new container, finding the MenuItem within that is simple. It hovers each one until the end and clicks on the final one if it gets through without any errors.
The containers are all direct children of the top level process so it doesn't have to search too deep. Each container then only contains a handful of MenuItem object to search through. So the speed remains good.
As each component is searched out and identified before it is used, I can validate as I go and and failed object searches will be picked up and generate the required error messages. (This is all data driven so needs to be robust in case people feed it garbage)
Very convoluted way of getting there. But got there in the end.