[問題] 滑鼠事件

看板C_Sharp作者 (汪洋中的一條狗)時間15年前 (2010/07/08 13:49), 編輯推噓1(105)
留言6則, 4人參與, 最新討論串1/2 (看更多)
因為要做有關滑鼠的程式 以前沒摸過 想先看簡單的範例 來摸索一下 就從網路上看一段簡易的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

07/08 14:11, , 1F
Form1_MouseMove要在InitializeComponent裡設定
07/08 14:11, 1F

07/08 14:15, , 2F
不好意思....我基礎有點差 有點聽不懂 可以講稍微詳細一點
07/08 14:15, 2F

07/08 15:44, , 3F
謝謝一樓 我往那個方向下手 問題似乎迎刃而解~~thx
07/08 15:44, 3F

07/08 16:16, , 4F
是笑果不會出現,還是出現例外狀況?你的變數g沒指派
07/08 16:16, 4F

07/08 17:22, , 5F
請跟著一步一步做:http://ppt.cc/l9OA
07/08 17:22, 5F

07/09 00:42, , 6F
謝謝大家幫忙 我問題已經解決哩
07/09 00:42, 6F
文章代碼(AID): #1CDMRm_L (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #1CDMRm_L (C_Sharp)