' Vi lägger bara till lite saker i listan som ska hoppa upp
Private Sub Form_Load()
List1.AddItem ""
List1.AddItem ""
List1.AddItem ""
End Sub
' Vi sätter in det man valt från listan i text1
Private Sub List1_Click()
Dim i
i = Text1.SelStart
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) & List1.Text
Text1.SelStart = i + Len(List1.Text)
List1.Visible = False
End Sub
' Skriver man ett < så visar vi listan
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = "<" Then
List1.Visible = True
Dim p As POINTAPI
GetCaretPos p
List1.Left = ScaleX(p.X, vbPixels, vbTwips) + Text1.Left + 60
List1.Top = ScaleY(p.Y, vbPixels, vbTwips) + Text1.Top + ScaleY(Text1.Font.Size, vbPoints, vbTwips) + 60
ElseIf List1.Visible = True Then
List1.Visible = False
End If
End Sub
Sample:
ExGetCaretPos.zip
Size:
2,44 kB