$ESCAPECHARS ON
$TYPECHECK ON
DECLARE SUB Paint
DECLARE SUB OnForm_KeyDown (Key AS BYTE, Shift AS INTEGER)
DEFSTR Help = " SCROLL WITH : Up, Down, Left, Right And ZOOM WITH +, - Keys"
DIM Bitmap AS QBITMAP
CREATE Form AS QFORM
WindowState = 2
OnKeyDown = OnForm_KeyDown
CAPTION = Help
CREATE Canvas AS QCANVAS
Align = 5
OnPaint = Paint
END CREATE
END CREATE
DECLARE FUNCTION SetWindowLong LIB "user32" ALIAS "SetWindowLongA" (hWnd AS LONG, _
nIndex AS LONG, dwNewLong AS LONG) AS LONG
CONST GWL_HWNDPARENT = (-8)
CONST HWND_DESKTOP = 0
setwindowlong(Form.handle, GWL_HWNDPARENT, HWND_DESKTOP)
setwindowlong(application.handle, GWL_HWNDPARENT, Form.handle)
Form.Show
DIM Source AS QRECT
DIM Destination AS QRECT
DEFINT bmpTop = 1, bmpLeft = 1, Busy = 0
DEFSNG Zoom = 1
Bitmap.BMP = "test.bmp"
Paint
Form.Visible = 0
Form.SHOWMODAL
SUB Paint
WITH Source
.Top = bmpTop
.Left = bmpLeft
.Right = (Canvas.Width * Zoom) + bmpLeft
.Bottom = (Canvas.Height * Zoom) + bmpTop
END WITH
WITH Destination
.Top = 0
.Left = 0
.Right = Canvas.Width
.Bottom = Canvas.Height
END WITH
Canvas.CopyRect(Destination, Bitmap, Source)
END SUB
SUB OnForm_KeyDown (Key AS BYTE, Shift AS INTEGER)
IF Busy = 1 THEN EXIT SUB
Busy = 1
SELECT CASE Key
CASE 37
Form.CAPTION = "Last Key Hit : LEFT = " & STR$(Key) & " Zoom = " & STR$(Zoom) & Help
bmpLeft = bmpLeft - 25
CASE 38
Form.CAPTION = "Last Key Hit : UP= " & STR$(Key) & " Zoom = " & STR$(Zoom) & Help
bmpTop = bmpTop - 25
CASE 39
Form.CAPTION = "Last Key Hit : RIGHT = " & STR$(Key) & " Zoom = " & STR$(Zoom) & Help
bmpLeft = bmpLeft + 25
CASE 40
Form.CAPTION = "Last Key Hit : DOWN = " & STR$(Key) & " Zoom = " & STR$(Zoom) & Help
bmpTop = bmpTop + 25
CASE 107
Zoom = Zoom / 2
Form.CAPTION = "Last Key Hit : ZOOM + = " & STR$(Key) & " Zoom = " & STR$(Zoom) & Help
CASE 109
Zoom = Zoom * 2
Form.CAPTION = "Last Key Hit : ZOOM - = " & STR$(Key) & " Zoom = " & STR$(Zoom) & Help
CASE ELSE
Busy = 0
EXIT SUB
END SELECT
IF bmpTop < 0 THEN BmpTop = 0
IF bmpLeft < 0 THEN bmpLeft = 0
Paint
Busy = 0
END SUB
|