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 make ListView's scroll absolutely without flickering - example included

How to make ListView's scroll absolutely without flickering - example included

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
14 Posts 5 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 s_k

    Hi all, I am trying to make my ListView (displaying files) scroll without any flickering. But I cannot get it work. I tried for example putting GetListCtrl().SetRedraw(FALSE) and GetListCtrl().SetRedraw(TRUE) around CListView::OnKeyDown() call if key pressed was PAGE DOWN or PAGE UP, but it made things even worse. For example this program does absolutely no flickers! http://www.altap.cz/ftp/salamand/salen200.exe Try scrolling eg. WINNT\System32 directory of any other directory with thousand of files with Page Down key held and you will see that. How is this possible??? I am using virtual ListView. Thank you for any suggestion!

    C Offline
    C Offline
    ColinDavies
    wrote on last edited by
    #2

    Maybe you should do a search here at CP for articles by "Keith Rule" and see his CMemDC class. Regardz Colin J Davies

    *** WARNING *
    This could be addictive
    **The minion's version of "Catch :bob: "

    It's a real shame that people as stupid as you can work out how to use a computer. said by Christian Graus in the Soapbox

    S 1 Reply Last reply
    0
    • C ColinDavies

      Maybe you should do a search here at CP for articles by "Keith Rule" and see his CMemDC class. Regardz Colin J Davies

      *** WARNING *
      This could be addictive
      **The minion's version of "Catch :bob: "

      It's a real shame that people as stupid as you can work out how to use a computer. said by Christian Graus in the Soapbox

      S Offline
      S Offline
      s_k
      wrote on last edited by
      #3

      Thanks for your suggestion Colin. Unfortunately, CMemDC doesn't work for my CListView-derived class. CMyView::OnDraw() is never executed and returning FALSE in OnEraseBackground() casues my ListView not being updated and look ugly...Don't you know why? Best regards, Standa.

      R 1 Reply Last reply
      0
      • S s_k

        Thanks for your suggestion Colin. Unfortunately, CMemDC doesn't work for my CListView-derived class. CMyView::OnDraw() is never executed and returning FALSE in OnEraseBackground() casues my ListView not being updated and look ugly...Don't you know why? Best regards, Standa.

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #4

        s_k wrote: CMyView::OnDraw() is never executed That's correct behaviour. View derived from CCtrlView never have their OnDraw() method called. You'll have to use OnPaint() instead.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        S 1 Reply Last reply
        0
        • R Ryan Binns

          s_k wrote: CMyView::OnDraw() is never executed That's correct behaviour. View derived from CCtrlView never have their OnDraw() method called. You'll have to use OnPaint() instead.

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

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

          But how can I then use CMemDC class, when it needs CDC pointer to be passed to constructor?

          R 1 Reply Last reply
          0
          • S s_k

            But how can I then use CMemDC class, when it needs CDC pointer to be passed to constructor?

            R Offline
            R Offline
            Ryan Binns
            wrote on last edited by
            #6

            void CMyList::OnPaint()
            {
            CPaintDC dc(this);
            CMemDC memDC(&dc);
            // ...
            }

            Ryan

            "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

            S 1 Reply Last reply
            0
            • R Ryan Binns

              void CMyList::OnPaint()
              {
              CPaintDC dc(this);
              CMemDC memDC(&dc);
              // ...
              }

              Ryan

              "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

              S Offline
              S Offline
              s_k
              wrote on last edited by
              #7

              Thank you Ryan, it works. But, in fact, I don't know what to wirte into OnPaint() handler routine. I have just CListView that displays list of files on local drives and the only thing I wanted to achieve is to get rid of flickering while scrolling the content of ListView....

              R 1 Reply Last reply
              0
              • S s_k

                Thank you Ryan, it works. But, in fact, I don't know what to wirte into OnPaint() handler routine. I have just CListView that displays list of files on local drives and the only thing I wanted to achieve is to get rid of flickering while scrolling the content of ListView....

                R Offline
                R Offline
                Ryan Binns
                wrote on last edited by
                #8

                void CMyList::OnPaint()
                {
                CPaintDC dc(this);
                CMemDC memDC(&dc);
                DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);
                }

                Hope this helps,

                Ryan

                "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                S 1 Reply Last reply
                0
                • R Ryan Binns

                  void CMyList::OnPaint()
                  {
                  CPaintDC dc(this);
                  CMemDC memDC(&dc);
                  DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);
                  }

                  Hope this helps,

                  Ryan

                  "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                  S Offline
                  S Offline
                  s_k
                  wrote on last edited by
                  #9

                  Thanks Ryan! Now list of files is drawn, but for example column headers are not visible till I click on them. I'm using Custom Draw feature, maybe it has something to do with it...

                  R A 2 Replies Last reply
                  0
                  • S s_k

                    Thanks Ryan! Now list of files is drawn, but for example column headers are not visible till I click on them. I'm using Custom Draw feature, maybe it has something to do with it...

                    R Offline
                    R Offline
                    Ryan Binns
                    wrote on last edited by
                    #10

                    s_k wrote: I'm using Custom Draw feature, maybe it has something to do with it... Possibly, but I'd still expect it to work. I haven't done this with custom draw, so I don't really know. Try removing the custom draw, and then trying again. If it paints, then that's good, and you might just have to do without the custom draw. You might need to do full owner draw instead. If not, I'm sorry I can't help much more.

                    Ryan

                    "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                    1 Reply Last reply
                    0
                    • S s_k

                      Hi all, I am trying to make my ListView (displaying files) scroll without any flickering. But I cannot get it work. I tried for example putting GetListCtrl().SetRedraw(FALSE) and GetListCtrl().SetRedraw(TRUE) around CListView::OnKeyDown() call if key pressed was PAGE DOWN or PAGE UP, but it made things even worse. For example this program does absolutely no flickers! http://www.altap.cz/ftp/salamand/salen200.exe Try scrolling eg. WINNT\System32 directory of any other directory with thousand of files with Page Down key held and you will see that. How is this possible??? I am using virtual ListView. Thank you for any suggestion!

                      P Offline
                      P Offline
                      PJ Arends
                      wrote on last edited by
                      #11

                      Does CListCtrl::Scroll() not work?


                      [

                      ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

                      S 1 Reply Last reply
                      0
                      • P PJ Arends

                        Does CListCtrl::Scroll() not work?


                        [

                        ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

                        S Offline
                        S Offline
                        s_k
                        wrote on last edited by
                        #12

                        Hi, maybe I post my question in a wrong way - I AM able to scroll the content of my ListView, I have vertical scrollbar there and pressing Key Down/Up keys also scroll the ListView. But in case when I have for example 10.000 files in ListView and I'm holding Page Key/Up or moving fastly with scroll bar, ListView "flashes", or how to say that...So I'm looking for some method with help of which I would make my ListView scroll without flashing/flickering...And in post there is link to one piece of software that does it greatly. Best regards, Standa.

                        P 1 Reply Last reply
                        0
                        • S s_k

                          Hi, maybe I post my question in a wrong way - I AM able to scroll the content of my ListView, I have vertical scrollbar there and pressing Key Down/Up keys also scroll the ListView. But in case when I have for example 10.000 files in ListView and I'm holding Page Key/Up or moving fastly with scroll bar, ListView "flashes", or how to say that...So I'm looking for some method with help of which I would make my ListView scroll without flashing/flickering...And in post there is link to one piece of software that does it greatly. Best regards, Standa.

                          P Offline
                          P Offline
                          PJ Arends
                          wrote on last edited by
                          #13

                          Ok, I misunderstood your question.


                          [

                          ](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!

                          1 Reply Last reply
                          0
                          • S s_k

                            Thanks Ryan! Now list of files is drawn, but for example column headers are not visible till I click on them. I'm using Custom Draw feature, maybe it has something to do with it...

                            A Offline
                            A Offline
                            Arjan Schouten
                            wrote on last edited by
                            #14

                            Hi, You have to exclude the headers from the clipbox, Try something like this... CPaintDC dc(this); CRect headerRect; CRect clientRect; GetClientRect(&clientRect); GetDlgItem(0)->GetWindowRect(&headerRect); ScreenToClient(&headerRect); dc.ExcludeClipRect(&headerRect); CMemDC memDC(&dc); //memDC.FillSolidRect(&clientRect, RGB(255, 255, 255)); DefWindowProc(WM_PAINT, (WPARAM)memDC->m_hDC, (LPARAM)0); Arjan

                            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