Page 1 of 1

How to speed up GUI redraw?

Posted: Thu Nov 25, 2004 6:56 pm
by BBSnowman
Hi everybody...

my issue is the speed the GUI draws some text on the screen.

I wrote a tiny progress dialog with a simple gauge and some text on it. The frame is derived from wxDialog and is brought to screen via Show() in the ctor. Perfect so far. But when I create the dialog the gauge runs fine but the text is not drawn at all. To avoid this, I added a wxSleep(1) at the end of the ctor and that works. But that couldn't be the right way, could it?

Is there a function like wxWaitRedraw() or something like that? Waiting a second for the GUI to draw some text hurts!

Thanks for your hints
Chris

[wxWindows 2.4.2/vc7 2003/WinXP]

Re: How to speed up GUI redraw?

Posted: Sun Nov 28, 2004 2:53 am
by Ryan Norton
BBSnowman wrote:Hi everybody...

my issue is the speed the GUI draws some text on the screen.

I wrote a tiny progress dialog with a simple gauge and some text on it. The frame is derived from wxDialog and is brought to screen via Show() in the ctor. Perfect so far. But when I create the dialog the gauge runs fine but the text is not drawn at all. To avoid this, I added a wxSleep(1) at the end of the ctor and that works. But that couldn't be the right way, could it?

Is there a function like wxWaitRedraw() or something like that? Waiting a second for the GUI to draw some text hurts!

Thanks for your hints
Chris

[wxWindows 2.4.2/vc7 2003/WinXP]
Are you overloading the paint event or are you using a wxClientDC to draw on the window?

If doing the former, are you double-buffering it?

Posted: Tue Nov 30, 2004 1:43 am
by BBSnowman
None of both. I don't handle a paint event. I'm only creating the text in the constructor.

What do you mean by double-buffering?

Posted: Sat Dec 04, 2004 3:31 pm
by Jasper
How do you handle drawing the guage vs. the text? If the text doesn't draw at all and a sleep solves the problem it sounds to me like your progress bar update function is blocking the main event loop (although I still wouldn't now why it wouldn't draw at all, but I don't know exactly what you're doing, so it's rather difficult to tell), so you may want to try updating the progress bar on idle events (one step at a time, don't block it!) or something like that (Yield might work too).

Posted: Sat Dec 04, 2004 3:32 pm
by Jasper
BTW, double-buffering is a scheme in which you draw on a memory dc and then display that when you've finished drawing, instead of drawing directly to the screen.