I tried a code posted here by TI-994A, several years ago, to set window background, it's not wotking. i modified it slightly:
Code: Select all
Procedure SetBackgroundImage(containerNo, imageNo)
If IsWindow(containerNo)
hWnd = WindowID(containerNo)
imgWidth = WindowWidth(containerNo)
imgHeight = WindowHeight(containerNo)
result = #True
ElseIf IsGadget(containerNo)
hWnd = GadgetID(containerNo)
imgWidth = GadgetWidth(containerNo)
imgHeight = GadgetHeight(containerNo)
result = #True
Else
result = #False
EndIf
If result
ResizeImage(imageNo, imgWidth, imgHeight)
image = CreatePatternBrush_(ImageID(imageNo))
If image
SetClassLongPtr_(hWnd, #GCL_HBRBACKGROUND, image)
RedrawWindow_(hWnd, #Null, #Null, #RDW_INVALIDATE)
result = #True
Else
result = #False
EndIf
EndIf
ProcedureReturn result
EndProcedure
LoadImage(0, "C:\Program Files (x86)\PureBasic\Examples\Sources\Data\purebasic.bmp")
OpenWindow(0, 100, 100, 300, 300, "SetBackgroundImage")
SetBackgroundImage(0, 0)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend