One of my recent projects needed to beautify UI, but when the app does not run on WinXP, the intrinsic scrollbar of common controls is too ugly. So I use self-draw
At present, only
VSCROLL is supported.
HSCROLL will be added when I have time to do it, and any help will be appreciated (you can add it by yourself).
The biggest problem to implement a scrollbar is to locate thumb properly. To solve this problem, I have used many ways, but at the end, a very convenient and reliable method was found: step by step approach.
void CScrollWnd::MoveThumb(CPoint ptOffset)
CPoint ptCurPos = ptCursor;
int nTimes = 0;
int nStep = 1;
CPoint ptNewPos = ptOffset + GetRect(HT_THUMB).CenterPoint();
while(abs(ptNewPos.y - ptCurPos.y)>nStep && nTimes++<nMaxTimes)
BOOL bDirDown = ptCurPos.y>ptNewPos.y;
ptNewPos = ptOffset + GetRect(HT_THUMB).CenterPoint();
See the attached source code for more details.
Sorry for my poor English. My mother tongue is Chinese. :)
- 8th March, 2005: Initial post