Here's the same program with adjustments to make it run on the demo version of Purebasic 4.51:
Code: Select all
; First take steps to make the code "Demo Friendly":
Prototype patternbrush(imageid.l)
OpenLibrary(0, "gdi32.dll")
CreatePatternBrush.patternbrush = GetFunction(0, "CreatePatternBrush")
Prototype setclasslong(hwnd.l, index.l, newclassbits.l)
OpenLibrary(1, "user32.dll")
SetClassLong.setclasslong = GetFunction(1, "SetClassLongA")
Prototype timesetevent(uDelay.l, uResolution.l, lpTimeProc.l, dwUser.l, fuEvent.l)
Prototype timeKillEvent(event.l)
OpenLibrary(2, "winmm.dll")
timeSetEvent.timesetevent = GetFunction(2, "timeSetEvent")
timeKillEvent.timekillevent = GetFunction(2, "timeKillEvent")
#GCL_HBRBACKGROUND = -10
#TIME_PERIODIC = $1
; Now for the program:
OpenWindow(0,0,0,640,640,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_Invisible)
LoadFont(0, "courier new", 10, #PB_Font_Bold|#PB_Font_HighQuality)
brush = CreateImage(#PB_Any,20,20)
StartDrawing(ImageOutput(brush))
Box(0,0,20,20,RGB(255,255,255))
Box(0,0,10,10,RGB(220,220,220))
Box(10,10,10,10,RGB(220,220,220))
StopDrawing()
Global cBrush = CreateImage(#PB_Any,640,200)
StartDrawing(ImageOutput(cBrush))
For j=0 To 180 Step 20
For i = 0 To 620 Step 20
DrawImage(ImageID(brush),i,j)
Next
Next
StopDrawing()
hBrush = CreatePatternBrush(ImageID(brush))
SetClassLong(WindowID(0),#GCL_HBRBACKGROUND,hbrush)
HideWindow(0,0)
CreateImage(0, 200, 200, 32|#PB_Image_Transparent)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
DrawingFont(FontID(0))
For j = 0 To 180 Step 20
For i=0 To 180 Step 20
Read.b a.b
DrawText(i,j,Chr(a),RGBA(0,0,0,255),RGBA(0,0,0,0))
Next
Next
StopDrawing()
ImageGadget(0,0,439,640,200,ImageID(0))
Procedure ReDraw(uID, uMsg, dwUser, dw1, dw2)
Static x=0
x+1:If x>=640:x=0:EndIf
If IsGadget(0) And IsImage(cBrush) And IsImage(0)
CreateImage(1, 640,200)
StartDrawing(ImageOutput(1))
DrawImage(ImageID(cbrush),0,0)
DrawAlphaImage(ImageID(0),x,0)
If x>440
GrabImage(0,2,640-x,0,200-(640-x),200)
If IsImage(2) : DrawAlphaImage(ImageID(2),0,0) : EndIf
EndIf
StopDrawing()
SetGadgetState(0, ImageID(1))
EndIf
EndProcedure
tid = timeSetEvent(12,1,@ReDraw(),0,#TIME_PERIODIC|$100)
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
timeKillEvent(tid)
For i=0 To 2
If IsLibrary(i)
CloseLibrary(i)
EndIf
Next
End
DataSection
Data.b 'B', 'Y', 'A', 'L', 'P', 'S', 'I', 'D', 'X', 'P'
Data.b 'U', 'E', 'L', 'Z', 'Z', 'U', 'P', 'E', 'U', 'W'
Data.b 'F', 'R', 'T', 'P', 'R', 'O', 'G', 'R', 'A', 'M'
Data.b 'F', 'A', 'D', 'E', 'L', 'S', 'E', 'U', 'R', 'W'
Data.b 'E', 'L', 'R', 'K', 'L', 'B', 'B', 'D', 'A', 'I'
Data.b 'R', 'C', 'A', 'B', 'A', 'P', 'J', 'E', 'E', 'N'
Data.b 'S', 'E', 'W', 'S', 'Z', 'H', 'M', 'C', 'L', 'D'
Data.b 'U', 'D', 'I', 'G', 'N', 'I', 'D', 'O', 'C', 'O'
Data.b 'D', 'C', 'N', 'T', 'A', 'H', 'C', 'R', 'C', 'W'
Data.b 'A', 'N', 'G', 'E', 'T', 'I', 'R', 'P', 'S', 'O'
EndDataSection