Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to detect appearance of MDI scrollbars.

Posted on 1998-07-11
2
Medium Priority
?
342 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 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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 …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

722 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