Solved

How to reset the scrollbar and scroll position of a CListCtrl box?

Posted on 2002-07-17
2
1,412 Views
Last Modified: 2013-11-20
Hi i have a CListCtrl Box (in Icon view) in my application which i need to fill it up with lots of icons and the icons will be removed and new icons will be added from time to time... everythings working fine except i can't figure out how to reset the scrollbar and scroll position (to origin) when i'm updating the icons.
At the moment I got this in my code but it doesn't seem to working too well:

//The function for updating the CListCtrl Box
SetWindowLong(m_ctlColourSample.m_hWnd,GWL_STYLE,m_listBoxStyle );

//clears the current colour list and Clistctrl box
while(!m_currentSampleList->IsEmpty())          
{
     CSample *pa;
     pa = (CSample*)m_currentSampleList->RemoveHead();
             delete pa;
}

int imageCount= m_imageListColour->GetImageCount();
for (int k=imageCount;k >0;k--)
{
     m_imageListColour->Remove(k-1);
}

//resets the position.. doesn't really work well
m_ctlColourSample.SetScrollPos( SB_HORZ  ,1, false);
m_ctlColourSample.SetScrollPos( SB_VERT  ,1, true);
m_ctlColourSample.SetScrollRange(SB_HORZ,0,0,false);
m_ctlColourSample.SetScrollRange(SB_VERT,0,0,false);

//codes adding new icons
..
..
..
..
//


//try to reset the scroll position to origin.. doesn't really work
m_ctlColourSample.SetScrollPos( SB_HORZ  ,1, false);
m_ctlColourSample.SetScrollPos( SB_VERT  ,1, true);



Anyone tell me how to fix the problem? did i do something wrong?
cheers,
0
Comment
Question by:rw8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
fl0yd earned 100 total points
ID: 7161815
0
 

Author Comment

by:rw8
ID: 7163638
Thanks! it's working now!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
has22 challenge 11 111
either24  challenge 19 110
haveThree challenge 22 128
pre4 challenge 19 116
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question