Home  |  About  |   Search   

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

RunCommand Constants

Terms of Use


 

API: Find out if the database container window is currently visible

Author(s)
Dev Ashish
  All versions of Access allow the developer to programmatically hide the Database Container window. However, it's not possible to detect whether the window is visible or not.

  You can use this function which will return True if the window is currently visible inside the MDI Client window of the application.

'***************** Code Start *****************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function FindWindowEx _
    Lib "user32" Alias "FindWindowExA" _
    (ByVal hwndParent As Long, _
    ByVal hwndChildAfter As Long, _
    ByVal lpszClass As String, _
    ByVal lpszWindow As String) _
    As Long
    
Private Declare Function GetWindowLong _
    Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, _
    ByVal nIndex As Long) _
    As Long

Private Const GWL_STYLE = (-16)
Private Const WS_VISIBLE = &H10000000

Public Function fIsDBCVisible() As Boolean
'
' Returns true if the Database container
' window is currently visible
'
    Dim lngStyle As Long
    Dim hWnd As Long
    Const WC_MDICLIENT = "MDIClient"
    Const WC_DBC = "Odb"

    ' Find the MDIClient window first
    hWnd = FindWindowEx(hWndAccessApp, 0, _
                WC_MDICLIENT, vbNullString)
    ' Find the db container window
    hWnd = FindWindowEx(hWnd, 0, WC_DBC, vbNullString)

    If (hWnd) Then
        ' retrieve the window style
        lngStyle = GetWindowLong(hWnd, GWL_STYLE)
        fIsDBCVisible = ((lngStyle And WS_VISIBLE) = WS_VISIBLE)
    End If
    
End Function
'***************** Code Start *****************

1998-2009, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer