WinForm實(shí)現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法
更新時(shí)間:2015年08月27日 12:39:59 作者:我心依舊
這篇文章主要介紹了WinForm實(shí)現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法,涉及C#實(shí)現(xiàn)WinForm窗體全屏顯示的實(shí)現(xiàn)及調(diào)用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(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)畫示例詳解
- C# Winform調(diào)用百度接口實(shí)現(xiàn)人臉識(shí)別教程(附源碼)
- visual studio 2019使用net core3.0創(chuàng)建winform無法使用窗體設(shè)計(jì)器
- Winform 實(shí)現(xiàn)進(jìn)度條彈窗和任務(wù)控制
相關(guān)文章
C#中系統(tǒng)時(shí)間和UNIX時(shí)間戳互相轉(zhuǎn)換
本文主要介紹C#中系統(tǒng)時(shí)間和UNIX時(shí)間戳相互轉(zhuǎn)換的方法,大家可以直接拿去用,希望有用。2016-05-05
基于C#實(shí)現(xiàn)一個(gè)簡單的FTP操作工具
這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)一個(gè)簡單的FTP操作工具,可以實(shí)現(xiàn)FTP上傳、下載、重命名、刷新、刪除功能,感興趣的可以了解一下2022-08-08
C#使用HttpPost請求調(diào)用WebService的方法
這篇文章主要為大家詳細(xì)介紹了C#使用HttpPost請求調(diào)用WebService的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
C#中結(jié)構(gòu)體定義并轉(zhuǎn)換字節(jié)數(shù)組詳解
在寫C#TCP通信程序時(shí),發(fā)送數(shù)據(jù)時(shí),只能發(fā)送byte數(shù)組,處理起來比較麻煩不說,如果是和VC6.0等寫的程序通信的話,很多的都是傳送結(jié)構(gòu)體,在VC6.0中可以很方便的把一個(gè)char[]數(shù)組轉(zhuǎn)換為一個(gè)結(jié)構(gòu)體,而在C#卻不能直接把byte數(shù)組轉(zhuǎn)換為結(jié)構(gòu)體,要在C#中發(fā)送結(jié)構(gòu)體,應(yīng)該怎么做呢?2017-11-11

