本帖最后由 heyheyyoyo 于 2012-12-16 19:28:55 编辑

解决方案 »

  1.   

    鼠标移动事件是看得网上的 不过效果不是很好 建议用windows API来做
    public partial class Form7 : Form
        {
            int with, height;        Point downPoint;        Rectangle downRectangle;        Rectangle lastRectangle;        public Form7()
            {
                InitializeComponent();
            }        private void Form7_Load(object sender, EventArgs e)
            {
                //获取图片框的宽高
                this.with = this.pictureBox1.Width;
                this.height = this.pictureBox1.Height;
            }
            
            /// <summary>
            /// 单击事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void pictureBox1_Click(object sender, EventArgs e)
            {
                //如果当前图片框的宽高大于初始的宽高 说明已放大 则还原初始大小
                if(this.pictureBox1.Width > this.with && this.pictureBox1.Height > this.height)
                {
                    this.pictureBox1.Width = this.with;
                    this.pictureBox1.Height = this.height;
                }
            }
            
            /// <summary>
            /// 双击放大 宽高各增加50像素
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void pictureBox1_DoubleClick(object sender, EventArgs e)
            {
                this.pictureBox1.Width += 50;
                this.pictureBox1.Height += 50;
            }        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button != System.Windows.Forms.MouseButtons.Right)
                    return;
                downPoint = e.Location;
                downRectangle = new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height);
                downRectangle.Offset(this.pictureBox1.PointToScreen(new Point(0, 0)));
                ControlPaint.DrawReversibleFrame(downRectangle, Color.White, FrameStyle.Thick);
                lastRectangle = downRectangle;
            }        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button != System.Windows.Forms.MouseButtons.Right)
                    return;
                ControlPaint.DrawReversibleFrame(lastRectangle, Color.White, FrameStyle.Thick);
                Rectangle rectangle = downRectangle;
                rectangle.Offset(e.X - downPoint.X, e.Y - downPoint.Y);
                ControlPaint.DrawReversibleFrame(rectangle, Color.White, FrameStyle.Thick);
                lastRectangle = rectangle;
            }        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
            {
                if (e.Button != System.Windows.Forms.MouseButtons.Right)
                    return;            ControlPaint.DrawReversibleFrame(lastRectangle, Color.White, FrameStyle.Thick);
                pictureBox1.Location = new Point(((Control)sender).Location.X + e.X - downPoint.X,((Control)sender).Location.Y + e.Y - downPoint.Y);
            }
        }
      

  2.   


    TAT。我在看你给的代码~~~好长好长。。呜呜呜简直是要疯了
      

  3.   

    我比较笨嘛。。又刚学TAT。好困可以明天再写么。
      

  4.   


    我想问呢。有没有一个东西可以直接用来控制双击。比如说我举个例子哈。if (e.Button == MouseDoubleClick)像这样的可以写在条件句啊类似句子里的。。(当然标红的这个是错的。。我瞎编的)
      

  5.   

    很有悟性嘛、
    MouseDoubleClick你可以想成是一个变量、
    当你触发双击事件的时候就把一个值赋给它、
    然后if (e.Button == 你赋给的值(MouseDoubleClick))
      

  6.   

    嗷嗷嗷怎么解释。。
    就是像  if (e.Button == MouseButtons.Left) 里的MouseButtons.Left是一个事件直接控制击左键,
    有没有一个事件可以直接控制双击的。。而不用再     private void pictureBox1_DoubleClick(object sender, EventArgs e)   这样写。。
      

  7.   


    嘿嘿嘿不要夸我我笨得要死~~~ >w<..
    唔可是e.Buttou是可以随便赋值的?如果不是系统内自己包含的事件。我自己赋的值怎么让e.Button响应。?
      

  8.   

    在click事件里判断一下是不是鼠标左键点击的
      

  9.   


    可是如果用if (e.Button == MouseButtons.Left)。。来判断它会报错因为头上那个是private void pictureBox1_DoubleClick(object sender, EventArgs e)不是MouseEventArgs e。了可是除了那样判断其他的我就不会了
      

  10.   


    确实是呢。TAT没想到。可是用本本的话木有滚轮。。
      

  11.   

    把pictureBox1_Click和pictureBox1_DoubleClick这两个事件去掉 换成下面这两个/// <summary>
            /// 鼠标单击事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
            {
                //判断是否是按的鼠标左键 避免按到右键误操作
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    //如果当前图片框的宽高大于初始的宽高 说明已放大 则还原初始大小
                    if (this.pictureBox1.Width > this.with && this.pictureBox1.Height > this.height)
                    {
                        this.pictureBox1.Width = this.with;
                        this.pictureBox1.Height = this.height;
                    }
                }
            }        /// <summary>
            /// 鼠标双击事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                //判断是否是按的鼠标左键
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    this.pictureBox1.Width += 50;
                    this.pictureBox1.Height += 50;
                }
            }
      

  12.   


    讷~!我竟然忘记了还有mouseclick这个东西!!!!!!!!!太谢谢您啦!!!!!!!!!!!!~~~~~~~不过我觉得36#的大哥说得对~~忽忽~~不过我想做的终于是实现了~~!!!!谢谢大家!!!!!