[AccessD] Transactions

Gustav Brock Gustav at cactus.dk
Fri Sep 7 09:09:05 CDT 2007


Hi Drew

Yes, I did figure that out, though I used SW_SHOWNORMAL.
This restores nicely the main window of Access. However, as I browsed the thread, the target was to unhide the Database window - or did I miss something?

/gustav

>>> DWUTKA at marlow.com 07-09-2007 15:59 >>>
Good point, sorry, just grabbed the code out of a module, the form I had
run that had the 'showaccesswindow' function.  Just replace that line
with:

ShowWindow hwnd, SW_MAXIMIZE

You'll need to copy the API declaration and SW_MAXMIZE constant from the
first bit of code in the post.

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Friday, September 07, 2007 8:31 AM
To: accessd at databaseadvisors.com 
Subject: Re: [AccessD] Transactions

Hi Drew

OK, it's probably from my cut and paste ...

But your sub ShowAccessWindow seems to miss?
I've found one from you dated 2002-05-10 but it takes another argument.

/gustav

>>> DWUTKA at marlow.com 07-09-2007 15:05 >>>
No idea why that says listview, should be long.

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Friday, September 07, 2007 4:44 AM
To: accessd at databaseadvisors.com 
Subject: Re: [AccessD] Transactions

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





More information about the AccessD mailing list