Attribute VB_Name = "modMain" Public X As Long Option Explicit Private Declare Function SystemParametersInfo Lib _ "user32" Alias "SystemParametersInfoA" (ByVal uAction _ As Long, ByVal uParam As Long, ByVal lpvParam As Any, _ ByVal fuWinIni As Long) As Long Const FLAGS = 3 Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2 Public SetTop As Boolean Private Declare Function SetWindowPos Lib "user32" (ByVal h%, ByVal hb%, ByVal X%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer Sub commons(Disablem As Boolean) X = SystemParametersInfo(97, Disablem, CStr(1), 0) End Sub Sub AlwaysOnTop(FormName As Form, bOnTop As Boolean) Dim wind As Integer If bOnTop = False Then wind% = SetWindowPos(FormName.Wnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) Else wind% = SetWindowPos(FormName.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS) End If End Sub