Jump to content

Progressbar image problem.


Sillvers

Recommended Posts

Hi again,

I'm trying to change the image that fills progressbar, but I have met small inconvenience.

Start configuration of progressbar:


wi.g.show = TRUE;
wi.g.x = 340;
wi.g.y = 40;
wi.g.width = 120;
wi.g.height = 190;
wi.g.parent = ghContainerPage0;
wi.text = "";
wi.customDraw = gwinProgressbarDraw_Image;
wi.customParam = &slider_1_greyimg;
wi.customStyle = &BlackWidgetStyle;
ghProgressbar1 = gwinProgressbarCreate(0, &wi);
gwinProgressbarSetRange(ghProgressbar1, 0, 190);
gwinProgressbarSetPosition(ghProgressbar1, 90);

During system working I change image with function - gwinProgressbarDraw_Image(ghProgressbar1, (void*)&slider_1_greyimg).

I see that image was changed, but when the position of the progressbar is changing, progressbar is fill with previous image.

What's missing in my code?

Link to comment
Share on other sites

Hello Sillvers!

Is it possible for you to provide us with a minimum working example (main.c, gfxconf.h, the actual original image and the converted image) so we can easily try this ourselves? That would save us a heap of time setting up a new project :)

Note that you can easily upload a .ZIP archive to your post.

~ Tectu

Link to comment
Share on other sites

Rather than calling that routine directly you need to register it as the draw routine for that progress bar. The system will then use that routine to draw it for you whenever anything changes.

You register the draw routine you want and the new image parameter using gwinSetCustomDraw ()

Link to comment
Share on other sites

Hi again Tectu,

nice to meet you again :)

So, I assumed that it would be quicker to find problem than prepare my code for you :D

I found problem - in my case I need to change the image of the progressbar from time to time and

keep this image till some event occured.

When I call gwinProgressbarDraw_Image() function image is change but in structure GWidgetObject

I have still fnParam variable filled with old image - and that is the point, because gwinProgressbarSetPosition

are using this variable.

Thanks for motivation to work :)

Link to comment
Share on other sites

Hello Sillvers, pleased to meet you again too :)

That sounds like you're assigning the new image the wrong way. What you need to do is calling gwinSetCustomDraw() with the new image as the custom parameter. Like this:


gwinSetCustomDraw(ghProgressbar1, gwinProgressbarDraw_Image, (void*)&newGdispImage);

That will automatically update everything that needs to be updated and issue a redraw.

Note that you might want to close the previous image to free some resources (depending on your needs).

As inmarket mentioned you NEVER EVER have to manually call a rendering routine. The GWIN module takes care of redrawing when something needs to be redrawn. If you need to issue a redraw manually, use gwinRedraw() instead. That will use the currently assigned rendering routine to redraw the widget.

~ Tectu

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