WinForm實現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法
更新時間:2015年08月27日 12:39:59 作者:我心依舊
這篇文章主要介紹了WinForm實現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法,涉及C#實現(xiàn)WinForm窗體全屏顯示的實現(xiàn)及調(diào)用技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了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è)計有所幫助。
您可能感興趣的文章:
- C# Winform下載文件并顯示進度條的實現(xiàn)代碼
- winform 實現(xiàn)控制輸入法
- C#中winform控制textbox輸入只能為數(shù)字的方法
- 在Winform動態(tài)啟動、控制臺命令行的方法
- C# WinForm-Timer控件的使用
- C# Winform實現(xiàn)波浪滾動效果
- Winform應(yīng)用程序如何使用自定義的鼠標圖片
- C# Winform中如何繪制動畫示例詳解
- C# Winform調(diào)用百度接口實現(xiàn)人臉識別教程(附源碼)
- visual studio 2019使用net core3.0創(chuàng)建winform無法使用窗體設(shè)計器
- Winform 實現(xiàn)進度條彈窗和任務(wù)控制
相關(guān)文章
Unity 實現(xiàn)框選游戲戰(zhàn)斗單位的思路詳解
這篇文章主要介紹了Unity 如何實現(xiàn)框選游戲戰(zhàn)斗單位,本文簡單介紹如何實現(xiàn)即時戰(zhàn)略游戲中框選戰(zhàn)斗單位的功能,需要的朋友可以參考下2022-12-12.NET中實現(xiàn)彩色光標、動畫光標及自定義光標的方法
這篇文章主要介紹了.NET中實現(xiàn)彩色光標、動畫光標及自定義光標的方法,非常實用的功能,需要的朋友可以參考下2014-08-08將文件夾下所有文件輸出到日志文件中 c#遞歸算法學(xué)習(xí)示例
這篇文章主要介紹了將文件夾下所有文件輸出到日志文件中,通過這個示例我們學(xué)習(xí)一下遞歸算法的使用方法2014-01-01