a 首先添加一个ContextMenuStrip,写两个菜单“全屏显示”和“取消全屏”,写菜单的MousDown事件如下:
        private void 全屏显示ToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
        {
            
this.TopMost = true;
            
this.FormBorderStyle = FormBorderStyle.None;
            
this.WindowState = FormWindowState.Maximized;
            FillScreenbtn.Text 
= "退出全屏";
        }

        
private void 退出全屏ToolStripMenuItem_MouseDown(object sender, MouseEventArgs e)
        {
            
this.TopMost = false;
            
this.FormBorderStyle = FormBorderStyle.Sizable;
            
this.WindowState = FormWindowState.Normal;
            FillScreenbtn.Text 
= "全屏";
        }
然后写鼠标的右击事件,由于我把picturebox控件在父窗口停靠了,所以就写picturebox的事件,如下:
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            
if (e.Button == MouseButtons.Right && FillScreenbtn.Text == "全屏")
            {
                退出全屏ToolStripMenuItem.Enabled 
= false;
                全屏显示ToolStripMenuItem.Enabled 
= true;
            }
            
else
            {
                退出全屏ToolStripMenuItem.Enabled 
= true;
                全屏显示ToolStripMenuItem.Enabled 
= false;
            }
        }
其中FillScreenbtn只是作为是否全屏的一个标识。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-02-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
相关资源
相似解决方案