All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
实现基于事件通知的.Net套接字_[Asp.Net教程]
程序开发者使用最多的五个PHP工具_php资料_编程技术
十天学会ASP.net,第三天_.net资料_编程技术
WML Script标准函数库_[XML教程]
ASP.NET正则表达式集合_[Asp.Net教程]
十六 有害的标签 Bad Tags_[Html教程]
PHP实现简单线性回归之数学库的重要性_[PHP教程]
GridView中实现并列排名的例子_[Asp.Net教程]
百分百的弹出窗口_JavaScript技术_编程技术
ASP.NET2.0数据库之SQL,Server安全性_[Asp.Net教程]
Reading number is top 10 pictures
西游日记4
Original author said, this is the Hengyang people
NeedWallpaper10
NeedWallpaper6
Terrorist smile the largest human history an explosion2
The real super beauty13
9.3阅兵全景图4-陸海空现代化兵种方阵梯队
BingBingFan apple dew point photo gallery3
So beauty, will let you spray blood1
I also want to live a June 1 children's day, dad
Download software ranking
Tram sex maniac 2 (H) rar bag19
Unix video tutorial17
matrix1
终极变速大师Speeder3.26
Tram sex maniac 2 (H) rar bag9
WebService在.NET中的实战应用教学视频 → 第2集
Such love down(擒爱记)
Boxer's Top ten classic battle5
1400篇各类破解文章
Sora aoi, the nurse, uniform ,nursing assistant
qq published in(发表于) 2014/7/11 9:19:30 Edit(编辑)
C#中定义鼠标指针为指定的图片实例

C#中定义鼠标指针为指定的图片实例

C#中定义鼠标指针为指定的图片实例|方法

定义鼠标指针为指定的图片

除了定义鼠标指针为指定的形状之外,还可以将鼠标指针定义为指定的图片。将鼠标指针定义为指定图片的方法非常简单,即将Cursor属性设置为指定鼠标指针样式的图片即可。

示例

定义鼠标为指定图片

本示例通过设置窗体的Cursor属性,在窗体上显示指定图片样式的鼠标指针形状。示例运行结果如图1所示。

程序主要代码如下:

private void button1_Click(object sender, EventArgs e)

{

this.Cursor = new Cursor("a.cur");

}

注意:a.cur是鼠标文件图片。

完整程序代码如下:

★ ★★★★frmMouseImage.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _2_02

{

public partial class frmMouseImage : Form

{

public frmMouseImage()

{

InitializeComponent();

}

private void frmMouseImage_Load(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

string reportPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,

Application.StartupPath.LastIndexOf("")).LastIndexOf(""));

reportPath += @"a.cur";

this.Cursor = new Cursor(reportPath);

}

private void button2_Click(object sender, EventArgs e)

{//本教程来自:http://www.isstudy.com

}

}

}

★ ★★★★frmMouseImage.Designer.cs窗体设计文件完整程序代码网站源代码★★★★★

namespace _2_02

{

partial class frmMouseImage

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(60, 12);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(132, 23);

this.button1.TabIndex = 0;

this.button1.Text = "自定义图片";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// frmMouseImage

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(292, 128);

this.Controls.Add(this.button1);

this.Name = "frmMouseImage";

this.Text = "frmMouseImage";

this.Load += new System.EventHandler(this.frmMouseImage_Load);

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;

}

}

★ ★★★★Program.cs主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _2_02

{

static class Program

{//本教程来自:http://www.isstudy.com

///

/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmMouseImage());

}

}

}



图1 定义鼠标指针形状为指定图片




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.