vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#

https://www.vbarchiv.net
Rubrik: Oberfläche · Effekte   |   VB-Versionen: VB4, VB5, VB621.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 WolffBewertung:  Views:  13.474 
www.andreaswolff.deSystem:  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



Anzeige

Kauftipp Unser Dauerbrenner!Diesen und auch alle anderen Tipps & Tricks finden Sie auch auf unserer aktuellen vb@rchiv  Vol.6
(einschl. Beispielprojekt!)

Ein absolutes Muss - Geballtes Wissen aus mehr als 8 Jahren vb@rchiv!
- nahezu alle Tipps & Tricks und Workshops mit Beispielprojekten
- Symbol-Galerie mit mehr als 3.200 Icons im modernen Look
Weitere Infos - 4 Entwickler-Vollversionen (u.a. sevFTP für .NET), Online-Update-Funktion u.v.m.
 
 
Copyright ©2000-2024 vb@rchiv Dieter OtterAlle Rechte vorbehalten.


Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.