Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
#Resource Bitmap tile "tile.bmp"
%IDC_Graphic = 500
%ID_Timer = 501
Global hDlg,hBMP As Dword, imgW, imgH, wc, hc As Long
Function PBMain() As Long
Dialog New Pixels, 0, "Continuous Tile Scrolling",300,300,300,150, %WS_OverlappedWindow To hDlg
Control Add Graphic, hDlg, %IDC_Graphic,"",0,0,300,300
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
'load the *.bmp image to a memory bitmap
Graphic Bitmap Load "tile", 0,0 To hBMP
Graphic Attach hBMP, 0
Graphic Get Canvas To imgW,imgH
Graphic Attach hDlg, %IDC_Graphic
Graphic Get Canvas To wc, hc
SetTimer hDlg, %ID_Timer, 50, 0
Case %WM_Destroy
KillTimer hDlg, %ID_Timer
Case %WM_Timer
MoveImageLeftToRight
End Select
End Function
Sub MoveImageLeftToRight
Static x As Long 'starting point in image
Graphic Clear
x = x Mod imgW
If (x+wc-1) < imgW Then
Graphic Copy hBMP, 0, (x,0)-(x+wc-1,hc-1) To (0,0)
ElseIf (x+wc) > imgW Then
Graphic Copy hBMP, 0, (x,0)-(imgW,hc-1) To (0,0)
Graphic Copy hBMP, 0, (0,0)-(x+wc-imgW,hc-1) To (imgW-x,0)
End If
Incr x
End Sub
'gbs_01425
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm