Hallo Rainer,
als Container kannst du eine Picturebox oder ein Frame-Control
verwenden. Das Frame kennt nur Twips als Einheit. Dann musst
du alle Pixel in Twips umrechnen. Bei der Picturebox kannst
du Pixel als Einheit einstellen. Es gibt hier auch einen
Tipp dazu. Muss man noch etwas anpassen:
https://www.vbarchiv.net/tipps/details.php?id=328
Alternative wäre ein MSFlexgrid. Probier mal dies:
Controls:
1 * MSFlexgrid (MSFlexgrid1)
1 * Picturebox (Picture1)
Private flg1 As Boolean
Private PicLst() As StdPicture
Private Sub Form_Load()
Me.MousePointer = vbHourglass
Me.ScaleMode = vbPixels
Me.KeyPreview = True
Randomize
flg1 = False
End Sub
Private Sub Form_Activate()
If flg1 = True Then Exit Sub
flg1 = True
DoEvents
Call FillGrid
Me.MousePointer = vbDefault
End Sub
Private Sub FillGrid()
Dim SW&, SH&, i&, j&, Farben&
Farben = 32
ReDim PicLst(Farben - 1)
SW = 68
SH = 40
With Picture1
.Visible = False
.BorderStyle = vbBSNone
.Move 0, 0, 68, 40
.ScaleMode = vbPixels
.BackColor = vbButtonFace
.AutoRedraw = True
.FillStyle = vbFSSolid
For i = 0 To Farben - 1
.Cls
Picture1.Line (0, SH / 2)-Step(SW, 0), vbRed
.FillColor = Rnd * &HFFFFFF
Picture1.Circle (SW / 2, SH / 2), 19, vbBlack
Set PicLst(i) = .Image
Next i
.Cls
End With
With MSFlexGrid1
.Redraw = False
.Move 0, 0, 1100, 650
.ScrollTrack = True
.WordWrap = True
'.GridLines = flexGridNone ' Gitter ja/nein
.FixedRows = 1
.FixedCols = 1
.BackColor = Picture1.BackColor
.ForeColor = vbWhite
.Cols = 35
.Rows = 20
.ScrollBars = flexScrollBarBoth
.RowHeight(-1) = 44 * Screen.TwipsPerPixelY
.ColWidth(-1) = 70 * Screen.TwipsPerPixelX
.TextArray(0) = "Plan"
For i = 1 To .Cols - 1
.TextArray(i) = "Station " & CStr(i)
Next i
For i = 1 To .Rows - 1
.TextMatrix(i, 0) = "Linie " & CStr(i) & vbCr & _
Choose(1 + (i Mod 4), "Bahnhof", "Rathaus", "Museum", "Stadion")
Next i
For i = 1 To .Rows - 1
.Row = i
For j = 1 To .Cols - 1
.Col = j
.Text = CStr(Int(Rnd * 16)) & " P."
.CellAlignment = flexAlignCenterCenter
.CellPictureAlignment = flexAlignCenterCenter
Set .CellPicture = PicLst(Int(Rnd * Farben))
Next j
Next i
.Row = .FixedRows
.Col = .FixedCols
.Redraw = True
End With
Screen.MousePointer = vbDefault
End Sub
Private Sub MSFlexGrid1_Click()
Dim r&, c&, N&
With MSFlexGrid1
r = .Row
c = .Col
N = Val(.TextMatrix(r, c))
End With
MsgBox "Linie: " & CStr(r) & vbCr & "Station: " & CStr(c) & vbCr & _
"Personen: " & CStr(N), vbInformation + vbOKOnly, App.Title
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyReturn
Call MSFlexGrid1_Click
Case vbKeyEscape
Unload Me
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSFlexGrid1.Clear
Erase PicLst
End Sub Gruss,
Zardoz |