Problem with custom ListBox

Class library usage, coding and language questions.
Duncan Scott
Posts: 5
Joined: Thu Sep 04, 2008 1:51 pm

Problem with custom ListBox

Post by Duncan Scott » Fri Sep 05, 2008 9:51 am

Hi,

I'm currently evaluating your product as a replacement for our current automation solution.

I'm having a problem with one of our controls. We have a few custom controls written in C++, and this one is a special ListBox with acts almost like a treeview. I don't think I can send you a copy of the application, but there's a page here for it on our company website:
http://www.qas.co.uk/products/demonstra ... /index.htm
so you can see what I mean, and download a trial version. I can send you a screenshot if you like, but there doesn't seem to be an option to upload one.

Essentially, the problems I have are:
1) I can't read the text correctly from the items in the ListBox (their values are all 0), and the ListItem names are garbage like "?ç???". I think the problem probably stems from the fact that the text actually has icons in front of it. It's worth noting that the text can be read with the other automation software we use, which uses VB6.

2) I can't work out how to double click on one of the ListItems. Your examples seem to be based on text which I can't read correctly. There don't appear to be any functions that allow me to get a ListItem Control from the ListBox using its index. Even in the Professional version, the ListBox class is missing the "Items" property, which is what I'd normally use. And the ItemCount of ListBox is different to the ListBox.Element.ChildCount value for some reason.

Hope you can help :). This seems to be the main stumbling block with most of the automation software we've tried. Our current automation software handles it, but it's based on VB6. Ideally we'd like to move to something newer like your software.

Cheers,
Duncan
[/url]

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Post by Support Team » Mon Sep 08, 2008 3:25 pm

I had a look at the application and at that ListBox.

Ad 1) The ListBox is owner-drawn and does not return text in response to window messages like LB_GETTEXT, but a pointer to internal data. The Ranorex.ListBox methods try to interpret that data as a string, that's why the names are all garbage. Unfortunately, the ListBox does not support MSAA correctly, either. Hence, the name of the ListBox' child elements contain garbage, too. (Text readers like the Microsoft Windows Narrator won't be able to read the list items.)
If your VB6 automation software returns meaningful names, it seems to know the internal structure of your ListBox.

Ad 2) You can use the ListBox.SelectedIndex property to select an item by its index. Or use the element approach to get the list item elements using the ListBox.Element.FindChildren(Role.ListItem) method. (Note, that the immediate children of a ListBox.Element are not the list items, but elements for its scrollbar, menu, and so on. One of it's immediate children has the role List, and the children of this element are the real list items.)

Regards,
Alex
Ranorex Support Team

Duncan Scott
Posts: 5
Joined: Thu Sep 04, 2008 1:51 pm

Post by Duncan Scott » Tue Sep 30, 2008 8:54 am

Thanks very much. I've asked our developers to look into it. It looks like they've agreed to improve the components to make them more readable for automation tools :).