VB Code:
  1. Option Explicit
  2.  
  3. Private Const HWND_NOTOPMOST = -2
  4. Private Const HWND_TOPMOST = -1
  5. Private Const SWP_NOMOVE = &H2
  6. Private Const SWP_NOSIZE = &H1
  7.  
  8. 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
  9.  
  10. Public Function MakeWindowAlwaysTop(byRef hWnd As Long)
  11.     SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
  12. End Function
  13.  
  14. Public Function MakeWindowNotTop(ByRef hWnd As Long)
  15.     SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
  16. End Function