using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace test
{
public partial class Form1 : Form
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
} Graphics g;
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
Cursor.Draw (g ,new Rectangle (e.X,e.Y,10,10));
}
private void Form1_Load(object sender, EventArgs e)
{
g =this.CreateGraphics();
}
}
}
书上的例子,说是实现抓取并显示程序中的鼠标形状,可是我怎么弄也不出来,我错在哪了?谢谢
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace test
{
public partial class Form1 : Form
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
} Graphics g;
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
Cursor.Draw (g ,new Rectangle (e.X,e.Y,10,10));
}
private void Form1_Load(object sender, EventArgs e)
{
g =this.CreateGraphics();
}
}
}
书上的例子,说是实现抓取并显示程序中的鼠标形状,可是我怎么弄也不出来,我错在哪了?谢谢
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Cursor.Draw (this.CreateGraphics() ,new Rectangle (e.X,e.Y,10,10));
}
我在VS.NET2005中运行了,运行之后在窗体表面点击鼠标(左键、右键、中键都可以),就会在窗体表面画出一个鼠标。当然,你直接把这部分代码拷贝的话肯定不行。需要你写的就是三句:
1.Graphics g;
写在类的开始处。2.Cursor.Draw (g ,new Rectangle (e.X,e.Y,10,10));
写在窗体的MouseUp事件中。3.g =this.CreateGraphics();
写在窗体的Load事件中。