Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Public Class MyTB : Inherits TextBox
  2. <DllImport("user32.dll", SetLastError:=True)> _
  3. Private Shared Function CreateCaret(ByVal hWnd As IntPtr, ByVal hBitmap As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As Boolean
  4. End Function
  5.  
  6. <DllImport("user32.dll")>
  7. Private Shared Function DestroyCaret() As Boolean
  8. End Function
  9.  
  10. <DllImport("user32.dll")>
  11. Private Shared Function SetCaretBlinkTime(ByVal uMSeconds As UInt32) As Boolean
  12. End Function
  13.  
  14. <DllImport("user32.dll")> _
  15. Private Shared Function ShowCaret(ByVal hWnd As IntPtr) As Boolean
  16. End Function
  17.  
  18. Protected Overrides Sub OnGotFocus(e As EventArgs)
  19. MyBase.OnGotFocus(e)
  20. MyTB.CreateCaret(Me.Handle, Nothing, 5, Me.Font.Height)
  21. MyTB.SetCaretBlinkTime(500UI)
  22. MyTB.ShowCaret(Me.Handle)
  23. End Sub
  24.  
  25. Protected Overrides Sub OnLostFocus(e As EventArgs)
  26. MyBase.OnLostFocus(e)
  27. MyTB.DestroyCaret()
  28. End Sub
  29. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement