GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / GetMouseTopInDocument Method
Example





In This Topic
GetMouseTopInDocument Method (GdViewer)
In This Topic
Returns the vertical (Y) coordinate (0-based) of the mouse cursor position located in the document area, in pixels, related to the current page of the displayed document in the GdViewer control.
Syntax
'Declaration
 
Public Function GetMouseTopInDocument() As Integer
public int GetMouseTopInDocument()
public function GetMouseTopInDocument(): Integer; 
public function GetMouseTopInDocument() : int;
public: int GetMouseTopInDocument(); 
public:
int GetMouseTopInDocument(); 

Return Value

The vertical coordinate of the current mouse cursor position related to the document area, in pixels.

If you want to get the actual position in inches, just use PosInches = GdViewer.GetMouseTopInDocument() / GdViewer.VerticalResolution.

Remarks
Just to remind you, that all coordinates are 0-based with the origin being in the top left corner of the document pages area and they are related to the current page determined by the CurrentPage property.

You can regularly apply the GetStat method to determine if this method has been successful.

Example
How to zoom on the specified document area according to the mouse cursor position.
'We assume that the GdViewer1 control has been properly integrated.
Sub GdViewer1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim left As Integer = GdViewer1.GetMouseLeftInDocument()
    Dim top As Integer = GdViewer1.GetMouseTopInDocument()
    Dim width As Integer = 400, height As Integer = 200
    GdViewer1.ZoomArea(left - width / 2, top - height / 2, width, height)
End Sub
//We assume that the GdViewer1 control has been properly integrated.
void GdViewer1_MouseClick(object sender, MouseEventArgs e)
{
    int left = GdViewer1.GetMouseLeftInDocument();
    int top = GdViewer1.GetMouseTopInDocument();
    int width = 400, height = 200;
    GdViewer1.ZoomArea(left - width/2, top - height/2, width, height);
}
See Also