954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HideCaret() Windows API function doesn't work properly

I want to hide the caret in the RichTextBox control and do that with the win api function HideCaret(),but it doesn't work.The cursor is still visible and blinking.Where i should call the function.I tried in the Enter event of the control but doesn't work again.As far as i know i should call the HideCaret() when the RichTextBox gets the focus.Is that right?
Here is the code:

[DllImport("User32.dll")]
static extern Boolean HideCaret(System.IntPtr hWnd);

private void richTextBox1_Enter(object sender, EventArgs e)
{
HideCaret(richTextBox1.Handle);
}

cygnusX
Newbie Poster
15 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

You call this once the control became active, then nothing called after that, I think you should use Observer pattern to keep monitoring your richtextbox, as it selected call this method.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You