GdPicture.NET Reference Guide
GetHorizontalScrollBarPosition Method
Example 





GdPicture14.WPF Namespace > GdViewer Class : GetHorizontalScrollBarPosition Method
Gets the current position of the horizontal scrollbar, in pixels, related to the document currently displayed in the GdViewer control. The resulting coordinate corresponds to the actual document area of the currently displayed page.
Syntax
'Declaration
 
Public Function GetHorizontalScrollBarPosition() As Double
public double GetHorizontalScrollBarPosition()
public function GetHorizontalScrollBarPosition(): Double; 
public function GetHorizontalScrollBarPosition() : double;
public: double GetHorizontalScrollBarPosition(); 
public:
double GetHorizontalScrollBarPosition(); 

Return Value

The current horizontal coordinate of the horizontal scrollbar, in pixels, related to the displayed document.
Remarks
You can regularly apply the GetStat method to determine if this method has been successful.

Just to remind you, that this coordinate is 0-based with the origin being in the top left corner in the document pages area and it is related to the current page determined by the CurrentPage property.

Example
How to get the current position of the scrollbars.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
 
    'The current position of both scrollbars after displaying the document
    'according to your currently defined GdViewer control settings.
    Dim x As Double = GdViewer1.GetHorizontalScrollBarPosition()
    Dim y As Double = GdViewer1.GetVerticalScrollBarPosition()
    MessageBox.Show("The scrollbars are set to this position: " + x + ", " + y, "GdViewer.GetHorizontalScrollBarPosition")
 
    If (x <> 0) OrElse (y <> 0) Then
        'Setting the scrollbars to the required position.
        GdViewer1.SetHorizontalScrollBarPosition(0)
        GdViewer1.SetVerticalScrollBarPosition(0)
        MessageBox.Show("The scrollbars are now set to this position: 0, 0", "GdViewer.GetHorizontalScrollBarPosition")
    End If
 
    'Do your other stuff here.
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetHorizontalScrollBarPosition")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    //The current position of both scrollbars after displaying the document
    //according to your currently defined GdViewer control settings.
    double x = GdViewer1.GetHorizontalScrollBarPosition();
    double y = GdViewer1.GetVerticalScrollBarPosition();
    MessageBox.Show("The scrollbars are set to this position: " + x.ToString() + ", " + y.ToString(), "GdViewer.GetHorizontalScrollBarPosition");
 
    if ((x != 0) || (y != 0))
    {
        //Setting the scrollbars to the required position.
        GdViewer1.SetHorizontalScrollBarPosition(0);
        GdViewer1.SetVerticalScrollBarPosition(0);
        MessageBox.Show("The scrollbars are now set to this position: 0, 0", "GdViewer.GetHorizontalScrollBarPosition");
    }
 
    //Do your other stuff here.
    GdViewer1.CloseDocument();
}
else
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetHorizontalScrollBarPosition");
See Also

Reference

GdViewer Class
GdViewer Members
SetHorizontalScrollBarPosition Method
GetHorizontalScrollBarMaxPosition Method
SetScrollBarsPosition Method
GetDisplayedArea Method