Proceduren ChangeStyleBit kan kaldes herfra
Option Explicit
'***********************************************************
'
'Example code that shows how to remove scroll bars from a
'listbox control and then control the scrolling from command
'buttons.
'
'Copyright David Daly 1999.
'
www.daly.co.uk/david'
'***********************************************************
'API declarations for SetWindowLong and SetWindowPos
Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
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
'API decalation for SendMessage
Declare Function SendMessageVal Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
'API declaration for GetWindowLong
Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
'API declaration for GetParent
Declare Function GetParent Lib "user32" _
(ByVal hwnd As Long) As Long
'API declaration for SetParent
Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
'Windows constants
Public Const WS_VSCROLL = &H200000
Public Const SB_LINEUP = 0
Public Const SB_LINEDOWN = 1
Public Const WM_VSCROLL = &H115
Public Const GWL_STYLE = (-16)
Public Const GWL_EXSTYLE = (-20)
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_FRAMECHANGED = &H20 'The frame changed: send WM_NCCALCSIZE
Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
'ChangeStyleBit is an API wrapper function that allows you
'to set windows style bits. I got this (copied it directly)
'from Bruce McKinneys 'Hardcore Visual Basic', well worth
'a read if you're interested in this kind of thing!
Sub ChangeStyleBit(hwnd As Long, f As Boolean, afNew As Long)
Dim af As Long
af = GetWindowLong(hwnd, GWL_STYLE)
If f Then
af = af Or afNew
Else
af = af And (Not afNew)
End If
Call SetWindowLong(hwnd, GWL_STYLE, af)
Dim hParent As Long
hParent = GetParent(hwnd)
SetParent hwnd, hParent
Call SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
SWP_NOZORDER Or SWP_NOSIZE Or _
SWP_NOMOVE Or SWP_DRAWFRAME)
End Sub