Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú#Region " [RichTextBox] FindNext "
' [ FindNext ]
'
' //By Elektro H@cker
'
' Examples :
'
' RichTextBox1.Text = "Hello World!, Hello World!, Hello World!"
'
' FindNext(RichTextBox1, "hello", FindDirection.Down, RegexOptions.IgnoreCase, Color.LightBlue, Color.Black)
' FindNext(RichTextBox1, "hello", FindDirection.Up, RegexOptions.IgnoreCase, Color.Red, Color.Black)
'
' Private Sub RichTextBox_Enter(sender As Object, e As EventArgs) ' Handles RichTextBox1.Enter
' ' Restore Selection Colors before search next match.
' sender.SelectionBackColor = DefaultBackColor
' sender.SelectionColor = DefaultForeColor
' End Sub
Public Enum FindDirection
Up = 0
Down = 1
End Enum
' FindNext
Private Sub FindNext(ByVal [Control] As RichTextBox, _
ByVal SearchText As String, _
ByVal Direction As FindDirection, _
Optional ByVal IgnoreCase As System.Text.RegularExpressions.RegexOptions = RegexOptions.None, _
Optional ByVal Highlight_BackColor As Color = Nothing, _
Optional ByVal Highlight_ForeColor As Color = Nothing)
If [Control].TextLength = 0 Then Exit Sub
' Start searching at 'SelectionStart'.
Dim Search_StartIndex As Integer = [Control].SelectionStart
' Stores the MatchIndex count
Dim matchIndex As Integer = 0
' Flag to check if it's first find call
Static First_Find As Boolean = True
' Checks to don't ommit the selection of first match if match index is exactly at 0 start point.
If First_Find _
AndAlso Search_StartIndex = 0 _
AndAlso Direction = FindDirection.Down Then
Search_StartIndex = -1
First_Find = False
ElseIf Not First_Find _
AndAlso Search_StartIndex = 0 _
AndAlso Direction = FindDirection.Down Then
First_Find = False
Search_StartIndex = 0
End If
' Store the matches
Dim matches As System.Text.RegularExpressions.MatchCollection = _
System.Text.RegularExpressions.Regex.Matches([Control].Text, _
SearchText, _
IgnoreCase Or If(Direction = FindDirection.Up, _
RegexOptions.RightToLeft, _
RegexOptions.None))
If matches.Count = 0 Then First_Find = True : Exit Sub
' Restore Highlight colors of previous selection
[Control].SelectionBackColor = [Control].BackColor
[Control].SelectionColor = [Control].ForeColor
' Set next selection Highlight colors
If Highlight_BackColor = Nothing Then Highlight_BackColor = [Control].BackColor
If Highlight_ForeColor = Nothing Then Highlight_ForeColor = [Control].ForeColor
' Set the match selection
For Each match As System.Text.RegularExpressions.Match In matches
matchIndex += 1
Select Case Direction
Case FindDirection.Down
If match.Index > Search_StartIndex Then ' Select next match
[Control].Select(match.Index, match.Length)
Exit For
ElseIf match.Index <= Search_StartIndex _
AndAlso matchIndex = matches.Count Then ' Select first match
[Control].Select(matches.Item(0).Index, matches.Item(0).Length)
Exit For
End If
Case FindDirection.Up
If match.Index < Search_StartIndex Then ' Select previous match
[Control].Select(match.Index, match.Length)
Exit For
ElseIf match.Index >= Search_StartIndex _
AndAlso matchIndex = matches.Count Then ' Select last match
[Control].Select(matches.Item(0).Index, matches.Item(0).Length)
Exit For
End If
End Select
Next match
' Set the current selection BackColor
[Control].SelectionBackColor = Highlight_BackColor
' Set the current selection ForeColor
[Control].SelectionColor = Highlight_ForeColor
' Scroll to Caret/Cursor selection position
[Control].ScrollToCaret()
End Sub
#End Region
#Region " [RichTextBox] FindNext String "
' [ FindNext String ]
'
' //By Elektro H@cker
'
' Examples :
'
' FindNext(RichTextBox1, "Hello", RichTextBoxFinds.MatchCase, Color.LightBlue, Color.Black)
'
' Private Sub RichTextBox_Enter(sender As Object, e As EventArgs) ' Handles RichTextBox1.Enter
' ' Restore Selection Colors before search next match.
' sender.SelectionBackColor = DefaultBackColor
' sender.SelectionColor = DefaultForeColor
' End Sub
' FindNext
Private Sub FindNext(ByVal [Control] As RichTextBox, _
ByVal SearchText As String, _
ByVal IgnoreCase As RichTextBoxFinds, _
Optional ByVal Highlight_BackColor As Color = Nothing, _
Optional ByVal Highlight_ForeColor As Color = Nothing)
' Start searching at 'SelectionStart'.
Dim Search_StartIndex As Integer = [Control].SelectionStart
Static Next_Count As Integer = 0
' Restore Highlight colors of previous selection
[Control].SelectionBackColor = [Control].BackColor
[Control].SelectionColor = [Control].ForeColor
' Set next selection Highlight colors
If Highlight_BackColor = Nothing Then Highlight_BackColor = [Control].BackColor
If Highlight_ForeColor = Nothing Then Highlight_ForeColor = [Control].ForeColor
' If is not first FindNext call then...
If Next_Count <> 0 Then
Search_StartIndex += SearchText.Length
Else ' If is first FindNext call then...
Next_Count += 1
End If
' Set Search_StartIndex
Search_StartIndex = _
[Control].Find(SearchText, Search_StartIndex, IgnoreCase)
' ...And prevent search at End Of File
If Search_StartIndex = -1 Then
Search_StartIndex = _
[Control].Find(SearchText, 0, IgnoreCase)
End If
If Search_StartIndex = -1 Then
Exit Sub ' No matches found
End If
' Set the match selection
[Control].Select(Search_StartIndex, SearchText.Length)
' Set the BackColor
[Control].SelectionBackColor = Highlight_BackColor
' Set the ForeColor
[Control].SelectionColor = Highlight_ForeColor
' Scroll to Caret/Cursor position
[Control].ScrollToCaret()
End Sub
#End Region
RichTextBox1.Select(RichTextBox1.TextLength - 1, 1)
If Not ScrollBarInfo.IsAtBottom(RichTextBox1) Then
RichTextBox1.ScrollToCaret()
End If
Public Class ScrollBarInfo
<System.Runtime.InteropServices.DllImport("user32")> _
Private Shared Function GetScrollInfo(hwnd As IntPtr, nBar As Integer, ByRef scrollInfo As SCROLLINFO) As Integer
End Function
Private Shared scrollInf As New SCROLLINFO()
Private Structure SCROLLINFO
Public cbSize As Integer
Public fMask As Integer
Public min As Integer
Public max As Integer
Public nPage As Integer
Public nPos As Integer
Public nTrackPos As Integer
End Structure
Private Shared Sub Get_ScrollInfo(control As Control)
scrollInf = New SCROLLINFO()
scrollInf.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(scrollInf)
scrollInf.fMask = &H10 Or &H1 Or &H2 'SIF_RANGE = &H1, SIF_PAGE= &H2, SIF_TRACKPOS = &H10
GetScrollInfo(control.Handle, 1, scrollInf)
End Sub
Public Shared Function ReachedBottom(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.max = scrollInf.nTrackPos + scrollInf.nPage
End Function
Public Shared Function ReachedTop(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.nTrackPos < 0
End Function
Public Shared Function IsAtBottom(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.max = (scrollInf.nTrackPos + scrollInf.nPage) - 1
End Function
Public Shared Function IsAtTop(control As Control) As Boolean
Get_ScrollInfo(control)
Return scrollInf.nTrackPos = 0
End Function
End Class
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function SendMessage(hWnd As IntPtr, wMsg As UInteger, wParam As UIntPtr, lParam As IntPtr) As Integer
End Function
' Examples:
'
' SendMessage(RichTextBox1.Handle, &HB6, 0, 1) ' Move 1 line to down
' SendMessage(RichTextBox1.Handle, &HB6, 0, 5) ' Move 5 lines to down
' SendMessage(RichTextBox1.Handle, &HB6, 0, -1) ' Move 1 line to up
' SendMessage(RichTextBox1.Handle, &HB6, 0, -5) ' Move 5 lines to up
CitarDirective Description Example
#EXTM3U File header. Must be the first line of the file! #EXTM3U
#EXTINF Track information, including runtime and title. #EXTINF:191,Artist Name - Track Title