Niečo som vypotil a funguje to, až na jednú vec. Neviem vyriešiť ako zmeniť kurzor myši pri nabehnutí na časť textu. Potreboval by som index (dĺžku textu) pozicie kurzora myši v RitchTextBox-e
Private Sub RichTextBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.MouseHover
A tu je môj kód. Dúfam, že niekto mi napíše, ako sa to dalo riešť jediným kliknutím. Príjemný večer
Public Class Form1
Dim i, j, k, m As Integer
Dim iOdkaz(100) As Integer
Dim sURL(100) As String
Dim bCTRL As Boolean
Private Sub RichTextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
'Nacita a ulozi indexy zaciatku a konca webovych adries
Do While RichTextBox1.Text.IndexOf("<htt", i) > -1
i = Me.RichTextBox1.Text.IndexOf("<htt", i)
j = Me.RichTextBox1.Text.IndexOf(">", i)
Me.RichTextBox1.Select(i + 8, j - i - 8)
sURL(k) = Me.RichTextBox1.SelectedText
'Nacita a ulozi indexy koncov odkazov na web stranky
m = i - 1
iOdkaz(k + 1) = m
'Nacita a ulozi indexy zaciatkov odkazov na web stranky
Do
m -= 1
Me.RichTextBox1.Select(m, 1)
Loop While Me.RichTextBox1.SelectionFont.Underline = True
iOdkaz(k) = m
Me.RichTextBox1.Select(iOdkaz(k), iOdkaz(k + 1) - iOdkaz(k))
'Vymaze http odkazy
Me.RichTextBox1.Select(i, j - i + 1)
Me.RichTextBox1.SelectedText = ""
i += 1
k += 2
Loop
End Sub
'Zapamata si poziciu CTRL klavesy
Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
If e.KeyCode = Keys.ControlKey Then
bCTRL = True
End If
End Sub
Private Sub RichTextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyUp
bCTRL = False
End Sub
'Po stlaceni CTRL a kliknuti mysou na odkaz zobrazi stranku
Private Sub RichTextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseClick
If bCTRL = True Then
For i = 0 To k Step 2
If Me.RichTextBox1.SelectionStart >= iOdkaz(i) And RichTextBox1.SelectionStart <= iOdkaz(i + 1) Then
Me.WebBrowser1.Navigate(sURL(i), "stranka")
End If
Next
End If
End Sub
Private Sub RichTextBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.MouseHover
' Tu by som potreboval kod, ktory by zmenil kurzor mysi.
End Sub
End Class
|