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. C / C++ / MFC
  4. How to avoid flickering in CListCtrl

How to avoid flickering in CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
helpperformancetutorialquestion
7 Posts 3 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.
  • S Offline
    S Offline
    shir_k
    wrote on last edited by
    #1

    Hi, I have list control whose property is set to "List1",IDC_CmdResp,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,293,37,146,214, WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out. void CNgpptDialog::ReadSerialData(CString sIn) { CString pressure_data; ptrCmdResp->SetRedraw(false); pressure_data=sIn; int counter = ptrCmdResp->GetItemCount(); ptrCmdResp->InsertItem(counter, "");// to insert a row ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0 ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords. if(counter > 150)// I start deleting first data when the number of items in the list control is > 150 { ptrCmdResp->DeleteItem(0); } ptrCmdResp->SetRedraw(true); int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex); } } Thanks in advance

    N D 2 Replies Last reply
    0
    • S shir_k

      Hi, I have list control whose property is set to "List1",IDC_CmdResp,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,293,37,146,214, WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out. void CNgpptDialog::ReadSerialData(CString sIn) { CString pressure_data; ptrCmdResp->SetRedraw(false); pressure_data=sIn; int counter = ptrCmdResp->GetItemCount(); ptrCmdResp->InsertItem(counter, "");// to insert a row ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0 ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords. if(counter > 150)// I start deleting first data when the number of items in the list control is > 150 { ptrCmdResp->DeleteItem(0); } ptrCmdResp->SetRedraw(true); int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex); } } Thanks in advance

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      With one post is enough... at least you could change your text and explain yourself in another way. Maybe is not clear what you mind (i.e. I don't know the word flickering)

      Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

      S 1 Reply Last reply
      0
      • S shir_k

        Hi, I have list control whose property is set to "List1",IDC_CmdResp,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,293,37,146,214, WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out. void CNgpptDialog::ReadSerialData(CString sIn) { CString pressure_data; ptrCmdResp->SetRedraw(false); pressure_data=sIn; int counter = ptrCmdResp->GetItemCount(); ptrCmdResp->InsertItem(counter, "");// to insert a row ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0 ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords. if(counter > 150)// I start deleting first data when the number of items in the list control is > 150 { ptrCmdResp->DeleteItem(0); } ptrCmdResp->SetRedraw(true); int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex); } } Thanks in advance

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        shir_k wrote:

        int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex);

        Comment out these two statements and see what happens.


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        S 1 Reply Last reply
        0
        • D David Crow

          shir_k wrote:

          int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex);

          Comment out these two statements and see what happens.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          S Offline
          S Offline
          shir_k
          wrote on last edited by
          #4

          There is no difference Thanks

          D 1 Reply Last reply
          0
          • N Nelek

            With one post is enough... at least you could change your text and explain yourself in another way. Maybe is not clear what you mind (i.e. I don't know the word flickering)

            Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

            S Offline
            S Offline
            shir_k
            wrote on last edited by
            #5

            K Got it. The actual issue is When i place the data in List Ctrl the data is unsteady.As am placing data continuously(120 samples/ sec)and i have run the s/w for many days continuously, i need to delete the data in List Ctrl otherwise buffer of the List Ctrl will overflow.After displaying 150 samples in Ctrllist am starting to delete at this moment data is unsteady. Thanks

            N 1 Reply Last reply
            0
            • S shir_k

              K Got it. The actual issue is When i place the data in List Ctrl the data is unsteady.As am placing data continuously(120 samples/ sec)and i have run the s/w for many days continuously, i need to delete the data in List Ctrl otherwise buffer of the List Ctrl will overflow.After displaying 150 samples in Ctrllist am starting to delete at this moment data is unsteady. Thanks

              N Offline
              N Offline
              Nelek
              wrote on last edited by
              #6

              Well, I reset tmy ListCttrlView everytime the OnDraw is called to empty all datas and then I write the newest values.

              void CMyTabView::OnDraw(CDC* pDC)
              { if (m_bJustOpened)
              InitializeView ();
              if (m_bListRedraw)
              DrawViewElements ();
              return;
              }

              In initialize views I configure the number of columns (may be variable from 8 up to 32). Write the name of columns and so on... By DrawViewElements (); my FIRST line is: m_clcRuleList.DeleteAllItems (); and then I write them down another time. And with that you can call the OnDraw easily with an pDoc->UpdateAllViews (NULL); in a Timer with the interval you desire

              Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

              1 Reply Last reply
              0
              • S shir_k

                There is no difference Thanks

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                So if all you are ever going to show is 150 items, why not store those in a fast container of some sort, and populate the list control from that container instead. Doing I/O on such a container would be way faster than the same I/O on a UI control. Make sense?


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                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