1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > c# 控件多屏显示全屏功能

c# 控件多屏显示全屏功能

时间:2023-05-05 13:46:33

相关推荐

c# 控件多屏显示全屏功能

工作中做了个播放的自定义控件,但程序在多屏幕显示器上运行时,全屏后总在主显示器上,查了些资料,做以下总结避免以后走弯路

if (m_FullScreen)

{

MenuItem_Fullscreen.Text = "退出全屏";

if (m_FullSreenSingle) //因为是多播放窗口控件,此处做了其中一个全屏的控制

{

MenuItem_FullscreenSingle.Visible = false;

OldLocalRect.X = UsingPlayer.Left;

OldLocalRect.Y = UsingPlayer.Top;

OldLocalRect.Width = UsingPlayer.Width;

OldLocalRect.Height = UsingPlayer.Height;

UsingPlayer.Dock = DockStyle.Fill;

UsingPlayer.BringToFront();

}

MenuStrip_Players.Refresh();

this.Controls.Clear();

Screen screen = Screen.FromControl(this.Parent); //判断控件所在的屏幕

fullscreenForm = new FullscreenFrom();

fullscreenForm.StartPosition = FormStartPosition.Manual; //此处必须设置为自定义,否则指定的位置无效

fullscreenForm.Controls.Add(pnl_back);

fullscreenForm.DesktopBounds = screen.Bounds;

fullscreenForm.Left = screen.Bounds.Left;

fullscreenForm.Top = screen.Bounds.Top;

fullscreenForm.ShowDialog();

}

else

{

if (fullscreenForm != null)

{

MenuItem_FullscreenSingle.Visible = true;

MenuItem_Fullscreen.Text = "多画面全屏";

MenuStrip_Players.Refresh();

if (m_FullSreenSingle == true)

{

m_FullSreenSingle = true;

UsingPlayer.Dock = DockStyle.None;

UsingPlayer.Left = OldLocalRect.X;

UsingPlayer.Top = OldLocalRect.Y;

UsingPlayer.Width = OldLocalRect.Width;

UsingPlayer.Height = OldLocalRect.Height;

}

fullscreenForm.Controls.Clear();

this.Controls.Add(pnl_back);

fullscreenForm.Close();

fullscreenForm = null;

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。