Label flickering
-
Hi again, I tried many things now, but nothing worked. The question isn't really difficult. I have a Status_line label which is actualised circa 20 times a seconde. In that label is always the actual running number written. But I do not get rid of that horrible flickering! I tried already to doublebuffer, but it seems to work only on Graphics. The writing function has to take the textcolor, backcolor and string as parameter, so I cannot statically DrawString on the label graphics. Isn't there a way to prevent that flickering? Thanks! cherry
-
Hi again, I tried many things now, but nothing worked. The question isn't really difficult. I have a Status_line label which is actualised circa 20 times a seconde. In that label is always the actual running number written. But I do not get rid of that horrible flickering! I tried already to doublebuffer, but it seems to work only on Graphics. The writing function has to take the textcolor, backcolor and string as parameter, so I cannot statically DrawString on the label graphics. Isn't there a way to prevent that flickering? Thanks! cherry
Hi, 1. AFAIK all Controls can be double-buffered, and that is the best way to improve the situation 2. some improvement can be achieved by NOT updating the control when all the parameters remain the same, i.e. compare the current ForeColor, BackColor and Text, with the new ones, and only update when there is a difference. :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
Hi, 1. AFAIK all Controls can be double-buffered, and that is the best way to improve the situation 2. some improvement can be achieved by NOT updating the control when all the parameters remain the same, i.e. compare the current ForeColor, BackColor and Text, with the new ones, and only update when there is a difference. :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
No, not all controls can be double buffered. As I tried to enable double buffering on that label, compiling error C3767 "Candidate Function Not Accessible" appears. I just can assign doublebuffering to the whole control (it's a control library project), but that has sadly no effect on the flickering. I also have tried your second hint, the comparison has also no effect and the fact is, that I have to update, because in every loop there's number incremented, which I want to display. So at least the text of the label MUST be changed. Nevertheless, thank you! Maybe you come up with a further issue.. ;)
-
No, not all controls can be double buffered. As I tried to enable double buffering on that label, compiling error C3767 "Candidate Function Not Accessible" appears. I just can assign doublebuffering to the whole control (it's a control library project), but that has sadly no effect on the flickering. I also have tried your second hint, the comparison has also no effect and the fact is, that I have to update, because in every loop there's number incremented, which I want to display. So at least the text of the label MUST be changed. Nevertheless, thank you! Maybe you come up with a further issue.. ;)
cherrymotion wrote:
No, not all controls can be double buffered
I haven't encountered a situation yet where I was in need to double-buffer something that did not offer to do so.
cherrymotion wrote:
Maybe you come up with a further issue
If the only purpose is to show some progress is (or isn't) being made, I often reverse the initiative: adding a Windows.Forms.Timer that periodically (say every 333msec) checks the situation and reports progress, independent of the work that is going on. BTW: that timer ticks on the GUI thread, so its handler can update any Control. PS: for it to work at all, the work itself needs to be handled by another thread (maybe in a BackgroundWorker) :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
cherrymotion wrote:
No, not all controls can be double buffered
I haven't encountered a situation yet where I was in need to double-buffer something that did not offer to do so.
cherrymotion wrote:
Maybe you come up with a further issue
If the only purpose is to show some progress is (or isn't) being made, I often reverse the initiative: adding a Windows.Forms.Timer that periodically (say every 333msec) checks the situation and reports progress, independent of the work that is going on. BTW: that timer ticks on the GUI thread, so its handler can update any Control. PS: for it to work at all, the work itself needs to be handled by another thread (maybe in a BackgroundWorker) :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
Hi, I started the backgroundworker doing his work, and from the DoWork-Event, I called timer->start(); but somehow the timer starts never. In the timer_Tick event I always update my label, I got you right?! But as I said, the Tick() event is never reached, altough I started the timer. Do I have to do something else with the backgroundworker? An own thread?
-
Hi, I started the backgroundworker doing his work, and from the DoWork-Event, I called timer->start(); but somehow the timer starts never. In the timer_Tick event I always update my label, I got you right?! But as I said, the Tick() event is never reached, altough I started the timer. Do I have to do something else with the backgroundworker? An own thread?
A Forms.Timer is like a Control, you should only touch it from the main thread, hence outside your worker threads. It needs an Interval value, a Tick handler, and a Start(). It is best to make the timer object a class member of your Form (or other Control). :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.