-
Dec 19th, 2019, 04:00 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Fill a Textbox with a delay!
Hi,
I have a textbox I need to copy and paste some text into it. You know, once you select the textbox and press CTRL+V the textbox gets all the clipboard's contents within a wink of an eye! I don't want that, I want the textbox to get the contents of the clipboard a character by character (with a delay), so once you press CTRL+V you see the characters getting filled into the textbox from right to left one by one until the textbox gets all the clipboard's contents say after 2 seconds (depending on the contents' length). Any ideas? Thanks.
-
Dec 19th, 2019, 04:58 PM
#2
Re: Fill a Textbox with a delay!
Here's an extended TextBox...
Code:
Public Class TextBoxEx
Inherits TextBox
Const WM_PASTE As Integer = &H302
Private WithEvents tmr As New Timer With {.Interval = 50}
Private pastedText As String
Private charCounter As Integer = 0
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_PASTE Then
pastedText = Clipboard.GetText
charCounter = 0
tmr.Start()
Return
End If
MyBase.WndProc(m)
End Sub
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
If charCounter < pastedText.Length Then
MyBase.Text &= pastedText.Substring(charCounter, 1)
charCounter += 1
Else
tmr.Stop()
End If
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 19th, 2019, 05:24 PM
#3
Thread Starter
Addicted Member
Re: Fill a Textbox with a delay!
Originally Posted by .paul.
Here's an extended TextBox...
Code:
Public Class TextBoxEx
Inherits TextBox
Const WM_PASTE As Integer = &H302
Private WithEvents tmr As New Timer With {.Interval = 50}
Private pastedText As String
Private charCounter As Integer = 0
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_PASTE Then
pastedText = Clipboard.GetText
charCounter = 0
tmr.Start()
Return
End If
MyBase.WndProc(m)
End Sub
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
If charCounter < pastedText.Length Then
MyBase.Text &= pastedText.Substring(charCounter, 1)
charCounter += 1
Else
tmr.Stop()
End If
End Sub
End Class
An idea and a code that puts it into practice? This is more than what I expected!
I have just tested it and it works exactly as I wanted.
Thank you very very much!
-
Dec 19th, 2019, 05:31 PM
#4
Re: [RESOLVED] Fill a Textbox with a delay!
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|