当前位置:网站首页>Maximize, minimize, restore, close and move the WinForm form form of C #
Maximize, minimize, restore, close and move the WinForm form form of C #
2022-07-24 02:23:00 【zcy_ wxy】
C# And winform Maximization of forms 、 To minimize the 、 Restore 、 Close and move the form
Doing it winform When beautifying the form interface , Generally, the FormBorderStyle Property changed to None, Then the form will become a blank “ White paper ”, Then design the interface according to your own needs . Close on the form 、 To minimize the 、 Maximize buttons need to be added by yourself , The code to realize its function is as follows :
// Closing of forms
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
// Minimize the form
private void btnMin_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
// Form maximization and restoration
private void btnMax_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
Image backImage = Resources. Maximize ;// Here, a good picture is added to the resource library when the picture is called Need to add reference using CalibrationAndMatching.Properties;
btn_Max.BackgroundImage = backImage;
}
else
{
this.WindowState = FormWindowState.Maximized;
Image backImage = Resources. Restore ;
btn_Max.BackgroundImage = backImage;
}
}After clicking the maximize form button, you will find that the form becomes larger and covers the whole screen , Cover the taskbar , The solution to this problem is as follows :
// On the window Load Events
private void Form1_Load(object sender, EventArgs e)
{
this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea;
}To realize the dragging of forms , Put the following code into the MouseDown In the event :
// call API function Add reference using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private void FrmMain_MouseDown(object sender, MouseEventArgs e)
{
if (e.Clicks == 1)
{
// The window moves
if (e.Button == MouseButtons.Left)
{
ReleaseCapture(); // Release mouse capture
// Send the left click message to this form ( The title bar )
SendMessage(this.Handle, 0xA1, 0x02, 0);
}
}
}
边栏推荐
- Tensorflow 2.0 deep learning tutorial
- 响应式布局一个网页在不同设备显示不同效果)meta:vp
- 奔走相告,行情与量化页面功能优化!股票量化分析工具QTYX-V2.4.5
- 组件el-scrollbar的使用
- [Luogu] p1318 ponding area
- Responsive layout a web page displays different effects on different devices) meta:vp
- 分享一个基于Abp 和Yarp 开发的API网关项目
- 氢能创业大赛 | 国华投资董事长刘小奇:发挥风光氢储融一体化优势 高水平承办创业大赛
- College degree want to 0 basic programming after looking for a job feasible?
- Opensmile introduction and problems encountered during installation
猜你喜欢

Responsive pbootcms template decoration design website

Crop leaf disease identification system

利用宝塔面板计划任务执行自动推送网址到百度收录

This article shows you how to use SQL to process weekly report data

Sharing a case of controller restart caused by a CIFS bug in NetApp Fas series

Use the hiflow scene connector to view the epidemic situation in the region every day

Resumption: a deck of cards (54), three people fighting the landlord, what is the probability that the big and small kings are in the same family

canvas-绘图(鼠标按下 绘制 抬起 结束)

Solve the problem that the script tag is written in front of the element node and cannot get the element node

Leetcode 70 climbing stairs, 199 right view of binary tree, 232 realizing queue with stack, 143 rearranging linked list
随机推荐
【数据集】——flyingthings3d光流部分数据集下载
ASP.NET CORE写一个缓存Attribute工具
Network protocol details: TCP part1
認識傳輸層協議—TCP/UDP
【FPGA教程案例39】通信案例9——基于FPGA的交织-解交织数据传输
Performance optimization of wechat applet (subcontracting, operation process details, simplified structure, native component communication)
Ardunio - ULN2003 drive board and DC motor fan - control fan speed
输入cnpm -v出现cnpm : 无法加载文件 C:\Users\19457\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
[untitled]
网络协议详解:TCP Part1
我国科学家在高安全量子密钥分发网络方面取得新进展
认识传输层协议—TCP/UDP
Async await details & Promise
Research on XMPP service (I)
ggplot2显示png
Wenxin big model raises a new "sail", and the tide of industrial application has arrived
Brief introduction of tfw6524 perfectly replacing imported pt6524 chip
Use of component El scrollbar
Tensorflow 2.0 deep learning tutorial
Performance test of ArrayList and LinkedList insertion based on jmh