Tile a window

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Steve.


Hello all.
Here's some code to tile a window.


;Program Tile1.pb
;By Steve
;Public Domain
;Tested with win95 and pb 2.82 reg.

;Tiles the window client area with a 70 x 70 bitmap file
;The bmap size is hard coded at the moment, this should be changed to working
;it out at run time. Also there's not a lot of error checking. If this program was
;bigger, Id put it in.(Lazy :-})
;Any problems with it let me know.
;Have a great day!
;Steve.

#WinParam = #PB_Window_SystemMenu|#PB_Window_MinimizeGadget
quit.l = 0
Global Client_Wd.l
Global Client_Ht.l
Global Whwnd.l
Global Ihwnd.l
Global BM_W.l
Global BM_H.l
Global *Cdc.l
Global *BMdc.l

Procedure SetUp()
a$ = "c:\pics\tile2.bmp"
myrect.RECT

Ihwnd = LoadImage_ (0, a$, #IMAGE_BITMAP, 0, 0, #LR_LOADFROMFILE)
If Ihwnd 0
GetClientRect_(Whwnd, @myrect)
Client_Wd = myrect\right
Client_Ht = myrect\bottom
*Cdc = GetDC_(Whwnd)
*BMdc = CreateCompatibleDC_(*Cdc)
SelectObject_(*BMdc, Ihwnd)
ReleaseDC_(Whwnd, *Cdc)
EndIf
EndProcedure

Procedure PaintIt()
y.l = 0: x.l = 0
BM_W = 70: BM_H = 70

*Cdc = GetDC_(Whwnd)
While y 0
SetUp()
While quit = 0
msg = WaitWindowEvent()
if msg = #PB_EventCloseWindow
quit = 1
endif
if msg = #PB_EventRepaint
PaintIt()
EndIf
Wend

;clean up and exit
DeleteObject_(Ihwnd)
DeleteDc_(BMdc)
FreeImage(0)
EndIf
End
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

works perfectly.
thx

Siggi
Post Reply