blah blah blah is here! blah blah » Close

up0down
link

^ Also is there a way to change the carat from like this | to this _?

last answered 2 years ago

1 answers

up0down
link

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.

up0down
link

Thank you.

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!

Feedback