'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 focus
Public Sub FormTopMost(hWnd As Long)
SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End Sub
'Brings the form in his
standard Z-Order
Public Sub FormNoTopMost(hWnd As Long)
SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End Sub
'Brings the form in the top
position of the Z-Order, if another form takes the
'focus it will become the new top form
Public Sub FormTop(hWnd As Long)
SetWindowPos hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE
End 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 removed
Public Sub RemoveSystemMenu(hWnd As Long, RemoveClose As Boolean)
Dim hMenu As Long
hMenu = 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 If
End Sub
'Hides the upper right keys
Maximize and minimize
Public 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, x
End Sub
'Shows the upper right keys
Maximize and minimize
Public 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, x
End 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 Then
x = x Or mAttribute
Else
x = x And Not mAttribute
End If
SetWindowLong hWnd, GWL_STYLE, x
End Sub |