Page 1 of 1

ListView in a tab control

Posted: Wed Oct 04, 2006 12:38 am
by Nik
Hi,
I have a dialog box application in which I have a tab control. Each tab has a listview in it. I want to access the list view item. How to do that?

Currently, I am getting handle to a main window-> Handle to a tab control -> Handle to a list view -> and calling RxListViewGetItemCount().
But the function returns 0 even if the list view contains 10 items.

I am using using VC++ 6.0 on Windows XP.
Please opine.

Thanks.
Nikhil

Re: ListView in a tab control

Posted: Wed Oct 04, 2006 5:57 pm
by Nik
Hi,
I found the solution. As per my understanding, it looks like a bug in Ranorex.
I used
HWND hTabControl1 = RxFormFindChildClassName(form, "SysTabControl32", 1);
HWND hTree = RxFormFindChildClassName(hTabControl1, "SysTreeView32", 1);

With this I get the handle to a treecontrol in the last tab. I thought I'll get the tree handle in the first tab.

So the workaround is to set index on the second tab with
RxTabControlSetSelectedIndex (hTabControl1, 1);
and then
call RxTabControlSetSelectedIndex (hTabControl1, 0);
to set the first tab as the current tab.
Once you do this, you can get the handle of treecontrol in the first tab.

Please opine.
-Nikhil

Nik wrote:Hi,
I have a dialog box application in which I have a tab control. Each tab has a listview in it. I want to access the list view item. How to do that?

Currently, I am getting handle to a main window-> Handle to a tab control -> Handle to a list view -> and calling RxListViewGetItemCount().
But the function returns 0 even if the list view contains 10 items.

I am using using VC++ 6.0 on Windows XP.
Please opine.

Thanks.
Nikhil

Posted: Thu Oct 05, 2006 10:08 pm
by webops
Nik wrote:With this I get the handle to a treecontrol in the last tab. I thought I'll get the tree handle in the first tab.
You should only find a control with ClassName and instance number if you have no other possibility. It's better to use FormFindControlId or the Element functions. ClassName and instance number are not unique identifier. Ranorex goes through all children of a control, reads ControlName, ControlId, ClassName and increments the instance number for each child with the same ClassName. There are no rules, which control gets the first instance number if you have more the one children.

But i know the problem, in older applications the controls have sometimes no ControlName and no unique ControlId.

Jenö Herget
Ranorex Team