Attribute VB_Name = "OTSTDLIB_OnTop" Option Explicit '============================================================ ' OT Standard Library: Visual Basic ' OnTop.bas ' Description: This sets a form to be on top at all times ' unless otherwise set '------------------------------------------------------------ '------------------------------------------------------------ ' Example of How to Call Function ' ------------------------------- ' ' +----------------------------------------------------------+ ' | This code block sets the current form to OnTop status | ' +----------------------------------------------------------+ ' ' SetWindowPos Me.hWnd, HWND_TOPMOST, Me.Left / 15, _ ' Me.Top / 15, Me.Width / 15, _ ' Me.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW '============================================================ 'begin conditional compile #If Win32 Then '32-bit declares Declare Sub 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) #Else '16-bit declares Declare Sub SetWindowPos Lib "User" (ByVal h1%, ByVal h2%, ByVal X%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) #End If 'end conditional compile Global Const HWND_TOPMOST = -1 Global Const HWND_NOTOPMOST = -2 Global Const SWP_NOACTIVATE = &H10 Global Const SWP_SHOWWINDOW = &H40