Sillvers Posted February 1, 2016 Report Posted February 1, 2016 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?
Joel Bodenmann Posted February 1, 2016 Report Posted February 1, 2016 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
inmarket Posted February 1, 2016 Report Posted February 1, 2016 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 ()
Sillvers Posted February 1, 2016 Author Report Posted February 1, 2016 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 I found problem - in my case I need to change the image of the progressbar from time to time andkeep 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 gwinProgressbarSetPositionare using this variable.Thanks for motivation to work
Joel Bodenmann Posted February 1, 2016 Report Posted February 1, 2016 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now