Rubrik: Oberfläche · Effekte | VB-Versionen: VB4, VB5, VB6 | 21.11.00 |
Objekte mit einem 3D-Rahmen ausstatten Mit dem nachfolgenden Tipp ist es möglich mit wenigen Anweisungen, Command- & Optionbuttons, Picture- & Checkboxen - einfach alle Objekte mit einer ... | ||
Autor: Andreas Wolff | Bewertung: | Views: 13.475 |
www.andreaswolff.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Mit dem nachfolgenden Tipp ist es möglich mit wenigen Anweisungen, Command- & Optionbuttons, Picture- & Checkboxen - einfach alle Objekte mit einer hWnd-Eigenschaft - mit einem 3D-Rahmen auszustatten.
' Allgemeine Deklaration ' 16Bit #If Win16 Then Declare Function GetWindowLong Lib "User" ( _ ByVal hWnd As Integer, _ ByVal nIndex As Integer) As Long Declare Function SetWindowLong Lib "User" ( _ ByVal hWnd As Integer, _ ByVal nIndex As Integer, _ ByVal dwNewLong As Long) As Long Declare Function SetWindowPos Lib "User" ( _ ByVal hWnd%, _ ByVal hWndInsertAfter%, _ ByVal X%, _ ByVal Y%, _ ByVal cX%, _ ByVal cY%, _ ByVal wFlags%) As Integer ' 32Bit #Else Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" ( _ ByVal hwnd As Long, _ ByVal nIndex As Long) As Long 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" _ Alias "SetWindowPos" ( _ 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 #End If Const GWL_STYLE = (-16) Const WS_THICKFRAME = &H40000 Const WS_CHILD = &H40000000 Const SWP_DRAWFRAME = &H20 Const SWP_NOMOVE = &H2 Const SWP_NOSIZE = &H1 Const SWP_NOZORDER = &H4 ' Aufruf Dim Style As Long Dim Ret As Long Style = GetWindowLong(OBJEKT.hWnd, GWL_STYLE) Style = Style& Or WS_THICKFRAME Ret = SetWindowLong(OBJEKT.hWnd, GWL_STYLE, Style) Ret = SetWindowPos(OBJEKT.hWnd, Form1.hWnd, 0, 0, 0, 0, _ SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME)
Beispiel:
Plazieren Sie eine Check-Box auf eine Form und fügen im Form_Load-Ereignis nachfolgenden Code ein:
Private Sub Form_Load() Dim Style As Long Dim Ret As Long Style = GetWindowLong(Check1.hWnd, GWL_STYLE) Style = Style& Or WS_THICKFRAME Ret = SetWindowLong(Check1.hWnd, GWL_STYLE, Style) Ret = SetWindowPos(Check1.hWnd, Form1.hWnd, 0, 0, 0, 0, _ SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME) End Sub