pictureBox里用滚轮实现 放大缩小功能

        [DllImport("user32.dll")]
        public static extern int WindowFromPoint(int xPoint, int yPoint);

        void Form1_MouseWheel(object sender, MouseEventArgs e)
        {
            System.Drawing.Point p = PointToScreen(e.Location);
            if (WindowFromPoint(p.X, p.Y) == pictureBox1.Handle.ToInt32())
            {

                //向前
                if (e.Delta > 0)
                {
                    float w = this.pictureBox1.Width * 0.9f; //每次縮小 20%  
                    float h = this.pictureBox1.Height * 0.9f;
                    this.pictureBox1.Size = Size.Ceiling(new SizeF(w, h));

                }

                //向后
                else if (e.Delta < 0)
                {

                    float w = this.pictureBox1.Width * 1.1f; //每次放大 20%
                    float h = this.pictureBox1.Height * 1.1f;
                    this.pictureBox1.Size = Size.Ceiling(new SizeF(w, h));
                    pictureBox1.Invalidate();

                }
            }
        }

阅读更多
文章标签: float object user
个人分类: c#
想对作者说点什么? 我来说一句

VB picturebox坐标轴 平移 缩放

2016年08月14日 4KB 下载

没有更多推荐了,返回首页

不良信息举报

pictureBox里用滚轮实现 放大缩小功能

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭