Page 1 of 1

Access to control in Tabcontrol

Posted: Tue Jan 09, 2007 2:21 am
by Nik
Hi,
I have a tabcontrol with 4 tabs in it. Each tab has listbox, combo box etc.
I have to navigate in all the tabs and dump the data in each of the control.
I am using Element approach but I am not able to dump the data except of the first tab. I am able to select the tabs but not able to grab the access of the controls in the tab.
Here is my code:

RxElementFindChild(elmRoot, ROLE_SYSTEM_PAGETABLIST,
GNTF_NULL, GNTF_NULL, &listElement);

for(each tab)
select tab
RxElementFindChild(&listElement, ROLE_SYSTEM_DIALOG,
GNTF_NULL, GNTF_NULL, &elmNewRoot);
dump the data

Can you please suggest a way to navigate in all the tabs and dump the data using Element approach.

Thanks,
Nikhil

Posted: Tue Jan 09, 2007 9:46 pm
by webops
In an older windows application, written with MFC, you should use the PropertyPage Role:
(See also MSDN Documentation)

Code: Select all

ElementStruct element;
RxControlGetElement(form, &element);
int itemCount = ::RxTabControlGetItemCount(htabControl);	
for(int item=0; item < itemCount; item++)
{
    ::RxTabControlSetSelectedIndex(htabControl,item);
    RxSleep(100);
    printf("Page=%d\n", item+1);

    ElementStruct clientElement;
    if ( RxElementFindChild(&element, ROLE_SYSTEM_PROPERTYPAGE, NULL, NULL, &clientElement) == TRUE )
    {
        int childCount = RxElementGetChildCount(&clientElement);
        for(int i=0; i< childCount; i++)
        {
            ElementStruct tabItem;
            if ( RxElementGetChild(&clientElement, i, &tabItem) == TRUE )
            {
                printf("    Name=%s Class=%s\n", tabItem.Name, tabItem.Class);
            }
            RxSleep(100);
        }
    }
}
In a newer windows application, written with .NET, the controls of the TabControl are in the Client area:

Code: Select all

ElementStruct element;
RxControlGetElement(htabControl, &element);
int itemCount = ::RxTabControlGetItemCount(htabControl);	
for(int item=0; item < itemCount; item++)
{
    ::RxTabControlSetSelectedIndex(htabControl,item);
    RxSleep(100);
    printf("Page=%d\n", item+1);
    
    ElementStruct clientElement;
    if ( RxElementFindChild(&element, ROLE_SYSTEM_CLIENT, 
            RxTabControlGetItemText(htabControl,item), NULL, &clientElement) == TRUE )
    {
        int childCount = RxElementGetChildCount(&clientElement);
        for(int i=0; i< childCount; i++)
        {
            ElementStruct tabItem;
            if ( RxElementGetChild(&clientElement, i, &tabItem) == TRUE )
            {
                printf("    Name=%s Class=%s\n", tabItem.Name, tabItem.Class);
            }
            RxSleep(100);
        }
    }
}
Jenö Herget
Ranorex Team