Ein ButtonImageGadget (Toogle) soll bei Betätigung das Image wechseln.
Da mache ich was falsch, weiß aber nicht weiter woran es liegt.
Grundgerüst ist mit IceDesigner erstellt. Bilder werden richtig geladen, wenn ich sie in der Declaration mal tausche.
Schonmal DANKE für Antworten
Code: Alles auswählen
; -----------------------------------------------------------------------------
; Name:
; Description:
; Author:
; Date: 2022-12-05
; Version:
; PB-Version:
; OS:
; Credit:
; Forum:
; Created by: IceDesign
; -----------------------------------------------------------------------------
EnableExplicit
;- Enumerations
Enumeration Window
#Window_0
EndEnumeration
Enumeration Gadgets
#Img_Backgound
#LeuchteEsszimmer
EndEnumeration
Enumeration Image
#Imag_0
#Imag_1
#Imag_2
EndEnumeration
;- Load Images
UsePNGImageDecoder()
UseJPEGImageDecoder()
CatchImage(#Imag_0, ?Imag_0)
CatchImage(#Imag_1, ?Imag_1)
CatchImage(#Imag_2, ?Imag_2)
Global AppQuit
;- Declare
Declare Resize_Window_0()
Declare Open_Window_0(X = 0, Y = 0, Width = 600, Height = 600)
Procedure Resize_Window_0()
Protected ImageBackground
ImageBackground = CopyImage(#Imag_1, #PB_Any)
If ImageBackground
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
SendMessage_(WindowID(#Window_0), #WM_SETREDRAW, #False, 0)
CompilerEndIf
ResizeImage(ImageBackground, DesktopScaledX(WindowWidth(#Window_0)), DesktopScaledY(WindowHeight(#Window_0)))
SetGadgetState(#Img_Backgound, ImageID(ImageBackground))
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
SendMessage_(WindowID(#Window_0), #WM_SETREDRAW, #True, 0)
RedrawWindow_(WindowID(#Window_0), #Null, #Null, #RDW_INVALIDATE | #RDW_ERASE | #RDW_ALLCHILDREN | #RDW_UPDATENOW)
CompilerEndIf
EndIf
EndProcedure
Procedure Open_Window_0(X = 0, Y = 0, Width = 600, Height = 600)
If OpenWindow(#Window_0, X, Y, Width, Height, "Erdgeschoss", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_NoActivate)
; Uncomment to Add Transparency to the Window (Windows Only)
;SetWindowLongPtr_(WindowID(#Window_0), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(#Window_0), #GWL_EXSTYLE) | #WS_EX_LAYERED) : SetLayeredWindowAttributes_(WindowID(#Window_0), 0, 192, #LWA_ALPHA) ; Tranparency=192
ImageGadget(#Img_Backgound, 0, 0, 800, 600, ImageID(#Imag_1))
DisableGadget(#Img_Backgound, #True)
ButtonImageGadget(#LeuchteEsszimmer, 190, 400, 32, 32, ImageID(#Imag_2), #PB_Button_Toggle)
BindEvent(#PB_Event_SizeWindow, @Resize_Window_0(), #Window_0)
PostEvent(#PB_Event_SizeWindow, #Window_0, 0)
EndIf
EndProcedure
;- Main Program
Open_Window_0()
;- Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
AppQuit = #True
;-> Event Gadget
Case #PB_Event_Gadget
Select EventGadget()
Case #LeuchteEsszimmer
SetGadgetState(#LeuchteEsszimmer, ImageID(#Imag_0)) ; WARUM ändert das Image nicht ????
MessageRequester("Information", "Button Image Name : #LeuchteEsszimmer")
EndSelect
EndSelect
Until AppQuit
;- DataSection
DataSection
Imag_0: : IncludeBinary "Seewarte\Bulb_32.png"
Imag_2: : IncludeBinary "Seewarte\Bulb_Off_32.png"
Imag_1: : IncludeBinary "C:\fp\Haus\MyHomemyCastle3_800_600.jpg"
EndDataSection