In vb 6, there is no any property or method to make a form the topmost window but we can do with the help of SetWindowPos method in user32 win API.
The following code uses a functions called Set_FormAlwaysTop and Set_FormNotTop. The Set_FormAlwaysTop function sets a form as a topmost Window and Set_FormNotTop sets a form to normal Window.The passed parameter ‘hwnd’ specifies the which window to be set as topmost window or as normal window.
Option Explicit Private Const HWND_BOTTOM As Long = 1 Private Const HWND_NOT_TOP_MOST As Long = -2 Private Const HWND_TOP As Long = 1 Private Const HWND_TOP_MOST As Long = -1 Private Const SWP_NO_MOVE As Long = &H2 Private Const SWP_NO_SIZE As Long = &H1 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) Declare Function GetActiveWindow& Lib "user32" () Public Sub Set_FormAlwaysTop(ByVal hWnd As Long) SetWindowPos hWnd, HWND_TOP_MOST, 0, 0, 0, 0, SWP_NO_MOVE + SWP_NO_SIZE End Sub Public Sub Set_FormNotTop(ByVal hWnd As Long) SetWindowPos hWnd, HWND_NOT_TOP_MOST, 0, 0, 0, 0, SWP_NO_MOVE + SWP_NO_SIZE End Sub
How to use above function:
Suppose if you want to make Form1 as TopMost window then you can call the Set_FormAlwaysTop function as:
Set_FormAlwaysTop(Form1.hwnd)