Click here to Skip to main content
13,406,896 members (53,545 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 8 Mar 2005

Add XP Style Scrollbar to listctrl, listbox and so on (by self-draw)

, 8 Mar 2005
Rate this:
Please Sign up or sign in to vote.
Implement XP style scrollbar by self-draw
Sample Image - self-draw_XPScrollbar.jpg


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 CScrollWnd instead.

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)

{ if(!IsMouseInRange(WM_VSCROLL))
 CPoint ptCursor;

 CPoint ptCurPos = ptCursor;
 int nMaxTimes=200;

 int nTimes = 0;
 int nStep = 1;//accuracy

 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


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
China China
No Biography provided

You may also be interested in...

Comments and Discussions

Answerwhat is this. Pin
Member 1086271012-Jun-14 23:02
memberMember 1086271012-Jun-14 23:02 
GeneralMy vote of 5 Pin
dlsyaim6-Nov-11 17:58
memberdlsyaim6-Nov-11 17:58 
GeneralCombbox Pin
lroels20-Aug-07 21:48
memberlroels20-Aug-07 21:48 
Generalsocksv5 specification, details Pin
avinu28-Jul-07 22:56
memberavinu28-Jul-07 22:56 
thank you for the helpful code you published.
i wanted to ask you a couple of questions:
when i examine the communication between the client and the server
(using ethereal) i dont understand the structure of some packets.
1) when the server replies to the connect command of the client it has as remote address. shouldnt it be the address to which the
client should send the preceding packets?
2) to this the client replies with a packet with the version = 208.
3) then the server replies with a packet with a missing ATYP field.
4) afterwards, when the client sends the server the data, the packets
version field are 0.

is this how socksv5 works? if so - where is the appropriate documentation?
(i looked for it in rfc's 1928,1929)

thanks allot!

avi (

GeneralError in Zip File Pin
Srirama Kalyan7-May-07 5:46
memberSrirama Kalyan7-May-07 5:46 
GeneralRe: Error in Zip File Pin
Svetoslav Chekanov9-May-07 22:27
memberSvetoslav Chekanov9-May-07 22:27 
GeneralError in ZIP file Pin
ConradB5-Oct-06 20:38
memberConradB5-Oct-06 20:38 
GeneralGood Pin
vcfans23-Mar-06 16:02
membervcfans23-Mar-06 16:02 
GeneralCan't unzip the zip file Pin
chinni_uday1-Mar-06 21:10
memberchinni_uday1-Mar-06 21:10 
GeneralFailed to add HScroll Pin
Sandeep A.C15-Feb-06 1:15
memberSandeep A.C15-Feb-06 1:15 
GeneralUnable to Unzip Pin
K.Senthil Babu14-Jul-05 21:59
memberK.Senthil Babu14-Jul-05 21:59 
GeneralRe: Unable to Unzip Pin
ckTan8128-Jul-05 19:59
memberckTan8128-Jul-05 19:59 
Generalcant download Pin
Sam Chris5-May-05 3:58
memberSam Chris5-May-05 3:58 
GeneralRedraw bug on Win2000 Pin
Kochise8-Mar-05 22:19
memberKochise8-Mar-05 22:19 
GeneralRe: Redraw bug on Win2000 Pin
xwp9-Mar-05 15:35
memberxwp9-Mar-05 15:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180221.1 | Last Updated 8 Mar 2005
Article Copyright 2005 by xwp
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid