作者willy01 (汪洋中的一条狗)
看板C_Sharp
标题[问题] 滑鼠事件
时间Thu Jul 8 13:49:33 2010
因为要做有关滑鼠的程式 以前没摸过 想先看简单的范例 来摸索一下
就从网路上看一段简易的CODE 但测试很久 一直不能出现成果
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Graphics g;
int Mdx;
int Mdy;
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
g.DrawLine(Pens.Black,Mdx,Mdy,e.X,e.Y);
Mdx = e.X;
Mdy = e.Y;
}
}
}
}
==========================================================
想问一下 这样打为啥一直效果不能出现.....谢谢有大大可以帮忙一下吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.25.118.131
1F:推 ngulin0911:Form1_MouseMove要在InitializeComponent里设定 07/08 14:11
2F:→ willy01:不好意思....我基础有点差 有点听不懂 可以讲稍微详细一点 07/08 14:15
3F:→ willy01:谢谢一楼 我往那个方向下手 问题似乎迎刃而解~~thx 07/08 15:44
4F:→ optimist9266:是笑果不会出现,还是出现例外状况?你的变数g没指派 07/08 16:16
6F:→ willy01:谢谢大家帮忙 我问题已经解决哩 07/09 00:42