Page 1 of 1

Button images from toolbar

Posted: Tue Aug 25, 2009 11:29 am
by chrisgeorge
I'm trying to get the image from a toolbar button with little success.

After quickly realising that it wasn't a property on the Ranorex.Button object/element, I thought about trying the remote invoke stuff again (like I did for the treeview). But I can't seem to cast the button objects to Ranorex.Control.

If i use .As<Ranorex.Control>() then the resulting control object is null
if I use the Ranorex.Control constructor, it throws a capability exception.

I don't want to have to just use the CaptureCompressedImage (which I assume just takes a screenshot of that image) as we will be running on multiple OS's and this will not be reliable enough.

Any ideas?

Thank

Chris

Re: Button images from toolbar

Posted: Tue Aug 25, 2009 12:29 pm
by Support Team
You can only create a Ranorex.Control adapter from an element if the element supports the corresponding "Control" capability, i.e. if the "Control" capability is listed in the "General" tab in Ranorex Spy for that element. Please read the following chapter in the Ranorex User Guide for more info:
http://www.ranorex.com/support/user-gui ... apter.html

If your application is a .NET Windows Forms app, I bet that the parent of your toolbar button element has the Control capability. You can then call InvokeRemotely on that parent element and get the icon corresponding to the button.

And right, if you use the Imaging class or the CaptureCompressedImage method, you will get a screenshot of the element.

Regards,
Alex
Ranorex Support Team

Re: Button images from toolbar

Posted: Wed Aug 26, 2009 9:38 am
by chrisgeorge
Hi Alex,

So the application I'm trying to use is SqlServer management studio... and the parent of the button is either a Toolbar or Menubar, both I believe are MsoCommandBar objects, neither of which have the Control capability.

I'm assuming MsoCommandBar are Win32?? can these be cast to something that ranorex knows about to get more than just rudimentary control?

Re: Button images from toolbar

Posted: Wed Aug 26, 2009 2:01 pm
by Support Team
InvokeRemotely only works with .NET Windows Forms controls, so that's not an option for pure Win32 windows.

Currently, there is no direct way in Ranorex to get the icons from MsoCommandBar toolbar buttons. And I doubt there will be a way in the near future, since the interface for this control is not open to the public. So, the only way right now is to use screenshots (Imaging class or CaptureCompressedImage method).

Regards,
Alex
Ranorex Support Team

Re: Button images from toolbar

Posted: Thu Aug 27, 2009 8:31 am
by chrisgeorge
I suspected as much, but thanks anyway :-). Our testers will have to do that manually... sigh! lol