?
Solved

How to know if the scrollbar is showing inside a listbox?

Posted on 2005-05-12
3
Medium Priority
?
208 Views
Last Modified: 2010-04-23
Hi,

I try to find a way to ask my listbox if the HorizontalScrollbar or the VerticalScrollbar is showing.
Is there a way?

Thanks!
0
Comment
Question by:slabrie99
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 600 total points
ID: 13985897
Public Class Control_Library

  Private Declare Function GetWindowLong _
    Lib "user32" Alias "GetWindowLongA" _
      (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer

  Private Const GWL_STYLE As Short = (-16)

  Public Shared Function HasHorizontalScrollbar(ByVal ctrl As System.Windows.Forms.Control) As Boolean

    Const WS_HSCROLL As Integer = &H100000

    Return GetWindowLong(ctrl.Handle, GWL_STYLE) And WS_HSCROLL

  End Function 'HasHorizontalScrollbar'


  Public Shared Function HasVerticalScrollbar(ByVal ctrl As System.Windows.Forms.Control) As Boolean

    Const WS_VSCROLL = &H200000

    Return GetWindowLong(ctrl.Handle, GWL_STYLE) And WS_VSCROLL

  End Function 'HasVerticalScrollbar'

End Class


Usage:
Dim vertical As Boolean = Control_Library.HasVerticalScrollbar(Me.ListBox1)

Bob
0
 
LVL 27

Expert Comment

by:planocz
ID: 13985945
What is the purpose for knowing this?
0
 

Author Comment

by:slabrie99
ID: 13986309
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question