Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

Obtaining the size of scroll bars

I'm using a multicolumned list control.  I'd like to set the column widths so that they fit neatly in the available space (that is, there's no horizontal scroll bar.)  

If I base these widths on the size returned by GetClientArea(), it works fine as long as there's no vertical scroll bar.  

I'd like to take the width of the vertical scroll bar into account - how do I find out what it is?    
0
fisham29
Asked:
fisham29
  • 3
  • 2
1 Solution
 
milenvkCommented:
Consider using
GetSystemMetrics(SM_CXVSCROLL)
This returns the width in pixels of the vertical scroll bar.
0
 
fisham29Author Commented:
Oh, maybe ::GetSystemMetrics( SM_CXVSCROLL )???

Now how do I convert from pixels to client coordinates?
0
 
fisham29Author Commented:
Oops - you beat me to it.   You were fast!!!  Could you indulge my second question also??
0
 
fisham29Author Commented:
Never mind.  I guess in MM_TEXT, pixels ARE client coordinates.
0
 
milenvkCommented:
You have to calculate in order to convert the pixels to client coordinates. You can assume that the scrollbar stays to the left of the right edge of the client rectangle. Then just subtract the pixels returned by GetSystemMetrics(SM_CXVSCROLL) from the right of the client rectangle and you'll get the left edge of the scrollbar in client coordinates.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now