Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_Graphic = 500
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Virutal Graphic Drag Test",300,600,500,500, %WS_OverlappedWindow To hDlg
Control Add Graphic, hDlg, %IDC_Graphic,"", 0,0,500,500, %WS_Visible Or %WS_Border
Graphic Attach hDlg, %IDC_Graphic
Graphic Set Virtual 1500,1500 'large virtual canvas
Graphic Set View 500,500 'display center part of canvas
Graphic Render Bitmap "chess.bmp", (600,600)-(899,899) 'draw bitmap into the exposed canvas area
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local ViewX, ViewY As Long
Static ddx,ddy As Long
Select Case Cb.Msg
Case %WM_MouseMove
If Cb.WParam And %MK_LBUTTON Then
ViewX = Max(0,Graphic(View.X) + ddx - Lo(Word,Cb.LParam))
ViewY = Max(0,Graphic(View.Y) + ddy - Hi(Word,Cb.LParam))
ViewX = Min(ViewX, Graphic(Canvas.X))
ViewY = Min(ViewY, Graphic(Canvas.Y))
Graphic Set View ViewX, ViewY
ddx = Lo(Word, Cb.LParam)
ddy = Hi(Word, Cb.LParam)
End If
Case %WM_LButtonDown
ddx = Lo(Word, Cb.LParam)
ddy = Hi(Word, Cb.LParam)
Case %WM_LButtonUp
End Select
End Function
'gbs_01389
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm