Solved

How to detect appearance of MDI scrollbars.

Posted on 1998-07-11
2
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 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