|
From: Kjell Arne Johansen on 23 Apr 2008 07:44 Hi How do I calculate the position of the thumb in the scrollbar? In an application I have a grid that can display thousands or millions of rows with data from a database. I do not want to retrieve more data from the database than what can be displayed and visible. I do not want to create a grid with 1000 000 rows if only 100 is visible in the application. So I cheat. I have built the scrollbar to reflect the total number of rows, e.g. 1000. The size of the thumb reflects the number of visible rows, e.g. 100 visible rows out of 1000. The size of the thumb is then 1/10 of the scroll area in the scrollbar. Scroll down and scroll up clicking in the scroll area of the scrollbar works fine. The thumb moves correctly 1/10 for each click in the scroll area, and I display next/previous 50 rows. The problem occurs when I click the arrow buttons in the scrollbar. If I click arrow down, then the thumb moves 1/10 down in the scroll area instead of 1/1000 down. How do I implement moving the scrollbar just one row? Which methods of the CSrollBar should I use? Thank you for any info that could help me. Regards Kjell Arne Johansen
From: Joseph M. Newcomer on 23 Apr 2008 11:14 You would have to show your OnVScroll handler code. joe On Wed, 23 Apr 2008 04:44:03 -0700, Kjell Arne Johansen <KjellArneJohansen(a)discussions.microsoft.com> wrote: >Hi > >How do I calculate the position of the thumb in the scrollbar? > >In an application I have a grid that can display thousands or millions of >rows with data from a database. > >I do not want to retrieve more data from the database than what can be >displayed and visible. > >I do not want to create a grid with 1000 000 rows if only 100 is visible in >the application. > >So I cheat. >I have built the scrollbar to reflect the total number of rows, e.g. 1000. >The size of the thumb reflects the number of visible rows, e.g. 100 visible >rows out of 1000. The size of the thumb is then 1/10 of the scroll area in >the scrollbar. > >Scroll down and scroll up clicking in the scroll area of the scrollbar works >fine. The thumb moves correctly 1/10 for each click in the scroll area, and >I display next/previous 50 rows. > >The problem occurs when I click the arrow buttons in the scrollbar. >If I click arrow down, then the thumb moves 1/10 down in the scroll area >instead of 1/1000 down. > >How do I implement moving the scrollbar just one row? > >Which methods of the CSrollBar should I use? > >Thank you for any info that could help me. > >Regards Kjell Arne Johansen > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Doug Harrison [MVP] on 23 Apr 2008 12:14 On Wed, 23 Apr 2008 04:44:03 -0700, Kjell Arne Johansen <KjellArneJohansen(a)discussions.microsoft.com> wrote: >Hi > >How do I calculate the position of the thumb in the scrollbar? > >In an application I have a grid that can display thousands or millions of >rows with data from a database. > >I do not want to retrieve more data from the database than what can be >displayed and visible. > >I do not want to create a grid with 1000 000 rows if only 100 is visible in >the application. > >So I cheat. >I have built the scrollbar to reflect the total number of rows, e.g. 1000. >The size of the thumb reflects the number of visible rows, e.g. 100 visible >rows out of 1000. The size of the thumb is then 1/10 of the scroll area in >the scrollbar. > >Scroll down and scroll up clicking in the scroll area of the scrollbar works >fine. The thumb moves correctly 1/10 for each click in the scroll area, and >I display next/previous 50 rows. > >The problem occurs when I click the arrow buttons in the scrollbar. >If I click arrow down, then the thumb moves 1/10 down in the scroll area >instead of 1/1000 down. > >How do I implement moving the scrollbar just one row? > >Which methods of the CSrollBar should I use? > >Thank you for any info that could help me. > >Regards Kjell Arne Johansen Presumably, you are maintaining your own variables that contain the index of the top item, the total number of items, and the number of visible items. You need to update the top item index as necessary, map its position to scrollbar coordinates, and then use SetScrollPos. -- Doug Harrison Visual C++ MVP
|
Pages: 1 Prev: treeview item's icon changed to dark when it was cutted Next: AttachConsole() on Win 2000 |