API Declarations Option ExplicitPrivate Declare Function DeleteMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As LongPrivate Declare Function GetSystemMenu Lib "user32.dll" (ByVal hWnd As Long, ByVal bRevert As Long ) As LongPrivate Declare Function SetWindowPos Lib "user32.dll" (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 LongPrivate Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nindex As Long, ByVal dwnewlong As Long) As LongPrivate Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nindex As Long) As LongPublic Const MF_BYCOMMAND = & H0 & Public Const MF_BYPOSITION = & H400 & Public Const SC_ARRANGE = & HF110Public Const SC_CLOSE = & HF060Public Const SC_HOTKEY = & HF150Public Const SC_HSCROLL = & HF080Public Const SC_KEYMENU = & HF100Public Const SC_MA XIMIZE = & HF030Public Const SC_MINIMIZE = & HF020Public Const SC_MOVE = & HF010Public Const SC_NEXTWINDOW = & HF040Public Const SC_PREVWINDOW = & HF050Public Const SC_RESTORE = & HF120Public Const SC_SIZE = & HF000Public Const SC_VSCROLL = & HF070Public Const SC_TASKLIST = & HF130Public Const HWND_TOPMOST = -1Public Const HWND_NOTOPMOST = -2Public Const HWND_TOP = 0Public Const SWP_NOSIZE = & H1PUBLIC const swP_nomove = & h2public const gwl_style = (-16) public enum t_windowstyle ws_border = & h800000 WS_CAPTION =
& HC00000 WS_CHILD = & H40000000 WS_CHILDWINDOW = (WS_CHILD) WS_CLIPCHILDREN = & H2000000 WS_CLIPSIBLINGS = & H4000000 WS_DISABLED = & H8000000 WS_DLGFRAME = & H400000 WS_EX_ACCEPTFILES = & H10 & WS_EX_DLGMODALFRAME = & H1 & WS_EX_NOPARENTNOTIFY = & H4 & WS_EX_TOPMOST = & H8 & WS_EX_TRANSPARENT = & H20 & WS_GROUP = & H20000 WS_HSCROLL = & H100000 WS_MAXIMIZE = & H1000000 WS_MAXIMIZEBOX = & H10000 WS_MINIMIZE = & H20000000 WS_MINIMIZEBOX = & H20000 WS_OVERLAPPED = & H0 & WS_ICONIC = WS_MINIMIZE WS_POPUP = & H80000000 WS_VISIBLE = & H10000000 WS_VSCROLL = & H200000 WS_SYSMENU = & H80000 WS_TABSTOP = & H10000 WS_THICKFRAME = & H40000 WS_TILED = WS_OVERLAPPED WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX) WS_POPUPWINDOW = (WS_POPUP Or ws_border or ws_sysmenu) WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW WS_SIZEBOX = WS_THICKFRAMEEND ENUM
Module 'Brings the specified form in the top most position, it will be over all other'forms in the screen, even if they will receive the focusPublic Sub FormTopMost (hWnd As Long) SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0 , SWP_NOSIZE SWP_NOMOVEEnd Sub'Brings the form in his standard Z-OrderPublic Sub FormNoTopMost (hWnd As Long) SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE SWP_NOMOVEEnd Sub'Brings the form in the top position of the Z -Order, if another form takes the'focus it will become the new top formPublic Sub FormTop (hWnd As Long) SetWindowPos hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE SWP_NOMOVEEnd Sub'Remove the form's system menu, if RemoveClose is true the Close command inside the'menu is removed too, in this case even the X key in the right upper cornet of the'form will be removedPublic Sub RemoveSystemMenu Dim hMenu As Long hMenu (hWnd As Long, RemoveClose As Boolean) = GetSystemMenu (hwnd, false) deleteMenu Hmenu, SC_Maximize, MF_BYCOMMAND DeleteMenu hMenu, SC_MINIMIZE, MF_BYCOMMAND DeleteMenu hMenu, SC_SIZE, MF_BYCOMMAND DeleteMenu hMenu, SC_MOVE, MF_BYCOMMAND DeleteMenu hMenu, SC_RESTORE, MF_BYCOMMAND DeleteMenu hMenu, SC_NEXTWINDOW, MF_BYCOMMAND If RemoveClose Then DeleteMenu hMenu, SC_CLOSE, MF_BYCOMMAND DeleteMenu hMenu, 0, MF_BYPOSITION End IfEnd Sub'Hides the upper right keys Maximize and minimizePublic Sub RemoveMaxMinButtons (hWnd As Long) Dim x As Long x = GetWindowLong (hWnd, GWL_STYLE) x = x and Not WS_MINIMIZEBOX x = x and Not WS_MAXIMIZEBOX SetWindowLong hWnd, GWL_STYLE, xEnd Sub '
Shows the upper right keys Maximize and minimizePublic Sub AddMaxMinButtons (hWnd As Long) Dim x As Long x = GetWindowLong (hWnd, GWL_STYLE) x = x Or WS_MINIMIZEBOX x = x Or WS_MAXIMIZEBOX SetWindowLong hWnd, GWL_STYLE, xEnd Sub'Set the attribute of a window: the module has a public enum type that contains'all the constants to define a window style (used by others Subs) public Sub SetWindowStyle (hWnd As Long, mAttribute As T_WindowStyle, Enable As Boolean) Dim x As Long x = GetWindowLong ( HWND, GWL_STYLE) IF enable the x = x = x and not mattribute end if setwindowlong hwnd, gwl_style, Xend Sub
http://www.andreavb.com/tip050002.html