what is the correct way to update the Image of an Image Gadget?
There is no offical way how to update the Image if the Image changed after Color Transformation functions.
After greyscaling the Image of an Image Gadget it is not updated automatically.
Use Gadget State and set the #Image once again do not work.
The way I found is a resize of the Image Gadget. But in my opinion this can't be the right way!
Solved: How to update an Image Gadget correctly
Solved: How to update an Image Gadget correctly
Last edited by SMaag on Sun Nov 23, 2025 10:16 pm, edited 1 time in total.
Re: How to update an Image Gadget correctly
PB-Help (F1)
- SetGadgetState(): Change the current Image of the gadget. A valid ImageID can be easily obtained with the ImageID() function. If the ImageID is 0, then the image is removed from the gadget.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to update an Image Gadget correctly
I tried SetGadgetState(). Does not work.
And if I set first Image=0 and then again the Image I get a white screen.
I have to resize always the ImageGadget to actualize with the modified Image.
PB6.21
I guess I will make a DemoCode to show the Problem.
But what is the offical way to update a modified Image on the Gadget?
And if I set first Image=0 and then again the Image I get a white screen.
I have to resize always the ImageGadget to actualize with the modified Image.
PB6.21
I guess I will make a DemoCode to show the Problem.
But what is the offical way to update a modified Image on the Gadget?
Re: How to update an Image Gadget correctly
Works fine here with macOS, Windows, Linux
Code: Select all
;-TOP
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(0)
dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
; Resize Gadgets
ResizeGadget(1, 10, dy - 35, 120, 25)
ResizeGadget(2, 140, dy - 35, 120, 25)
ResizeGadget(3, 270, dy - 35, 120, 25)
EndProcedure
Procedure Main()
Protected dx, dy
#WinStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 600, 400, "Test Window", #WinStyle)
; MenuBar
CreateMenu(0, WindowID(0))
MenuTitle("&File")
MenuItem(99, "E&xit")
; StatusBar
CreateStatusBar(0, WindowID(0))
AddStatusBarField(#PB_Ignore)
; Images
image1.s = #PB_Compiler_Home + "examples/sources/Data/AlphaChannel.bmp"
LoadImage(1, image1)
image2.s = #PB_Compiler_Home + "examples/sources/Data/PureBasicLogo.bmp"
LoadImage(2, image2)
; Gadgets
dx = WindowWidth(0)
dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
ImageGadget(0, 10, 10, 400, 240, ImageID(2), #PB_Image_Border)
ButtonGadget(1, 10, dy - 35, 120, 25, "Image 1")
ButtonGadget(2, 140, dy - 35, 120, 25, "Image 2")
ButtonGadget(3, 270, dy - 35, 120, 25, "No Image")
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
; Main Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case 0
Break
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 99
PostEvent(#PB_Event_CloseWindow, 0, 0)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 1
SetGadgetState(0, ImageID(1))
Case 2
SetGadgetState(0, ImageID(2))
Case 3
SetGadgetState(0, 0)
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Solved: How to update an Image Gadget correctly
oohh!!
As I saw your code, I realized my fault.
Now it works!
Thank you very much!
I forgot the ImageID() Function at SetGadgetState()
As I saw your code, I realized my fault.
Now it works!
Thank you very much!
I forgot the ImageID() Function at SetGadgetState()
Code: Select all
SetGadgetState(#GG_Image, ImageID(actImgNo))
; SetGadgetState(#GG_Image, actImgNo) ; That was the fault
Re: Solved: How to update an Image Gadget correctly
And again ...
many people who wants to help invest time and energy only because there is no working or not working example which shows the problem.
With your missing example code the problem where solved in 5 minutes.
You need 10 minutes to write such a code.
10 'helpers' needs 10 x 10 minutes to write examples. 9 x 10 minutes where wasted.
many people who wants to help invest time and energy only because there is no working or not working example which shows the problem.
With your missing example code the problem where solved in 5 minutes.
You need 10 minutes to write such a code.
10 'helpers' needs 10 x 10 minutes to write examples. 9 x 10 minutes where wasted.
Re: Solved: How to update an Image Gadget correctly
I know that! But I did not ask for a working code!And again ...
many people who wants to help invest time and energy only because there is no working or not working example which shows the problem.
With your missing example code the problem where solved in 5 minutes.
You need 10 minutes to write such a code.
10 'helpers' needs 10 x 10 minutes to write examples. 9 x 10 minutes where wasted.
I did not ask for solving my problem - I just described it!
I just asked what is the standard way to update an ImageGadget because in the documentation there is no comment for that issue.
So if anyone knows. The simple response is: SetGadgetState() is the standard command to update an image!
Furthermore in my first response I wrote: "I will make an example which shows my problem!"
And once again. Thanks for the help!
Re: Solved: How to update an Image Gadget correctly
Yes there is. mk-soft linked to it above.SMaag wrote: Mon Nov 24, 2025 9:41 amI just asked what is the standard way to update an ImageGadget because in the documentation there is no comment for that issue.


