Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postion Of Control On Form

Status
Not open for further replies.

AlastairP

Technical User
Feb 8, 2011
286
AU
How do I get the position of a text box or edit box relative to the top of the SCREEN?
This is for a tablet PC, for when the keyboard is covering the controls needing data entry

this.xyzcontrol.top is only useful if the control is on the form.
If control is in a container (Which they all are) this refers to the top of the container






 
You can find any control's position relative to the form with OBJTOCLIENT().

 
Just to add to Dan's answer, the following code might be useful. Put this in a custom method of the control:

Code:
* Left position of the control
lnLeft = OBJTOCLIENT(this, 2) + thisform.Left + SYSMETRIC(3)

* Top position of the control
lnTop = OBJTOCLIENT(this, 1) + this.Height + thisform.Top + ;
  SYSMETRIC(9) + SYSMETRIC(4)

In both cases, this gives the position of the control relative to the _SCREEEN client area, taking account of window borders and scroll bars.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top