| Let your form be right on top even though form does not have the focus. Other applications will still run normally, just with your form floating on top Option Explicit Private Const HWND_BOTTOM = 1 Private Const HWND_NOTOPMOST = -2 Private Const HWND_TOP = 0 Private Const HWND_TOPMOST = -1 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Declare Function GetActiveWindow Lib "user32" () As Long 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 'Pass the form's hwnd. The first routine ensures the form will 'always be on top. The second reverts back to the normal state Public Sub MakeWindowAlwaysTop(hwnd As Long) SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, _ SWP_NOMOVE + SWP_NOSIZE End Sub Public Sub MakeWindowNotTop(hwnd As Long) SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, _ SWP_NOMOVE + SWP_NOSIZE End Sub |
True Form on top with API |
Express News India | Freelance ecommerce web development India