TextBox Labels

Ask general questions here.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

TextBox Labels

Post by atom » Tue Feb 17, 2009 8:49 pm

Hiya

I have a Win32 form, that has some Textbox's on it
Each textbox has a Label next to it

How can i identify the TextBox from the label next to it ?

Thanks

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 » Wed Feb 18, 2009 10:46 am

In Win32 forms these controls usually have no direct relationship. So there is no out-of-the-box method to do it.

If the layout looks like this ..

[Label1] [Textbox1]
[Label2] [Textbox2]
..
..

.. try the following:
Collect the Labels (in native win32 those are text[@class='Static']) and the Textboxes (text[@class='Edit']) in two separate lists
and compare those pairwise by geometry

so if L is the label rectangle and T the textbox rectangle

then check pairwise for
L.Right<T.Left and (L.Top+L.Bottom)/2 is >T.Top and <T.Bottom

That should do the trick.

Michael
Ranorex Team