Panning can be implemented in the Document Imaging SDK by handling the MouseDown, MouseMove, MouseUp events of the BiDisp control (BiDisp DLL or OCX).
Panning hand icon moves the image in the window.
Please see the following sample code for an implementation of panning:
[C#]
// The BiDisp object
public AxBIDISPLib.AxBIDisp Disp;
// Variables for storing the last cursor position
public int x;
public int y;
// Variable that will be set to true during a panning operation
public bool panning;
public Form1()
{
InitializeComponent();
// Subscribe to the events
Disp.MouseDownEvent += Disp_MouseDownEvent;
Disp.MouseUpEvent += Disp_MouseUpEvent;
Disp.MouseMoveEvent += Disp_MouseMoveEvent;
}
private void Disp_MouseDownEvent(object sender, AxBIDISPLib._DBIDispEvents_MouseDownEvent e)
{
// Start panning if the right button is pressed
if(e.button == 2)
{
panning = true;
// Capture the mouse cursor so we will receive the mouse events even if the user drags the cursor outside of the control
Disp.SetCapture();
// Save the current cursor position
x = e.x;
y = e.y;
}
}
private void Disp_MouseMoveEvent(object sender, AxBIDISPLib._DBIDispEvents_MouseMoveEvent e)
{
if(panning)
{
// Move the image by the same amount the mouse cursor moved since the last event
Disp.SetHorizontalScrollPos(Disp.GetHorizontalScrollPos() + x - e.x);
Disp.SetVerticalScrollPos(Disp.GetVerticalScrollPos() + y - e.y);
// Save the current cursor position
x = e.x;
y = e.y;
}
}
private void Disp_MouseUpEvent(object sender, AxBIDISPLib._DBIDispEvents_MouseUpEvent e)
{
if(panning)
{
// Release the cursor at the end of the panning operation
Disp.ReleaseCapture();
panning = false;
}
}
For the used functions and events please see the following pages in the manual: