Gustav Brock
Gustav at cactus.dk
Fri Sep 7 04:43:46 CDT 2007
Hi Drew Nice. However, what is the ListView type? A2003 won't compile that: Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As ListView) As Long /gustav >>> DWUTKA at marlow.com 06-09-2007 23:15 >>> Yes, my code does the same, and a little more: Option Compare Database Option Explicit Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal _ cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Const SW_HIDE = 0 Const SW_MAXIMIZE = 3 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const HWND_TOPMOST = -1 Private Const HWND_BOTTOM = 1 Private Sub cmdAlwaysOnTop_Click() If IsWindowVisible(Application.hWndAccessApp) Then ShowWindow Application.hWndAccessApp, SW_HIDE SetWindowPos Application.hWndAccessApp, HWND_TOPMOST, 0, 0, 0, 0, _ SWP_NOMOVE Or SWP_NOSIZE Else ShowWindow Application.hWndAccessApp, SW_MAXIMIZE SetWindowPos Application.hWndAccessApp, HWND_BOTTOM, 0, 0, 0, 0, _ SWP_NOMOVE Or SWP_NOSIZE End If End Sub Private Sub Form_Unload(Cancel As Integer) If IsWindowVisible(Application.hWndAccessApp) = False Then ShowWindow Application.hWndAccessApp, SW_MAXIMIZE SetWindowPos Application.hWndAccessApp, HWND_BOTTOM, 0, 0, 0, 0, _ SWP_NOMOVE Or SWP_NOSIZE End If End Sub The code above hides the access window and actually puts popup forms as 'always on top' of all other windows. However, this code: Option Explicit Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Public intWindowsShown As Long Function FindAndShowWindows() Dim dwReturn As Long dwReturn = EnumWindows(AddressOf EnumWindowsProc, 0) End Function Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As ListView) As Long Dim strClass As String Dim dwReturn As Long strClass = Space(50) dwReturn = GetClassName(hwnd, strClass, 50) strClass = Left(strClass, dwReturn) If strClass = "OMain" And Not IsWindowVisible(hwnd) Then ShowAccessWindow hwnd intWindowsShown = intWindowsShown + 1 End If EnumWindowsProc = 1 End Function Will unhide every Access window on your machine. Drew