Private Const GWL_EXSTYLE& = (-20)
Private Const GWL_STYLE& = (-16)
Private Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long)
Private Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Public Sub ModifyStyle(ByVal hWindow As Long, _
ByVal Remove As Long, ByVal Add As Long)
Dim style As Long, OldStyle As Long
OldStyle = GetWindowLong(hWindow, GWL_STYLE)
style = (OldStyle And (Not Remove)) Or Add
SetWindowLong hWindow, GWL_STYLE, style
End Sub
Public Sub ModifyStyleEx(ByVal hWindow As Long, _
ByVal Remove As Long, ByVal Add As Long)
Dim xstyle As Long, OldStyle As Long
OldStyle = GetWindowLong(hWindow, GWL_EXSTYLE)
xstyle = (OldStyle And (Not Remove)) Or Add
SetWindowLong hWindow, GWL_EXSTYLE, xstyle
End Sub
For example, to remove the maximize and minimize buttons from a form and make it transparent, you will use the above functions like this:
ModifyStyle hwnd, WS_MAXIMIZEBOX Or WS_MINIMIZEBOX, 0
ModifyStyleEx hwnd, 0, WS_EX_TRANSPARENT
No comments:
Post a Comment