日期:2014-05-18 浏览次数:21187 次
1、两个预览窗口的定义,是Form
 /// <summary>
        /// 预览窗口
        /// </summary>
        private ImageFrm m_ifrm = new ImageFrm();
        /// <summary>
        /// 预览窗口
        /// </summary>
        private ImageFrm1 m_ifrm1 = new ImageFrm1();
2、在主窗口的Load,初始化他们,这两个窗口会停止主窗口的右侧
/// <summary>
        /// Load...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DiaryFrm_Load(object sender, EventArgs e)
        {            
                    
            this.m_ifrm.Location = new Point(this.Location.X + this.Width, this.Location.Y);
            this.m_ifrm.Owner = this;
            this.m_ifrm.Show();
            this.m_ifrm1.Location = new Point(this.Location.X + this.Width, this.Location.Y + this.m_ifrm.Height);
            this.m_ifrm1.Owner = this;
            this.m_ifrm1.Show();
加载两个事件
this.LocationChanged += new EventHandler(DiaryFrm_LocationChanged);
            this.SizeChanged += new EventHandler(DiaryFrm_SizeChanged);     
}
3、事件代码
/// <summary>
        /// Size Changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DiaryFrm_SizeChanged(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                
            }
            else
            if (this.WindowState == FormWindowState.Maximized)
            {
                
                this.m_ifrm.Location = new Point((this.Location.X + this.Width) - this.m_ifrm.Width - 20, this.Location.Y + SystemInformation.CaptionHeight + SystemInformation.ToolWindowCaptionHeight);
                
                this.m_ifrm1.Location = new Point((this.Location.X + this.Width) - this.m_ifrm.Width - 20, this.Location.Y + this.m_ifrm.Height + SystemInformation.CaptionHeight + SystemInformation.ToolWindowCaptionHeight);
            }
            else
            {
                
                this.m_ifrm.Location = new Point(this.Location.X + this.Width, this.Location.Y);
                
                this.m_ifrm1.Location = new Point(this.Location.X + this.Width, this.Location.Y + this.m_ifrm.Height);
            }
        }
        /// <summary>
        /// Location Changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DiaryFrm_LocationChanged(object sender, EventArgs e)
        {
            if (this.WindowState != FormWindowState.Maximized)
            {
                this.m_ifrm.Location = new Point(this.Location.X + this.Width, this.Location.Y);
                this.m_ifrm1.Location = new Point(this.Location.X + this.