Hallo,
ich versuche gerade mit dem Tipp "Größenänderung von Controls zur Laufzeit" die Größe einer PictureBox zu verändern. Funktioniert auch, da ich die PictureBox als SideBar in einer MDI Form benutzen möchte, sollte die größenänderung nur nach links möglich sein.
Ist dies mit dem volgenden Code möglich oder kann man sowas nicht einstellen?
Mfg: Crysis
' zunächst die benötigten API-Deklarationen
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private 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
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOMOVE = &H2
Private Const SWP_DRAWFRAME = &H20
Private Const GWL_STYLE = (-16)
Private Const WS_THICKFRAME = &H40000
' Ermöglicht die Größe eines Objekts zur Laufzeit zu ändern
'
' bStatus = True, Größenänderung einschalten
' bStatus = False, Größenänderung abschalten
' =====================================================
Public Sub DoResize(hWndParent As Long, _
hWndObject As Long, ByVal bStatus As Boolean)
Dim Result As Long
Result = GetWindowLong(hWndObject, GWL_STYLE) Or _
WS_THICKFRAME
If Not bStatus Then _
Result = Result - WS_THICKFRAME
SetWindowLong hWndObject, GWL_STYLE, Result
SetWindowPos hWndObject, hWndParent, 0, 0, 0, 0, _
SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or _
SWP_DRAWFRAME
End Sub |