Access to control in Tabcontrol

Class library usage, coding and language questions.
Nik
Posts: 18
Joined: Fri Sep 29, 2006 1:35 am

Access to control in Tabcontrol

Post by Nik » Tue Jan 09, 2007 2:21 am

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

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Tue Jan 09, 2007 9:46 pm

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