The following code works to a point but won't allow interacting with forms behind it:
In standard Module 13:
Userform ONTOPFORM code:
I cannot figure out why this code is keeping the small ONTOPFORM "locked" not allowing interaction with the form or forms behind it.
I've seen this done but cannot find the correct code.
64 bit machine, Windows API calls.
Any help much appreciated
cr
In standard Module 13:
Code:
' Place this code in a standard module
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As LongPtr, ByVal lpWindowName As LongPtr) As LongPtr
Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_TOPMOST As LongPtr = -1
Public Const SWP_NOMOVE As Long = &H2
Public Const SWP_NOSIZE As Long = &H1
Public Const SWP_NOACTIVATE As Long = &H10
Public Const SWP_NOZORDER As Long = &H4
Public Const SWP_SHOWWINDOW As Long = &H40
Public Const HWND_NOTOPMOST As LongPtr = -2
Userform ONTOPFORM code:
Code:
Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:01"), "KeepFormOnTop"
End Sub
Private Sub UserForm_Deactivate()
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:01"), "KeepFormOnTop", , False
End Sub
I cannot figure out why this code is keeping the small ONTOPFORM "locked" not allowing interaction with the form or forms behind it.
I've seen this done but cannot find the correct code.
64 bit machine, Windows API calls.
Any help much appreciated
cr