国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

WinForm實現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法

2020-01-24 01:29:39
字體:
供稿:網(wǎng)友

本文實例講述了WinForm實現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

using System;using System.Windows.Forms;using System.Drawing;namespace CSImageFullScreenSlideShow{ public class FullScreen {  private FormWindowState winState;  private FormBorderStyle brdStyle;  private bool topMost;  private Rectangle bounds;  public FullScreen()  {   IsFullScreen = false;  }  public bool IsFullScreen  {   get;   set;  }  public void EnterFullScreen(Form targetForm)  {   if (!IsFullScreen)   {    Save(targetForm); // Save the original form state.    targetForm.WindowState = FormWindowState.Maximized;    targetForm.FormBorderStyle = FormBorderStyle.None;    targetForm.TopMost = true;    targetForm.Bounds = Screen.GetBounds(targetForm);    IsFullScreen = true;   }  }  /// <summary>  /// Save the current Window state.  /// </summary>  private void Save(Form targetForm)  {   winState = targetForm.WindowState;   brdStyle = targetForm.FormBorderStyle;   topMost = targetForm.TopMost;   bounds = targetForm.Bounds;  }  /// <summary>  /// Leave the full screen mode and restore the original window state.  /// </summary>  public void LeaveFullScreen(Form targetForm)  {   if (IsFullScreen)   {    // Restore the original Window state.    targetForm.WindowState = winState;    targetForm.FormBorderStyle = brdStyle;    targetForm.TopMost = topMost;    targetForm.Bounds = bounds;    IsFullScreen = false;   }  } }}

調(diào)用:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace CSImageFullScreenSlideShow{ public partial class Test : Form {  public Test()  {   InitializeComponent();   }  private FullScreen fullScreen = new FullScreen();  private void button1_Click(object sender, EventArgs e)  {   if (fullScreen.IsFullScreen)   {    fullScreen.LeaveFullScreen(this);   }   else   {    fullScreen.EnterFullScreen(this);   }  } }}

希望本文所述對大家的C#程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 昔阳县| 潮州市| 诸暨市| 那曲县| 昭苏县| 沙田区| 湘潭县| 诏安县| 会理县| 高平市| 齐齐哈尔市| 昌都县| 望城县| 花莲市| 隆化县| 大同市| 肃北| 榆树市| 甘泉县| 中山市| 台安县| 和龙市| 新化县| 宁波市| 资源县| 杭锦后旗| 嘉峪关市| 广灵县| 梁山县| 沧州市| 泰宁县| 海南省| 梨树县| 宁德市| 祁东县| 阿城市| 澄迈县| 馆陶县| 务川| 玛纳斯县| 五台县|