You can stop the caret blinking using the API function SetCaretBlinkTime(). However, as this is a global setting, you should store the current value when the RTB is entered and then restore it when it's left. Here's some sample code: // add this using directive using System.Runtime.InteropServices; // add these declarations within your form class [DllImport("user32.dll")] static extern uint GetCaretBlinkTime(); [DllImport("user32.dll")] static extern bool SetCaretBlinkTime(uint uMSeconds); const uint INFINITE = 0xFFFFFFFF; uint oldBlinkTime; // add these evenhandlers private void richTextBox1_Enter(object sender, EventArgs e) { oldBlinkTime = GetCaretBlinkTime(); SetCaretBlinkTime(INFINITE); } private void richTextBox1_Leave(object sender, EventArgs e) { SetCaretBlinkTime(oldBlinkTime); } It's possible to create a different caret using the API functions CreateCaret(), ShowCaret() and DeleteCaret(). However, unless you load in a bitmap, I couldn't see any obvious way to create an underscore which could in any case cause a problem if that character were typed into the RTB.
1 answers
You can stop the caret blinking using the API function SetCaretBlinkTime().
However, as this is a global setting, you should store the current value when the RTB is entered and then restore it when it's left.
Here's some sample code:
// add this using directive
using System.Runtime.InteropServices;
// add these declarations within your form class
[DllImport("user32.dll")]
static extern uint GetCaretBlinkTime();
[DllImport("user32.dll")]
static extern bool SetCaretBlinkTime(uint uMSeconds);
const uint INFINITE = 0xFFFFFFFF;
uint oldBlinkTime;
// add these evenhandlers
private void richTextBox1_Enter(object sender, EventArgs e)
{
oldBlinkTime = GetCaretBlinkTime();
SetCaretBlinkTime(INFINITE);
}
private void richTextBox1_Leave(object sender, EventArgs e)
{
SetCaretBlinkTime(oldBlinkTime);
}
It's possible to create a different caret using the API functions CreateCaret(), ShowCaret() and DeleteCaret().
However, unless you load in a bitmap, I couldn't see any obvious way to create an underscore which could in any case cause a problem if that character were typed into the RTB.
answered 2 years ago by:
17279
Thank you.
answered 2 years ago by:
51
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!