Always on Top problems

HardCode

New member
Local time
Today, 15:02
Joined
Apr 6, 2005
Messages
6
No matter what code examples I use from this forum, I cannot get a form to stay on top within the Access .MDB (I am not running it from an .MDE). Here is the code that I am using. Does anyone see anything wrong?

In a module:
Code:
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

' Topmost window
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Public Sub OnTop(ByVal lhWnd As Long)
  SetWindowPos lhWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub

Public Sub NotOnTop(ByVal lhWnd As Long)
  SetWindowPos lhWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub

In the form:
Code:
Private Sub Form_Load()

    DoCmd.Restore
    Call OnTop(Me.hWnd)
    
End Sub
 
Maybe I'm thinking too simple, but why don't you just set the Modal-property of the form on True? That should keep it focussed until it's closed.

Or do you want to keep the entire access-app ontop in windows??

Greetz,

Seth
 

Users who are viewing this thread

Back
Top Bottom