专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »DotNet » 鼠标图标:c#定义鼠标为指定的动画图标 »正文

鼠标图标:c#定义鼠标为指定的动画图标

来源: 发布时间:星期五, 2009年1月9日 浏览:14次 评论:0
  在Windows窗体中通过设置Control控件属性无法将鼠标设置为动画图标形式如果要实现该功能可以通过APILoadCursorFromFile和SetClassLong实现这两个声明代码如下:

[DllImport("user32", EntryPo = "LoadCursorFromFile")]
    public extern LoadCursorFromFile( lpFileName);
    [DllImport("user32", EntryPo = "SetCursor")]
    public extern void SetCursor( hcur, i);
  注意:API需要导入using .Runtime.InteropServices命名空间   举例  定义鼠标为指定动画图标

  本举例实现运行时候当鼠标移动到窗体上时鼠标显示动画效果

  主要代码如下

private void frmPicut_Load(object sender, EventArgs e)
    {
       reportPath = Application.StartupPath.Sub(0, Application.StartupPath.Sub(0,
    Application.StartupPath.LastIndexOf("")).LastIndexOf(""));
      reportPath @"sl3210mouse.ani";
       cur = LoadCursorFromFile(reportPath);
      SetCursor(cur, 32512);
    }
    private void frmPicut_FormClosing(object sender, FormClosingEventArgs e)
    {
       cur = LoadCursorFromFile(@"C:WINDOWSCursorsarrow_m.cur");
      SetCursor(cur, 32512);    }


0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: