Force a popup form to the front of other windows application windows (1 Viewer)

Atomic Shrimp

Humanoid lifeform
Local time
Today, 04:15
Joined
Jun 16, 2000
Messages
1,954
I've got an application that uses pop up forms that open on top of the desktop (with the Access window minimised) - except that when a user launches the application, the startup form (a login form) drops behind other application windows.

How do I force it to the front?
 

ajetrumpet

Banned
Local time
Yesterday, 22:15
Joined
Jun 22, 2007
Messages
5,638
couldn't you hide the application window before you open the login form? you could do that if you replace the opening form specification with code that runs the minimize code and then opens the form with the docmd. here's some code to minimize the app window:
PHP:
Option Compare Database

'***********DECLARATIONS SECTION************
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
            (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2


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

Global Const HWND_TOPMOST = -1
Global Const SWP_NOSIZE = &H1
Global Const SWP_NOMOVE = &H2

Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Dim dwReturn As Long

Const SW_HIDE = 0
Const SW_SHOWMAXIMIZED = 3

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, _
     ByVal nCmdShow As Long) As Long




'USE THIS PROCEDURE TO SHOW OR HIDE THE ACCESS PROGRAM WINDOW
Public Function fAccessWindow( _
                                   Optional Procedure As String, _
                                   Optional SwitchStatus As Boolean, _
                                   Optional StatusCheck As Boolean _
                                   ) As Boolean

If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
End If
If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
End If
If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
End If
If StatusCheck = True Then
    If IsWindowVisible(hWndAccessApp) = 0 Then
        fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then
        fAccessWindow = True
    End If
End If

End Function
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 04:15
Joined
Jun 16, 2000
Messages
1,954
Thanks for that - so would you recommend calling that from a dedicated single-purpose startup form that runs this code, launches the login form, then closes itself?
 

ajetrumpet

Banned
Local time
Yesterday, 22:15
Joined
Jun 22, 2007
Messages
5,638
Thanks for that - so would you recommend calling that from a dedicated single-purpose startup form that runs this code, launches the login form, then closes itself?
i use it in an autoexec macro. and hide the window first thing before i do anything else.
 

Users who are viewing this thread

Top Bottom