getting caret
Hi All,
I am a C++ programmer moving to C#. In C++ we can get a caret (not to be confused with the cursor) if we want to. Is it possible to get a caret in C#. I am using it for a text editing program. Any suggestions welcome.
Thnaks.
# 2 Re: getting caret
I am not using a text box at all, nor can I use one. Here is what I would like. The user moves the mouse in the client area of a form. If the user left clicks, then I place the caret there (ideally the caret would be blinking, like in Word) I can do a caret in C++. One would thing C# can to. If it can't, that is a significant drawback for people writing text stuff.
# 3 Re: getting caret
Greetings.
You will find the following win32 functions helpful:
namespace Example
{
public sealed class NativeFunctions
{
private NativeFunctions(){}
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll")]
internal static extern int CreateCarat(IntPtr hWnd, IntPtr hBitmap, int Width, int Height);
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll")]
internal static extern int GetCaratBlinkTime();
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll")]
internal static extern int HideCarat(IntPtr hWnd);
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll")]
internal static extern int SetCaretBlinkTime(int Milliseconds);
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("user32.dll")]
internal static int ShowCarat(IntPtr hWnd);
}
}
This isn't portable, but it works.
Regards.