#include "BIDISP.H"
LRESULT CALLBACK DisplaySetScrollPos( HWND hWnd,
LPDISPLAYSTRUCT lpView,
LPPOINT ptPos)
Description
Scrolls the displayed image to the new position. Create a Pan Window with this function.
Parameters
|
HWND |
hWnd |
Window handle to getting client parameters. |
|
LPDISPLAYSTRUCT |
lpView |
Display information structure. |
|
LPPOINT |
ptPos |
New scroll position. |
Return values
Returns 0 on success, or error code.
Programming notes
The scroll position in the scroll range is stored in the DISPLAYSTRUCT
rcScrollRange store the valid scroll positions.
rcScrollRange.left - minimum X scroll position.
rcScrollRange.right - maximum X scroll position.
rcScrollRange.top - minimum Y scroll position.
rcScrollRange.bottom - maximum Y scroll position.
pScrollPos store the current scroll positions.
pScrollPos.x - current X scroll position.
pScrollPos.y - current Y scroll position.
All scroll positions use device coordinates in pixel.
Not all scroll positions are valid. The function checks the new position and scrolls to the best valid position . The minimum scrollable unit depends on the scaling mode and the scaling factor. This value is not stored in DISPLAYSTRUCT but can be calculated by using MapDisplayDC function.
POINT ptMinScrollUnit;
HDD hDc = GetDC(hWnd);
MapDisplayDC(hDC,&Disp);
GetViewportExtEx(hDC,& ptMinScrollUnit );
ReleaseDC(hWnd,hDC);
Requirements
Header : Declared in BIDisp.h; include BIDisp.h.
Library : Use BIDisp.lib.
DLLs : BIDisp.dll.
Code example
For an example on how to scroll the image with the mouse wheel using the DisplaySetScrollPos function, please see the How to scroll an image with the mouse wheel page.
Example code to create pan with this function.
POINT ptStartScroll , ptStartMouse;
BOOL bDown;
LRESULT WndProc(HWND hWNd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
switch (iMessage)
{
case WM_LBUTTONDOWN:
bDown = TRUE;
ptStartScroll = sDisplay.pScrollPos;
ptStart = (POINT) lParam;
break;
case WM_MOUSEMOVE:
if ( bDown )
{
POINT ptNewPos ,ptMouse;
ptMouse = (POINT) lParam;
ptNewPos.x = ptStartScroll.x - ( ptMouse.x- ptStartMouse.x);
ptNewPos.y = ptStartScrolll.y - (ptMouse.y- ptStartMouse.y);
DisplaySetScrollPos(hWnd,&sDisplay,&ptNewPos);
}
break;
case WM_LBUTTONUP:
bDown = FALSE;
break;
}
}