ClientToDocument Method

Translates the specified viewer control (client) coordinates to the coordinates of the displayed document.

expression.ClientToDocument(plX, plY)

*expression   * Required. An expression that returns an MiDocView object.

plX    Required Long. A variable that specifies the viewer control (client) x-axis coordinate and returns the equivalent x-axis document coordinate.

plY    Required Long. A variable that specifies the viewer control (client) y-axis coordinate and returns the equivalent y-axis document coordinate.

Remarks

The ClientToDocument method translates the specified coordinates in pixels of the viewer control (the client) to the displayed document's coordinates. For example, if you scroll the document upward a small distance vertically in the viewer control, without scrolling horizontally, and pass in the values (100, 100), the ClientToDocument method may return a plX value of 100 and a plY value of 425. This indicates that the viewer and the document are aligned horizontally (that is, 100 pixels from the left edge of the viewer control is also 100 pixels from the left of the document), but that 100 pixels from the top of the viewer control is 425 pixels vertically from the top of the scrolled document (the top of which is scrolled beyond the top of the viewer control).

Example

The following example translates the viewer control (client) coordinates (100, 100) to document coordinates for the document displayed in the viewer control.

Sub TestClientToDocument()
  
  Dim x As Long, y As Long
  x = 100
  y = 100

  MiDocView1.ClientToDocument x, y
  MsgBox "Client to document coordinates:" & vbCrLf & _
    " Client X of 100 = Document X of " & x & vbCrLf & _
    " Client Y of 100 = Document Y of " & y

End Sub

Applies to | MiDocView Object