網路城邦
上一篇 回創作列表 下一篇   字體:
誰來幫我除錯
2009/11/21 20:05:40瀏覽772|回應3|推薦5

學VC#碰到兩個問題,對照程式碼跟書上完全一樣

也沒有偵測到錯誤,可是我的就是不跑,書上光碟範例會跑

我把我的整個專案上傳了

http://rapidshare.de/files/48715036/C.zip.html

底下是程式碼,有誰可以教我?

一、這是要讓滑鼠點就會出現圖形的

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Point[] pt = new Point[100];
        int pt_index = -1;
        Image img = Properties.Resources.STBZ055;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (pt_index < pt.Length)
            {
                pt_index++;
                pt[pt_index] = new Point(e.X, e.Y);
            }
            this.Invalidate();
        }
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 0; i <= pt_index; i++)
            {
                e.Graphics.DrawImage(img,
                    pt[i].X - img.Width / 2, pt[i].Y - img.Height / 2,
                    img.Width, img.Height);
            }
        }

    }
}


二、這是要跑出直線的程式

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 1; i <= 20; i++)
            {
                if (i % 2 == 0)
                    e.Graphics.DrawLine(Pens.Red, i * 20, 30, i * 20, 100);
                else
                    e.Graphics.DrawLine(Pens.Black, i * 20, 50, i * 20, 100);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

( 心情隨筆心情日記 )
推薦文章 列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=Piner&aid=3519096

 回應文章

鳳彩翎:阿9公然侮辱
等級:8
留言加入好友
樓下高月一輝貴賓
2009/11/23 12:03

  

我還是沙攏哞(台灣話)溜

    


ABay
等級:8
留言加入好友
THANKS
2009/11/22 17:58

感激不盡



高月:流觴亭阿9(九)公然侮辱
等級:7
留言加入好友
Handler
2009/11/22 16:05
private void Form1_Load(object sender, EventArgs e)
     {
     this.Paint += new PaintEventHandler(Form1_Paint);
     }