窗体属性中添加Resize事件
事件函数:
private void Form1_Resize(object sender, EventArgs e)
{
dvpRegion roi;
roi = new dvpRegion();
dvpStatus status;
status = DVPCamera.dvpGetRoi(m_handle, ref roi);
pictureBox1.Width = this.Width - pictureBox1.Left;//显示控件宽度=窗口宽度-显示控件左外边距
pictureBox1.Height = this.Height - pictureBox1.Top;//显示控件高度=窗口高度-显示控件左上边距
/*维持图像比例*/
//if (pictureBox1.Width * roi.H > pictureBox1.Height * roi.W)
//{
// pictureBox1.Width = pictureBox1.Height * roi.W / roi.H;
//}
//else
//{
// pictureBox1.Height = pictureBox1.Width * roi.H / roi.W;
//}
}