打印预览TopMost问题

想要实现打印预览始终居于最上边,发现有个问题,只要弹出了打印预览,结果连点击QQ都没有反映了,因为打印预览挡住了QQ的弹出框。于是修改如下,在打印预览有焦点时,TopMost=true,失去焦点时TopMost=false.

 PrintPreviewDialog PrnPreView = new PrintPreviewDialog();
                PrnPreView.PrintPreviewControl.Zoom = 1; 
                PrnPreView.StartPosition = FormStartPosition.CenterScreen;
                PrnPreView.WindowState = FormWindowState.Maximized;
              
                PrnPreView.Icon = DesignNewForms.Print.Properties.Resources.z1;
                PrnPreView.MinimizeBox = false;                   
                PrnPreView.TopLevel = true;
                PrnPreView.ShowIcon = true;
                PrnPreView.ShowInTaskbar = true;
                PrnPreView.TopMost = true;
                PrnPreView.Activated += (s, arg) =>
                {
                    PrnPreView_Activated(PrnPreView, arg);
                };
                PrnPreView.LostFocus += (s, arg) =>
                {
                    PrnPreView_LostFocus(PrnPreView, arg);
                };
                PrnPreView.Deactivate += (s, arg) =>
                {
                    PrnPreView_Deactivate(PrnPreView, arg);
                };
                PrnPreView.Focus();
                PrnPreView.ShowDialog(); 
 private void PrnPreView_Activated(PrintPreviewDialog PrnPreView, EventArgs e)
        {          
            PrnPreView.TopMost = true;
        }
        private void PrnPreView_Deactivate(PrintPreviewDialog PrnPreView, EventArgs e)
        {          
            PrnPreView.TopMost = false;
        }
        private void PrnPreView_LostFocus(PrintPreviewDialog PrnPreView, EventArgs e)
        {          
            PrnPreView.TopMost = false;
        }

 

你可能感兴趣的:(CS编辑器,.net,C#)