1 Option Explicit On 2 Option Strict Off 3 4 Public Class Super_RichTextBox_PanAn : Inherits System.Windows.Forms.RichTextBox 5 6 Private My_Cursor As Cursor 7 8 #Region "----------------> Eventi Super_RichTextBox_PanAn" 9 Public Sub New() 10 11 MyBase.New() 12 Call Me.InitializeComponent() 13 14 End Sub 15 16 Private Sub InitializeComponent() 17 18 With Me 19 20 .AllowDrop = True 21 .ShowSelectionMargin = True 22 23 .AutoWordSelection = True 24 .BorderStyle = BorderStyle.FixedSingle 25 .Dock = DockStyle.Fill 26 .AcceptsTab = True 27 .HideSelection = False 28 .EnableAutoDragDrop = True 29 .ShortcutsEnabled = True 30 .AutoWordSelection = True 31 32 .SelectionIndent = 100 33 34 End With 35 36 End Sub 37 38 Private Sub Super_RichTextBox_PanAn_HandleCreated(sender As Object, e As System.EventArgs) Handles MyBase.HandleCreated 39 40 My_Cursor = New Cursor(My.Resources.Cursor_Icon_Dx.Handle) 41 42 End Sub 43 44 Private Sub Super_RichTextBox_PanAn_ContentsResized(sender As Object, e As System.Windows.Forms.ContentsResizedEventArgs) Handles MyBase.ContentsResized 45 46 End Sub 47 48 Private Sub Super_RichTextBox_PanAn_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown 49 50 Old_Local_Mouse_Position = Me.PointToClient(System.Windows.Forms.Cursor.Position) 51 Cursor_Shown = False 52 53 End Sub 54 55 #End Region '<------------ Eventi Super_RichTextBox_PanAn 56 57 Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs) 58 59 With Me 60 61 If .SelectionIndent <= 0 Then 62 If Not .ClientRectangle.Contains(e.Location) Then 63 .Capture = False 64 ElseIf Not .Capture Then 65 .Capture = True 66 End If 67 End If 68 69 Dim X As Integer = PointToClient(Control.MousePosition).X 70 71 If X <= Me.SelectionIndent Then 72 73 .Capture = True 74 75 If Cursor = My_Cursor Then 'If Cursor = Cursors.Arrow Then 76 GoTo Salto 77 End If 78 79 Cursor = My_Cursor 80 'Cursor = Cursors.Arrow 81 82 Else 83 84 .Capture = False 85 86 If Cursor = Cursors.IBeam Then 87 GoTo Salto 88 End If 89 90 Cursor = Cursors.IBeam 91 92 End If 93 94 Salto: 95 96 97 If Not Me.ClientRectangle.Contains(e.Location) Then 98 Me.Capture = False 99 If Cursor <> Cursors.Default Then 100 Cursor = Cursors.Default 101 End If 102 End If 103 104 Dim LocalMousePosition As Point = Me.PointToClient(System.Windows.Forms.Cursor.Position) 105 106 Dim CaretLoc As Point = Nothing 107 108 If LocalMousePosition <> Old_Local_Mouse_Position Then 109 110 If Cursor_Shown = False Then 111 112 Cursor_Shown = True 113 114 End If 115 116 End If 117 118 End With 119 120 MyBase.OnMouseMove(e) 121 122 End Sub 123 124 #Region "------------------> HideCaret - ShowCaret" 125 Private Property Old_Local_Mouse_Position As Point 126 Private _Cursor_Shown As Boolean = True 127 128 Public Property Cursor_Shown As Boolean 129 Get 130 Return _Cursor_Shown 131 End Get 132 Set(ByVal Value As Boolean) 133 If Value = _Cursor_Shown Then 134 Return 135 End If 136 If Value Then 137 System.Windows.Forms.Cursor.Show() 138 Else 139 System.Windows.Forms.Cursor.Hide() 140 End If 141 _Cursor_Shown = Value 142 End Set 143 End Property 144 145 #End Region '<-------------- HideCaret - ShowCaret 146 147 End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)