|
Option Explicit
Private TextBoxAnzahl As Long
Private TextBoxAnzahlQuer As Long
Private TextBoxHeight As Single
Private TextBoxWidth As Single
Private TextBoxLeft As Single
Private LabelWidth As Single
Private LabelLeft As Single
Private TextBoxAbstandHoehe As Long
Private TextBoxAbstandBreite As Long
Private TextBoxContainerTop As Long
Private TextBoxContainerBottom As Long
Private TextBoxContainerLeft As Long
Private TextBoxFrameTotalHeight As Single
Private Sub Form_Load()
Dim i As Long
Me.Width = 800 * Screen.TwipsPerPixelX Me.Height = 570 * Screen.TwipsPerPixelY
If Screen.Width > Me.Width Then
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
Else
Me.Top = 0
Me.Left = 0
End If
TextBoxAnzahl = 240 TextBoxAnzahlQuer = 3
LabelWidth = 450 LabelLeft = 30
TextBoxHeight = 315 TextBoxWidth = 2100 TextBoxLeft = 600 TextBoxAbstandHoehe = TextBoxHeight + 150 TextBoxAbstandBreite = TextBoxWidth + 900 TextBoxContainerTop = 600 TextBoxContainerBottom = 1600 TextBoxContainerLeft = 600
Label1(0).Alignment = vbRightJustify doIniTextBox Text1(0) doIniLabel Label1(0) doIniVScroll VScroll1, Picture1 TextBoxFrameTotalHeight = FrameTotalHeight doIniPictureContainer Picture1 doIniFrameContainer Frame1, Picture1, VScroll1 doIniTextBoxen Text1 doIniLabels Label1
For i = 0 To TextBoxAnzahl - 1 Text1(i).Text = "Feld " & i
Next
For i = 0 To TextBoxAnzahl - 1 Label1(i).Caption = Format(i, "000")
Next
For i = 0 To Text1.Count - 1 Text1(i).TabIndex = i
Next
Picture1.TabStop = False
VScroll1.TabStop = False
End Sub
Private Sub Form_Resize()
Dim h As Single
If Me.WindowState = vbMinimized Then
Exit Sub
End If
doResizeControls Picture1, Frame1, VScroll1
End Sub
Private Sub Text1_GotFocus(Index As Integer)
doScroll Text1(Index), Picture1, Frame1, VScroll1
Text1(Index).BackColor = vbYellow
End Sub
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).BackColor = vbWhite
End Sub
Private Sub VScroll1_Change()
Form_Resize
End Sub
Private Sub doIniTextBox(TBox As TextBox)
With TBox
Set .Container = Frame1
.Width = TextBoxWidth
.Height = TextBoxHeight
.Top = TextBoxAbstandHoehe - TextBoxHeight
.Left = TextBoxLeft
End With
End Sub
Private Sub doIniLabel(Lab As Label)
With Lab
Set .Container = Frame1
.Width = LabelWidth
.Height = TextBoxHeight - 60
.Top = TextBoxAbstandHoehe - TextBoxHeight + 60
.Left = LabelLeft
End With
End Sub
Private Sub doIniVScroll(VScroll As VScrollBar, PictureContainer As PictureBox)
With VScroll
Set .Container = PictureContainer
.Width = 255
.Top = 0
.Min = 0
.Max = TextBoxAnzahl \ TextBoxAnzahlQuer - 1
.LargeChange = 50
.SmallChange = 20
End With
End Sub
Private Function FrameTotalHeight() As Long
FrameTotalHeight = (TextBoxAbstandHoehe - TextBoxHeight) * 2 + _
TextBoxAbstandHoehe * TextBoxAnzahl / TextBoxAnzahlQuer
End Function
Private Sub doIniPictureContainer(PictureContainer As PictureBox)
With PictureContainer
.BorderStyle = 1
.Width = TextBoxAbstandBreite * TextBoxAnzahlQuer + _
VScroll1.Width - TextBoxLeft + 600
.Top = TextBoxContainerTop
.Left = TextBoxContainerLeft
End With
End Sub
Private Sub doIniFrameContainer(FrameContainer As Frame, _
PictureContainer As PictureBox, _
VScroll As VScrollBar)
With FrameContainer
.BorderStyle = 0
.Caption = ""
Set .Container = PictureContainer
.Height = Me.ScaleHeight
.Width = PictureContainer.ScaleWidth - VScroll.Width - 90
.Top = 0
.Left = 0
End With
End Sub
Private Sub doIniTextBoxen(TBox As Object)
Dim i As Long
Dim j As Long
Dim k As Long
For i = 0 To TextBoxAnzahl - 1 Step TextBoxAnzahlQuer
For j = 0 To TextBoxAnzahlQuer - 1
If i + j > 0 Then
Load TBox(i + j)
With TBox(i + j)
.Visible = True
k = Abs(i + j) \ TextBoxAnzahlQuer
.Top = TBox(0).Top + k * TextBoxAbstandHoehe
If j > 0 Then
.Left = .Left + (TextBoxAbstandBreite) * j
End If
End With
End If
Next
Next
End Sub
Private Sub doIniLabels(Lab As Object)
Dim i As Long
Dim j As Long
Dim k As Long
For i = 0 To TextBoxAnzahl - 1 Step TextBoxAnzahlQuer
For j = 0 To TextBoxAnzahlQuer - 1
If i + j > 0 Then
Load Lab(i + j)
With Lab(i + j)
.Visible = True
k = Abs(i + j) \ TextBoxAnzahlQuer
.Top = Lab(0).Top + k * TextBoxAbstandHoehe
If j > 0 Then
.Left = .Left + (TextBoxAbstandBreite) * j
End If
End With
End If
Next
Next
End Sub
Private Sub doResizeControls(PictureContainer As PictureBox, _
FrameContainer As Frame, VScroll As VScrollBar)
Dim h As Single
With PictureContainer .Height = Me.ScaleHeight - .Top - TextBoxContainerBottom
End With
With FrameContainer If TextBoxAbstandHoehe > 0 Then
.Height = ((Me.ScaleHeight - PictureContainer.Top - TextBoxContainerBottom) _
\ TextBoxAbstandHoehe) * TextBoxAbstandHoehe
End If
End With
With VScroll .Height = PictureContainer.ScaleHeight
.Left = PictureContainer.ScaleWidth - .Width
h = (TextBoxFrameTotalHeight - FrameContainer.Height) * .Value / .Max
If h > 0 Then
h = (h \ TextBoxAbstandHoehe) * TextBoxAbstandHoehe
End If
FrameContainer.Top = h * -1 If h > 0 Then
FrameContainer.Height = FrameContainer.Height + h
End If
End With
End Sub
Public Sub doScroll(TBox As TextBox, PictureContainer As PictureBox, _
FrameContainer As Frame, VScroll As VScrollBar)
Dim i As Long
If TBox.Top + TBox.Height + FrameContainer.Top > PictureContainer.Height Then
Do
i = VScroll.Value + 1
If i > VScroll.Max Then
i = VScroll.Max
End If
VScroll1.Value = i
If TBox.Top + TBox.Height + FrameContainer.Top <= PictureContainer.Height Then
Exit Do
End If
Loop
ElseIf TBox.Top + FrameContainer.Top < 0 Then
If VScroll.Value = VScroll.Max Then
i = 0
Else
i = VScroll.Value - 1
End If
If i < VScroll.Min Then
i = VScroll.Min
End If
VScroll.Value = i
End If
End Sub
Private Sub VScroll1_Scroll()
Form_Resize
End Sub
|