管理输入光标的 WIN32 API 函数

下面的 API 函数是用来管理输入光标的 API 函数,下面是在使用C#时声明的这些函数:

/// <summary>
/// 参数说明:
///        hwnd   : 要创建光标的控件的句柄
///        hbm    : 一个位图的句柄,如果指定则使用指定的位图来创建光标
///        nWidth : 光标的宽度
///        nHeight: 光标的高度
///    说明:
///        如果指定了 hbm 参数(不为 IntPtr.Zero)时,将忽略 nWidth 和 nHeight 参数
/// </summary>

[DllImport("User32.dll")]
public static extern int CreateCaret(IntPtr hwnd, IntPtr hbm, int nWidth, int nHeight);

/// <summary>
/// 销毁一个光标
/// </summary>

[DllImport("User32.dll")]
public static extern int DestroyCreate();

/// <summary>
/// 取得光标的位置,放到 position 参数中, 在这里 Point 不是 System.Drawing 命名空间下的 Point,
/// 关于这个 Point 的结构,可以参考 MSDN 
/// </summary>

[DllImport("User32.dll")]
public static extern int GetCaretPos(ref Point position);

/// <summary>
/// 设置光标的信位置。参数 x 指定光标的 X 坐标, y 指定光标的 Y 坐标
/// </summary>

[DllImport("User32.dll")]
public static extern int SetCaretPos(int x, int y);

/// <summary>
/// 显示光标, hwnd 指定要显示光标的控件
/// </summary>

[DllImport("User32.dll")]
public static extern int ShowCaret(IntPtr hwnd);

/// <summary>
/// 隐藏光标, hwnd 指定要隐藏光标的控件
/// </summary>

[DllImport("User32.dll")]
public static extern int HideCaret(IntPtr hwnd);

/// <summary>
/// 取得光标闪烁的速度,以毫秒为单位
/// </summary>

[DllImport("User32.dll")]
public static extern int GetCaretBlinkTime();

/// <summary>
/// 设置光标的闪烁速度,以毫秒为单位
/// </summary>

[DllImport("User32.dll")]
public static extern int SetCaretBlinkTime(int milliecond);


MSDN参考连接:MSDN Library/用户界面的设计和开发/Windows管理/Windows User Interface/Resoures/Carets

文章出处:我的网站

posted @ 2004-12-12 16:26  匡匡  阅读(578)  评论(0编辑  收藏  举报