Scrollbars in richtext box visible?

Posted on 2006-05-18
Medium Priority
Last Modified: 2012-05-05
This is a question that has been asked in many variations, but I have yet to find an answer.

I have a richtext box and I want to know, at any given time, if the vertical scroll bar is visible. I have other hooks in place to track when the scroll in scrolled (using GetScrollInfo), but I am trying to figure out if it is visible. I.e. When the user resizes the form, is the scroll bar still visible.  Any thoughts?
Question by:IOFDSYS
1 Comment
LVL 86

Accepted Solution

Mike Tomlinson earned 1000 total points
ID: 16709750

    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
    Public Const WS_HSCROLL = &H100000
    Public Const WS_VSCROLL = &H200000
    Public Const GWL_STYLE = (-16)

    Private Function HasVerticalScrollBar(ByVal handle As IntPtr) As Boolean
        Return (GetWindowLong(handle, GWL_STYLE) And WS_VSCROLL) = WS_VSCROLL
    End Function

    Private Function HasHorizontalScrollBar(ByVal handle As IntPtr) As Boolean
        Return (GetWindowLong(handle, GWL_STYLE) And WS_HSCROLL) = WS_HSCROLL
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Debug.WriteLine("Vertical: " & HasVerticalScrollBar(RichTextBox1.Handle))
        Debug.WriteLine("Horizontal: " & HasHorizontalScrollBar(RichTextBox1.Handle))
    End Sub

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

621 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