Jump to content

Image Button - how to change image on fly?


king2

Recommended Posts

Assuming that you are using the existing image rendering routine for the button widget you just have to change the image that's being passed through the custom parameter. You do that by calling gwinSetCustomDraw() again and just using a different parameter.

Note that as you only change a pointer the GWIN module doesn't know that it has to redraw the button widget. Therefore you have to issue a redraw manually using gwinRedraw() after you modified the image pointer.

Keep in mind that the image passed to the rendering function must be opened already. You might also want to close the previous image - depending on your needs.

Important note: When you just want to show a different image for when the button is released and when the button is pressed to make a visual "Click" effect then that has already been done for you! The existing image rendering function for the button widget can take an image that's either one, two or three times the height of the actual button. This way you can stack the image for the 'released', the 'pressed', (and optionally the 'disabled') state on top of each other and use that as one image. The button widget will automatically render the correct one depending on its current state.

You can find more information about this in the API documentation and by using the forum search.

This is also already supported by the uGFX-Studio. If you select the image rendering function on a button then you can not only submit the image path but also specify how many images you have (1, 2 or 3).

~ Tectu

Link to comment
Share on other sites

No, I want to change status of button, for example, user presses button 'recording', then recording starts (or not). If everything is ok and recording was started, I want to change button image with recording symbol to red.

Thank you very much!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...