ScrollBars

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I determine the width of vertical scrollbars? It looks like the scrollbar may be a fixed number of pixels wide (it gets fatter with lower resolution) but I can't find sny documentation that tells me how "wide" it really is...
 
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hDC As Long, ByVal nIndex As Long) As Long

' Constants
Private Const SM_CXVSCROLL = 2


You call the API like this:

lngScrollBarWidth = GetSystemMetrics(SM_CXVSCROLL)


Sample code, along with functions to convert Pixels to Twips can be
found in this project:
http://www.lebans.com/justicombo.htm

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


jwkeene said:
How do I determine the width of vertical scrollbars? It looks like the
scrollbar may be a fixed number of pixels wide (it gets fatter with
lower resolution) but I can't find sny documentation that tells me how
"wide" it really is...
 
Hi,


You can determine the width of the vertical scrollbar by performing the following steps


1) Create a module with the following code


'---------------------------- Start of Module Code ----------------------------
Option Compare Database
Option Explicit

' Logical Font
Public Const LF_FACESIZE = 32

Public Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(1 To LF_FACESIZE) As Byte
End Type

Public Type NONCLIENTMETRICS
cbSize As Long
iBorderWidth As Long
iScrollWidth As Long
iScrollHeight As Long
iCaptionWidth As Long
iCaptionHeight As Long
lfCaptionFont As LOGFONT
iSMCaptionWidth As Long
iSMCaptionHeight As Long
lfSMCaptionFont As LOGFONT
iMenuWidth As Long
iMenuHeight As Long
lfMenuFont As LOGFONT
lfStatusFont As LOGFONT
lfMessageFont As LOGFONT
End Type

Const SPI_GETNONCLIENTMETRICS = 41

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Any, _
ByVal fuWinIni As Long) As Long

Public Function GetNonClientMetrics() As NONCLIENTMETRICS
Dim nonClientMetricsRecord As NONCLIENTMETRICS


nonClientMetricsRecord.cbSize = Len(nonClientMetricsRecord)

Call SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, nonClientMetricsRecord, 0)

GetNonClientMetrics = nonClientMetricsRecord
End Function
'----------------------------- End of Module Code ----------------------------


2) Call GetNonClientMetrics with the following code


Dim nonClientMetricsRecord As NONCLIENTMETRICS


nonClientMetricsRecord = GetNonClientMetrics()


The width of the vertical scrollbar is nonClientMetricsRecord.iScrollWidth


Wayne Pearson


jwkeene said:
How do I determine the width of vertical scrollbars? It looks like the scrollbar may be a fixed number of pixels wide (it gets
fatter with lower resolution) but I can't find sny documentation that tells me how "wide" it really is...
 
Back
Top