我們自定義控件中可能會有一些光標的使用,比如插入文字和圖片提示,下面是調用WIN32 API的光標用法
Winform控件調用插入點的用法
// 導入處理光標的 Windows 32 位 API
// 創建光標
[DllImport("User32.dll")]
private static extern bool GetCaretPos(ref MyNativePOINT p);
// 導入處理光標的 Windows 32 位 API
// 創建光標
[DllImport("User32.dll")]
private static extern bool CreateCaret(IntPtr hWnd, int hBitmap, int nWidth, int nHeight);
// 設置光標位置
[DllImport("User32.dll")]
private static extern bool SetCaretPos(int x, int y);
// 刪除光標
[DllImport("User32.dll")]
private static extern bool DestroyCaret();
// 顯示光標
[DllImport("User32.dll")]
private static extern bool ShowCaret(IntPtr hWnd);
// 隱藏光標
[DllImport("User32.dll")]
private static extern bool HideCaret(IntPtr hWnd);