如何工作时与Windows窗体应用程序更改鼠标光标变成一个自定义的? [英] How to change the mouse cursor into a custom one when working with Windows Forms applications?

查看:948
本文介绍了如何工作时与Windows窗体应用程序更改鼠标光标变成一个自定义的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户控件我想从箭头更改鼠标光标,一个手形图标结果
我目前做的是这样的:

In a UserControl I want to change the mouse cursor from the arrow, to a hand icon.
What I currently do is this:

this.Cursor = Cursors.Hand;

这是非常好的,它给了我一个鼠标看起来像这样:

This is very nice, it gives me a mouse cursor looking like this:

不过,这才是我的问题......这显示了手手指状结果
我需要的是一个抓一方面,更多的像这样的:

But here comes my problem... this shows a hand with a pointing finger.
What I need is a "grabbing" hand, more like this one:

我如何做到这一点?,我如何可以加载一个图标文件(.ICO),光标文件(.CUR),或图像文件(png格式),并把它作为鼠标光标?

How do I do this?, How can I load an icon file (.ico), a cursor file (.cur), or image file (.png), and use it as the mouse cursor?

推荐答案

如果你有一个光标文件:

If you have a cursor file:

Cursor myCursor = new Cursor("myCursor.cur");
myControl.Cursor = myCursor;



否则,您必须创建一个:

otherwise you have to create one:

了解自定义光标

这篇关于如何工作时与Windows窗体应用程序更改鼠标光标变成一个自定义的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆