Code: Alles auswählen
EnableExplicit
InitNetwork()
UseJPEGImageDecoder()
Procedure SetWindowBackgroundImage(hWnd.i, hImage.i)
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
Protected Child.I
Protected ChildrenList.I
Protected *Name
Protected Widget.I = gtk_bin_get_child_(hWnd)
Repeat
ChildrenList = gtk_container_get_children_(Widget)
Child = g_list_nth_data_(ChildrenList, 0)
If Child = 0
Break
Else
*Name = gtk_widget_get_name_(Child)
Widget = Child
EndIf
Until PeekS(*Name, -1, #PB_UTF8) = "GtkFixed"
If Child
gtk_fixed_put_(Child, gtk_image_new_from_pixbuf_(hImage), 0, 0)
gtk_widget_show_all_(hWnd)
EndIf
CompilerCase #PB_OS_Windows
Protected hBrush = CreatePatternBrush_(hImage)
If hBrush
SetClassLongPtr_(hWnd, #GCL_HBRBACKGROUND, hBrush)
InvalidateRect_(hWnd, 0, #True)
UpdateWindow_(hWnd)
EndIf
CompilerCase #PB_OS_MacOS
CocoaMessage(0, hWnd, "setBackgroundColor:",
CocoaMessage(0, 0, "NSColor colorWithPatternImage:", hImage))
CompilerEndSelect
EndProcedure
If ReceiveHTTPFile("http://realsource.de/images/stargate_atlantis.jpg", GetTemporaryDirectory() + "stargate_atlantis.jpg")
LoadImage(0, GetTemporaryDirectory() + "stargate_atlantis.jpg")
OpenWindow(0, 100, 100, 800, 450, "Window with background image")
SetWindowBackgroundImage(WindowID(0), ImageID(0))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf