Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Keep form on top


'use this API to set a window on top
Public 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
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = - 1
Public Const HWND_NOTOPMOST = - 2

Dim iReturn As Integer
'to put the window on top
iReturn = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
'to release the window from being on top
iReturn = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)