Determine Which Scrollbars are Visible

Determine Which Scrollbars are Visible

Sometimes, it’s useful to know whether a control is displaying vertical scrollbars, horizontal scrollbars, both horizontal and vertical, or no scrollbars at all. For instance, when determining the amount of room inside a control, you might have to take into account the space taken up by the scrollbars. This function, written in VB5, returns an enumerated constant representing the scrollbar state of the given control:

 Private Declare Function GetWindowLong Lib "user32" Alias _	"GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _	As Long) As Long'GetWindowLong ConstantsPrivate Const GWL_STYLE = (-16)Private Const WS_HSCROLL = &H100000Private Const WS_VSCROLL = &H200000'Used by VisibleScrollBars functionEnum Enum_VisibleScrollBars	vs_none = 0	vs_vertical = 1	vs_horizontal = 2	vs_both = 4End EnumPublic Function VisibleScrollBars(ControlName As Control) _	As Enum_VisibleScrollBars	'	' Returns an enumerated type constant depicting the 	' type(s) of scrollbars visible on the passed control.	'	Dim MyStyle As Long	MyStyle = GetWindowLong(ControlName.hWnd, GWL_STYLE)	'Use a bitwise comparison	If (MyStyle And (WS_VSCROLL Or WS_HSCROLL)) = _		(WS_VSCROLL Or WS_HSCROLL) Then		'Both are visible		Let VisibleScrollBars = vs_both	ElseIf (MyStyle And WS_VSCROLL) = WS_VSCROLL Then		'Only Vertical is visible		Let VisibleScrollBars = vs_vertical	ElseIf (MyStyle And WS_HSCROLL) = WS_HSCROLL Then		'Only Horizontal is visible		Let VisibleScrollBars = vs_horizontal	Else		'No scrollbars are visible		Let VisibleScrollBars = vs_none	End IfEnd Function

Hard-coding a scrollbar with a predetermined width or height is not a good idea because these might vary depending on the user’s display settings (accessibility options, desktop themes, and so on). Call GetSystemMetrics to always ensure the proper value for this metric.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as