Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Label flickering

Label flickering

Scheduled Pinned Locked Moved Managed C++/CLI
questiongraphics
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cherrymotion
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • C cherrymotion

      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

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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.


      C 1 Reply Last reply
      0
      • L Luc Pattyn

        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.


        C Offline
        C Offline
        cherrymotion
        wrote on last edited by
        #3

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

        L 1 Reply Last reply
        0
        • C cherrymotion

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

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          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.


          C 1 Reply Last reply
          0
          • L Luc Pattyn

            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.


            C Offline
            C Offline
            cherrymotion
            wrote on last edited by
            #5

            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?

            L 1 Reply Last reply
            0
            • C cherrymotion

              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?

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              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.


              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups