Solved

How to detect appearance of MDI scrollbars.

Posted on 1998-07-11
2
332 Views
Last Modified: 2010-05-18
I'm using VB5 Professional Edition. I don't know how to detect the appearance of
scrollbars event in an MDI form when two or more child forms are displayed with
their margins extending otside the MDI borders. Is it possible to detect such an event
or does one have to work with the the ScaleLeft and ScaleTop properties?
0
Comment
Question by:flavour
2 Comments
 
LVL 2

Accepted Solution

by:
mtoft earned 50 total points
ID: 1465489
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Type SCROLLINFO
    cbSize As Long
    fMask As Long
    nMin As Long
    nMax As Long
    nPage As Long
    nPos As Long
    nTrackPos As Long
End Type

' Scroll Info Mask Flags
Private Const SIF_RANGE = &H1
Private Const SIF_PAGE = &H2
Private Const SIF_POS = &H4
Private Const SIF_DISABLENOSCROLL = &H8
Private Const SIF_TRACKPOS = &H10
Private Const SIF_ALL = SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS

' Scroll Bar Constants
Private Const SB_HORZ = 0
Private Const SB_VERT = 1
Private Const SB_CTL = 2
Private Const SB_BOTH = 3

Private Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As Long, ByVal n As Long, lpScrollInfo As SCROLLINFO) As Long

Private Sub MDIForm_Click()
    Debug.Print "Horz: " & IsScrollBarVisible(Me, SB_HORZ)
    Debug.Print "Vert: " & IsScrollBarVisible(Me, SB_VERT)
End Sub

Function IsScrollBarVisible(ByVal TheForm As MDIForm, ByVal Scrollbar As Long)
    ' Find the MDIClient area
    Dim lHwnd As Long
    lHwnd = FindWindowEx(TheForm.hWnd, 0&, "MDIClient", vbNullString)
       
    If lHwnd = 0 Then
        MsgBox "Could not find MDI Client window.", vbExclamation
        Exit Function
    End If
       
    ' Get scrollbar information for MDIClient window
    Dim lpInfo As SCROLLINFO
    lpInfo.cbSize = LenB(lpInfo)
    lpInfo.fMask = SIF_ALL
    If GetScrollInfo(lHwnd, Scrollbar, lpInfo) = 0 Then
        ' Scrollbars are not visible
        IsScrollBarVisible = False
    Else
        ' We got some information about the scrollbars
        ' scrollbars are visible...
        ' Information available in lpInfo
        IsScrollBarVisible = (lpInfo.nPage - 1) <> lpInfo.nMax
    End If
End Function

0
 

Author Comment

by:flavour
ID: 1465490
Thank you very much for the help I'll try it strait away!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

820 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