Jump to content

Image Button - changing image


wctltya

Recommended Posts

How can I change(replace) the image(run time) of an Image Button widget? Its not about the button states enabled/pressed/disabled, but the complete image. Assuming the new image is already opened in gdispImage imageNew for example.

And the same question for Image Box widget? Whether just opening the new image gwinImageOpenFile(ghImageBox, "newImage.gif") is enough?

Link to comment
Share on other sites

Assuming that you're using the built-in image button rendering function of the button widget you just pass a different gdispImage* pointer via the custom parameter to the rendering function. The button widget doesn't store the pointer to your image at all, it just takes the custom parameter of the rendering function and casts it to (gdispImage*) that's all. Therefore, changing the image works like this:

gwinSetCustomDraw(ghMyButton, gwinButtonDraw_Image, &myNewImage);

 

With the images of the list box widget it's a different story because the image is actually being stored as part of the list item object. Changing the image is simply a matter of using the corresponding high-level API that has been added exactly for this:

gwinListItemSetImage(ghMyImage, 0, &myNewListItemImage);

 

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...