Solved

How to detect appearance of MDI scrollbars.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 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…
Suggested Courses
Course of the Month5 days, 19 hours left to enroll

627 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