WinForm实现窗体最大化并遮盖任务栏的方法
作者:我心依旧 发布时间:2022-09-19 20:00:19
标签:WinForm,窗体,最大化
本文实例讲述了WinForm实现窗体最大化并遮盖任务栏的方法。分享给大家供大家参考。具体实现方法如下:
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;
}
}
}
}
调用:
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#程序设计有所帮助。


猜你喜欢
- 这周末体验了一下挺火的Docker技术,记录学习笔记。>Docker是干什么的Docker 是一个基于Linux容器(LXC-linu
- 做一个五子棋练练手,没什么特别的,再复习一下自定义View的知识,onMeasure,MeasureSpec , onDraw以及OnTou
- 1.SQL注入:程序向后台数据库传递SQL时,用户提交的数据直接拼接到SQL语句中并执行,从而导入SQL注入攻击。字符型注入:黑色部分为拼接
- 本文实例为大家分享了winform循环播放多个视频的具体代码,供大家参考,具体内容如下环境: vs2015 +winform首先,vs自带组
- 会报错如下:org.springframework.web.util.NestedServletException: Request pro
- 如下所示:public static boolean isSdcardExists(Context context) {StorageMan
- 在android中的webview中,可以对文本内容进行对齐,具体方法如下 public class MainActivity
- 在使用Android Studio开发的时候,如遇到多个项目引用同一个library的情况时,会遇到在每个项目中都要有一套library的代
- java 高并发中volatile的实现原理摘要: 在多线程并发编程中synchronized和Volatile都扮演着重要的角色,Vola
- 在有些开发场景,需要对 List 对象列表进行过滤处理,并将有用的数据存放到Map中。例如:告警对象,包含告警uuid(alarmUuid)
- 为什么需要互斥量在多任务操作系统中,同时运行的多个任务可能都需要使用同一种资源。这个过程有点类似于,公司部门里,我在使用着打印机打印东西的同
- 一、题目描述题目:有五个学生,每个学生有 3 门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),把这些数据存放在磁盘文件 &q
- 一、简介Android的消息机制主要是指Handler的运行机制,那么什么是Handler的运行机制那?通俗的来讲就是,使用Handler将
- 任意位置获取HttpServletRequest对象方法一//获取RequestAttributes RequestAttributes r
- 在逆向一个Android程序时,如果只是盲目的分析需要阅读N多代码才能找到程序的关键点或Hook点,本文将分享一下如何快速的找到APP程序的
- 本文实例为大家分享了Silverlight实现星星闪烁动画展示的具体代码,供大家参考,具体内容如下原理很简单,生成1000个圆,从随机数来布
- Spring Boot 内置Tomcat默认端口号为8080,在开发多个应用调试时很不方便,本文介绍了修改 Spring Boot
- 前言嵌套查询的实现原理为两次查询,比如产品表为主表,图片表为从表通过product_id字段与产品表id字段关联实现一对多,嵌套查询 首先查
- 我们绝大部分人估计都还在用着jdk8,12其实是一个非LTS(long time support)版本,而11与8一样是LTS版,意味着下个
- 本文实例为大家分享了Unity shader实现遮罩效果的具体代码,供大家参考,具体内容如下效果:shader代码:Shader "