当前位置:网站首页>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
边栏推荐
- ∞ symbol line animation canvasjs special effect
- Eye gaze estimation using webcam
- Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
- Investment analysis and prospect forecast report of global and Chinese triglycine sulfate industry from 2022 to 2028
- 抖音实战~实现App端视频上传与发布
- [proteus simulation] example of using timer 0 as a 16 bit counter
- im即时通讯开发应用保活之进程防杀
- How to delete the entire row with duplicate items in a column of WPS table
- 微搭低代码中实现增删改查
- 教程详解|在酷雷曼系统中如何编辑设置导览功能?
猜你喜欢

Why do more and more physical stores use VR panorama? What are the advantages?

Do280openshift access control -- encryption and configmap

Tiktok practice ~ upload and release app video

Phprunner 10.7.0 PHP code generator

Signal integrity (SI) power integrity (PI) learning notes (XXV) differential pair and differential impedance (V)

What exactly is Nacos

Collective例子

It's 2022, and you still don't know what performance testing is?

人体改造 VS 数字化身

Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
随机推荐
Time unified system
第三代电力电子半导体:SiC MOSFET学习笔记(五)驱动电源调研
信号完整性(SI)电源完整性(PI)学习笔记(二十五)差分对与差分阻抗(五)
创意SVG环形时钟js特效
Technology sharing | wvp+zlmediakit realizes streaming playback of camera gb28181
Scala IO reads binary files
Current situation analysis and development trend prediction report of hesperidase industry in the world and China from 2022 to 2028
U.S. House of Representatives: digital dollar will support the U.S. dollar as the global reserve currency
It's 2022, and you still don't know what performance testing is?
After 5 years of software testing in didi and ByteDance, it's too real
干接点和湿接点
Analysis report on development mode and investment direction of sodium lauriminodipropionate in the world and China 2022 ~ 2028
【图数据库性能和场景测试利器LDBC SNB】系列一:数据生成器简介 & 应用于GES服务
机器学习自学成才的十条戒律
Tape SVG animation JS effect
在滴滴和字节跳动干了 5年软件测试,太真实…
抖音實戰~項目關聯UniCloud
Current situation and development prospect forecast report of global and Chinese tetrahydrofurfuryl alcohol acetate industry from 2022 to 2028
In the past 5 years, from "Diandian" to the current test development, my success is worth learning from.
[proteus simulation] example of using timer 0 as a 16 bit counter