作者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
推 ngulin0911:Form1_MouseMove要在InitializeComponent裡設定 07/08 14:11
→ willy01:不好意思....我基礎有點差 有點聽不懂 可以講稍微詳細一點 07/08 14:15
→ willy01:謝謝一樓 我往那個方向下手 問題似乎迎刃而解~~thx 07/08 15:44
→ optimist9266:是笑果不會出現,還是出現例外狀況?你的變數g沒指派 07/08 16:16
→ willy01:謝謝大家幫忙 我問題已經解決哩 07/09 00:42