Tipp 0151 SplitterBar -1-
Autor/Einsender:
Datum:
  Ronald Janowski
29.10.2001
Entwicklungsumgebung:   VB 5
Mit diesem Tipp kann man sich schnell eine (oder auch mehrere) SplitterBar in sein Programm einbauen, und zwar nicht wie oft gezeigt, mittels flackernder PictureBox, sondern einfach über das Festlegen einer "Region".
 
Option Explicit

Private Type POINTAPI
  X As Long
  Y As Long
End Type

Private Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type

Dim Region1 As RECT
Dim Region2 As RECT
Dim Split1 As Boolean
Dim Split2 As Boolean
Dim savXY As POINTAPI

Private Sub Form_Load()
  Picture1.Height = List1.Height - Picture1.Top
End Sub

Private Sub Form_Resize()
  List1.Height = (Me.ScaleHeight - List1.Top) - 12
  Text1.Width = (Me.ScaleWidth - Text1.Left) - 12
  Picture1.Width = (Me.ScaleWidth - Picture1.Left) - 12
  Picture1.Height = (List1.Top + List1.Height) - Picture1.Top

  savXY.X = List1.Left + List1.Width + Text1.Width
  savXY.Y = List1.Top + List1.Height

  Call getRegions
End Sub

Private Sub getRegions()
  On Error Resume Next

  Region1.Left = List1.Width - 30
  Region1.Right = Text1.Left + 30
  Region1.Top = List1.Top 
  Region1.Bottom = List1.Height

  Region2.Left = Picture1.Left
  Region2.Right = Picture1.Left + Picture1.Width
  Region2.Top = Text1.Height - 30
  Region2.Bottom = Picture1.Top + 30
End Sub

Private Function getPos(mX As Single, mY As Single)
  On Error Resume Next

  If mX > Region1.Left And mX < Region1.Right _
          And mY > Region1.Top And mY < Region1.Bottom Then
    Me.MousePointer = 9
    Split1 = True
    Split2 = False

  ElseIf mX > Region2.Left And mX < Region2.Right _
          And mY > Region2.Top And mY < Region2.Bottom Then
    Me.MousePointer = 7
    Split2 = True
    Split1 = False

  Else
    Me.MousePointer = 1
    Split2 = False
    Split1 = False
  End If
End Function

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _
      X As Single, Y As Single)
  On Error Resume Next

  Call getRegions
  Call getPos(X, Y)

  If Button = 1 Then
    If Split1 = True Then
      If X < 25 Xor X > Me.ScaleWidth - 40 Then Exit Sub

      List1.Width = X - 6
      Text1.Left = X + 6
      Text1.Width = savXY.X - Text1.Left
      Picture1.Left = X + 6
      Picture1.Width = savXY.X - Text1.Left

    ElseIf Split2 = True Then
      If Y < 25 Xor Y > Me.ScaleHeight - 40 Then Exit Sub

      Text1.Height = Y - 6
      Picture1.Top = Y + 6
      Picture1.Height = savXY.Y - Picture1.Top
    End If
  End If
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift _
      As Integer, X As Single, Y As Single)
  Me.MousePointer = 1
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift _
      As Integer, X As Single, Y As Single)
  Me.MousePointer = 1
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift _
      As Integer, X As Single, Y As Single)
  Me.MousePointer = 1
End Sub

Private Sub mnFileExit_Click()
  Unload Me
  Set frmSplit = Nothing
End Sub
 
Weitere Links zum Thema
Form scrollen
StatusBar ohne OCX erstellen
Teilbereich einer Form scrollen

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,7 kB) Downloads bisher: [ 1246 ]

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, 25. Juli 2011