这个就是调用系统的插字符方法,另外还有GetCaretBlinkTime和SetCaretBlinkTime两个方法,记得在窗体获取焦点的时候创建插字符,窗体失去焦点时销毁插字符
[DllImport("user32.dll")]
static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
[DllImport("user32.dll")]
static extern bool ShowCaret(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool SetCaretPos(int x, int y);
[DllImport("user32.dl")]
static extern bool DestoryCaret(IntPtr hWnd);