Code: Select all
DisableGadget(#gadget, 1)
DisableGadget(#gadget, 0)
Code: Select all
Enumeration
#window
#image_one
#image_two
#button_one
#button_two
EndEnumeration
Macro RefreshGadget(gadget)
DisableGadget(gadget, 1)
DisableGadget(gadget, 0)
EndMacro
If OpenWindow(#window, #PB_Any, #PB_Any, 140, 270, "PB Window", #PB_Window_ScreenCentered | #PB_Window_Invisible | #PB_Window_SystemMenu)
If CreateImage(#image_one, 120, 120)
If StartDrawing(ImageOutput(#image_one))
Box(0, 0, 119, 119, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
ButtonImageGadget(#button_one, 10, 10, 120, 120, ImageID(#image_one))
ButtonGadget(#button_two, 10, 140, 120, 120, "Change")
EndIf
HideWindow(#window, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case #button_two
If StartDrawing(ImageOutput(#image_one))
Box(0, 0, 119, 119, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
RefreshGadget(#button_one) ;New feature request here. Comment/uncomment this line
EndSelect
EndSelect
ForEver
EndIf