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

首頁 > 編程 > C# > 正文

WinForm實現窗體最大化并遮蓋任務欄的方法

2019-10-29 21:38:42
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了WinForm實現窗體最大化并遮蓋任務欄的方法,涉及C#實現WinForm窗體全屏顯示的實現及調用技巧,具有一定參考借鑒價值,需要的朋友可以參考下

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

 

 
  1. using System; 
  2. using System.Windows.Forms; 
  3. using System.Drawing; 
  4. namespace CSImageFullScreenSlideShow 
  5. public class FullScreen 
  6. private FormWindowState winState; 
  7. private FormBorderStyle brdStyle; 
  8. private bool topMost; 
  9. private Rectangle bounds; 
  10. public FullScreen() 
  11. IsFullScreen = false
  12. public bool IsFullScreen 
  13. get; 
  14. set; 
  15. public void EnterFullScreen(Form targetForm) 
  16. if (!IsFullScreen) 
  17. Save(targetForm); // Save the original form state. 
  18. targetForm.WindowState = FormWindowState.Maximized; 
  19. targetForm.FormBorderStyle = FormBorderStyle.None; 
  20. targetForm.TopMost = true
  21. targetForm.Bounds = Screen.GetBounds(targetForm); 
  22. IsFullScreen = true
  23. /// <summary> 
  24. /// Save the current Window state. 
  25. /// </summary> 
  26. private void Save(Form targetForm) 
  27. winState = targetForm.WindowState; 
  28. brdStyle = targetForm.FormBorderStyle; 
  29. topMost = targetForm.TopMost; 
  30. bounds = targetForm.Bounds; 
  31. /// <summary> 
  32. /// Leave the full screen mode and restore the original window state. 
  33. /// </summary> 
  34. public void LeaveFullScreen(Form targetForm) 
  35. if (IsFullScreen) 
  36. // Restore the original Window state. 
  37. targetForm.WindowState = winState; 
  38. targetForm.FormBorderStyle = brdStyle; 
  39. targetForm.TopMost = topMost; 
  40. targetForm.Bounds = bounds; 
  41. IsFullScreen = false

調用:

 

 
  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.ComponentModel; 
  4. using System.Data; 
  5. using System.Drawing; 
  6. using System.Text; 
  7. using System.Windows.Forms; 
  8. namespace CSImageFullScreenSlideShow 
  9. public partial class Test : Form 
  10. public Test() 
  11. InitializeComponent(); 
  12. private FullScreen fullScreen = new FullScreen(); 
  13. private void button1_Click(object sender, EventArgs e) 
  14. if (fullScreen.IsFullScreen) 
  15. fullScreen.LeaveFullScreen(this); 
  16. else 
  17. fullScreen.EnterFullScreen(this); 

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东至县| 营山县| 嵩明县| 盐源县| 绥中县| 巴南区| 新津县| 樟树市| 白河县| 株洲市| 衢州市| 湘潭县| 泸定县| 曲麻莱县| 保康县| 绥德县| 堆龙德庆县| 专栏| 息烽县| 清水河县| 祁阳县| 拜泉县| 陇南市| 洪江市| 五家渠市| 托克逊县| 温州市| 子洲县| 喀喇沁旗| 义马市| 韩城市| 弋阳县| 连南| 衡山县| 福安市| 自治县| 定安县| 肃北| 四平市| 乌兰县| 绥化市|