当前位置:网站首页>C# Winform 最大化遮挡任务栏和全屏显示问题
C# Winform 最大化遮挡任务栏和全屏显示问题
2022-06-24 19:49:00 【熊思宇】
在打开最大化窗体时,如果不进行配置,那么默认情况下窗体是被任务栏档住,导致有部分界面看不见,看看下面代码的效果,也许对你有帮助
新建一个Winform项目,添加三个按钮,给三个按钮添加点击事件
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Size WindowMaximumSize;
private void Form1_Load(object sender, EventArgs e)
{
WindowMaximumSize = this.MaximumSize;
this.TopMost = true;
}
private void button1_Click(object sender, EventArgs e)
{
//任务栏不会被遮挡
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
}
else
{
this.WindowState = FormWindowState.Maximized;
}
}
private void button2_Click(object sender, EventArgs e)
{
//任务栏会被遮挡
if (this.WindowState == FormWindowState.Maximized)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.None;
this.MaximumSize = WindowMaximumSize;
this.WindowState = FormWindowState.Maximized;
}
}
private void button3_Click(object sender, EventArgs e)
{
//任务栏不会被遮挡
if (this.WindowState == FormWindowState.Maximized)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
}
}
}
}
效果:
点击按钮1,会最大化,但窗体不会遮挡任务栏,
点击按钮2,会全屏显示,
点击按钮3,会最大化,但窗体不会遮挡任务栏,
end
边栏推荐
- 浅析大型IM即时通讯系统开发难度
- 【图数据库性能和场景测试利器LDBC SNB】系列一:数据生成器简介 & 应用于GES服务
- 微搭低代码中实现增删改查
- China CAE industry investment strategic planning and future development analysis report 2022 ~ 2028
- 离散数学及其应用 2018-2019学年春夏学期期末考试 习题详解
- Stm32f030f4 reading infrared remote control data
- C程序设计专题 15-16年期末考试习题解答(上)
- Canvas spiral style animation JS special effect
- Hello C (V) -- pointer and array
- Hibernate学习2 - 懒加载(延迟加载)、动态SQL参数、缓存
猜你喜欢
抖音實戰~項目關聯UniCloud
QT display RGB data
浅析大型IM即时通讯系统开发难度
What exactly is Nacos
Technology sharing | wvp+zlmediakit realizes streaming playback of camera gb28181
The third generation of power electronics semiconductors: SiC MOSFET learning notes (V) research on driving power supply
为什么生命科学企业都在陆续上云?
Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
JPA学习2 - 核心注解、注解进行增删改查、List查询结果返回类型、一对多、多对一、多对多
Stm32f030f4 reading infrared remote control data
随机推荐
Analysis report on operation mode and future development of global and Chinese methyl cyclopentanoate industry from 2022 to 2028
How to use stm32subeide SWV function
One way 和two way ANOVA分析的区别是啥,以及如何使用SPSS或者prism进行统计分析
∞符号线条动画canvasjs特效
Phprunner 10.7.0 PHP code generator
Development status and prospect trend forecast report of humic acid sodium industry in the world and China from 2022 to 2028
Leetcode No.10 regular expression matching
Time unified system
canvas螺旋样式的动画js特效
Requests Library
wx小程序跳转页面
Daily calculation (vowel case conversion)
On the difficulty of developing large im instant messaging system
Current situation and development prospect forecast report of global and Chinese tetrahydrofurfuryl alcohol acetate industry from 2022 to 2028
Using external Libpcap library on ARM platform
Start QT program
Do280openshift access control -- encryption and configmap
The file containing the file operation vulnerability (6)
JPA learning 2 - core annotation, annotation addition, deletion, modification and query, list query result return type, one to many, many to one, many to many
Report on operation pattern and future prospect of global and Chinese propyl isovalerate industry from 2022 to 2028