コード例 #1
0
        private void capture()
        {
            if (this.now_handle_hwnd == 0)
            {
                MessageBox.Show("请先获取句柄等相关信息");
            }
            else
            {
                Bitmap pic = WindowLike.get_window_pic(new IntPtr(this.now_handle_hwnd), 0, 0);
                if (pic != null)
                {
                    this.now_log = "保存成功" + pic.Width.ToString() + "x" + pic.Height.ToString();

                    this.imageView.Image = pic;

                    FormRect rect = new FormRect();
                    rect = Util.getFormRect(this);

                    //int oldWidth_imageView = this.imageView.Width;
                    //int oldHeight_imageView = this.imageView.Height;
                    //pic = Util.ZoomImage(pic, pic.Width / 5, pic.Height / 5);
                    // 注意先后设置顺序
                    //this.Height = pic.Height - this.imageView.Height + rect.height;
                    //this.Width = pic.Width - this.imageView.Width + rect.width;

                    this.imageView.Height = pic.Height;
                    this.imageView.Width  = pic.Width;
                }
            }
        }
コード例 #2
0
        public static FormRect getFormRect(Form form)
        {
            FormRect rect = new FormRect();

            rect.width  = form.Width;
            rect.height = form.Height;
            return(rect);
        }