Example





In This Topic
GdPicture14 Namespace / GdViewer Class / GetMouseLeftInDocument Method

GetMouseLeftInDocument Method (GdViewer)

In This Topic
Returns the horizontal (X) 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 GetMouseLeftInDocument() As Integer
public int GetMouseLeftInDocument()
public function GetMouseLeftInDocument(): Integer; 
public function GetMouseLeftInDocument() : int;
public: int GetMouseLeftInDocument(); 
public:
int GetMouseLeftInDocument(); 

Return Value

The horizontal 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.GetMouseLeftInDocument() / GdViewer.HorizontalResolution.

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