Solved

How to detect appearance of MDI scrollbars.

Posted on 1998-07-11
2
325 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now