Home > Language Reference > Classes > UIComponent

ScreenToComponent Method

Converts coordinates relative to the screen into coordinates relative a component.

Syntax

Public Sub ScreenToComponent(ByRef x As Integer, ByRef y As Integer)

ParameterDescription
xX-coordinate to convert.
yY-coordinate to convert.

Remarks

The ScreenToComponent method converts the x and y coordinates relative to the top left corner of the screen into coordinates relative to the top left corner of the component.

The reciprocal conversion is possible using the ComponentToScreen method. These two methods are often used together to convert coordinates relative to one component into coordinates relative to another component.

The example below illustrates this by converting coordinates relative to a Button control into coordinates relative to the form on which it is found:

Private Sub Button1_PenDown(ByVal x As Integer, ByVal y As Integer)
  Button1.ComponentToScreen x, y
  Me.ScreenToComponent x, y

  ' code using x and y

End Sub

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A