Tipp 0146 Client-Bereich einer Form vertieft darstellen
Autor/Einsender:
Datum:
  Christian Lotmann
23.10.2001
Entwicklungsumgebung:   VB 6
Eine Möglichkeit den Client-Bereich einer Form vertieft (3D) darzustellen, wäre der Einsatz eines Container-Steuerelements wie z.B. einer PictureBox.
Die andere Möglichkeit ist, den Fensterstil mit WS_EX_CLIENTEDGE zu setzen. Damit die Stiländerung sofort wirksam wird, ist ein Refresh notwendig, sonst würde diese erst nach einem Resize zu sehen sein.
Code im Codebereich des Moduls
 
Option Explicit

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" (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 uFlags As Long) As Long

Public Const GWL_EXSTYLE = -20
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_FRAMECHANGED = &H20
Public Const WS_EX_CLIENTEDGE = &H200&

Public Sub FormVertiefen(Form As Form, vertiefen As Boolean)
  Dim nWindowLong As Long

  With Form
    nWindowLong = GetWindowLong(.hwnd, GWL_EXSTYLE)

    If vertiefen Then
      nWindowLong = nWindowLong Or WS_EX_CLIENTEDGE
    Else
      nWindowLong = nWindowLong And Not WS_EX_CLIENTEDGE
    End If
    SetWindowLong .hwnd, GWL_EXSTYLE, nWindowLong

    RedrawWindow .hwnd
  End With
End Sub

Public Sub RedrawWindow(ByVal hwnd As Long)
  Const Flags As Long = SWP_NOSIZE Or SWP_NOMOVE Or _
      SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_FRAMECHANGED
  SetWindowPos hwnd, 0, 0, 0, 0, 0, Flags
End Sub
 
Code im Codebereich der Form
 
Option Explicit

Private Sub Check1_Click()
  If Check1.Value = 0 Then
    Call FormVertiefen(Form1, False)
  Else
    Call FormVertiefen(Form1, True)
  End If
End Sub
 

Windows-Version
95
98/SE
ME
NT
2000
XP
Vista
Win 7
VB-Version
VBA 5
VBA 6
VB 4/16
VB 4/32
VB 5
VB 6


Download  (2,5 kB) Downloads bisher: [ 1039 ]

Vorheriger Tipp Zum Seitenanfang Nächster Tipp

Startseite | Projekte | Tutorials | API-Referenz | VB-/VBA-Tipps | Komponenten | Bücherecke | VB/VBA-Forum | VB.Net-Forum | DirectX-Forum | Foren-Archiv | DirectX | VB.Net-Tipps | Chat | Spielplatz | Links | Suchen | Stichwortverzeichnis | Feedback | Impressum

Seite empfehlen Bug-Report
Letzte Aktualisierung: Montag, 4. Juli 2011