WinForm實(shí)現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法
本文實(shí)例講述了WinForm實(shí)現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法。分享給大家供大家參考。具體實(shí)現(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); } } } }
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
- C# Winform下載文件并顯示進(jìn)度條的實(shí)現(xiàn)代碼
- winform 實(shí)現(xiàn)控制輸入法
- C#中winform控制textbox輸入只能為數(shù)字的方法
- 在Winform動(dòng)態(tài)啟動(dòng)、控制臺(tái)命令行的方法
- C# WinForm-Timer控件的使用
- C# Winform實(shí)現(xiàn)波浪滾動(dòng)效果
- Winform應(yīng)用程序如何使用自定義的鼠標(biāo)圖片
- C# Winform中如何繪制動(dòng)畫(huà)示例詳解
- C# Winform調(diào)用百度接口實(shí)現(xiàn)人臉識(shí)別教程(附源碼)
- visual studio 2019使用net core3.0創(chuàng)建winform無(wú)法使用窗體設(shè)計(jì)器
- Winform 實(shí)現(xiàn)進(jìn)度條彈窗和任務(wù)控制
相關(guān)文章
Unity 實(shí)現(xiàn)框選游戲戰(zhàn)斗單位的思路詳解
這篇文章主要介紹了Unity 如何實(shí)現(xiàn)框選游戲戰(zhàn)斗單位,本文簡(jiǎn)單介紹如何實(shí)現(xiàn)即時(shí)戰(zhàn)略游戲中框選戰(zhàn)斗單位的功能,需要的朋友可以參考下2022-12-12spreadsheetgear插件屏蔽鼠標(biāo)右鍵的方法
今天用到spreadsheetGear插件,然后右鍵有插件自己的菜單。都是英文的,而且還能打開(kāi)新的窗體。嵌到程序里面,不太合適,所以著手屏蔽2014-02-02.NET中實(shí)現(xiàn)彩色光標(biāo)、動(dòng)畫(huà)光標(biāo)及自定義光標(biāo)的方法
這篇文章主要介紹了.NET中實(shí)現(xiàn)彩色光標(biāo)、動(dòng)畫(huà)光標(biāo)及自定義光標(biāo)的方法,非常實(shí)用的功能,需要的朋友可以參考下2014-08-08將文件夾下所有文件輸出到日志文件中 c#遞歸算法學(xué)習(xí)示例
這篇文章主要介紹了將文件夾下所有文件輸出到日志文件中,通過(guò)這個(gè)示例我們學(xué)習(xí)一下遞歸算法的使用方法2014-01-01如何利用C#正則表達(dá)式判斷是否是有效的文件及文件夾路徑
項(xiàng)目中少不了讀取或設(shè)置文件路徑的功能,如何才能對(duì)輸入的路徑是否合法進(jìn)行判斷呢?下面這篇文章主要給大家介紹了關(guān)于C#利用正則表達(dá)式判斷是否是有效的文件及文件夾路徑的相關(guān)資料,需要的朋友可以參考下2022-04-04C#中Array的存儲(chǔ)結(jié)構(gòu)簡(jiǎn)單介紹
本文將從一個(gè)數(shù)組的基礎(chǔ)操作開(kāi)始,逐步來(lái)推導(dǎo)數(shù)組的在C#基礎(chǔ)操作、數(shù)組在CoreCLR的維護(hù)策略,數(shù)組在C++的內(nèi)存分配等階段具體是如何實(shí)現(xiàn)的,感興趣的朋友跟隨小編一起看看吧2023-11-11