This article is a mirror article of machine translation, please click here to jump to the original article.

View: 17250|Reply: 0

[WinForm] How to get screen width and height in C#

[Copy link]
Posted on 2/12/2015 4:36:07 PM | | |

//1、在屏幕的右下角显示窗体
//这个区域不包括任务栏的
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);
//这个区域包括任务栏,就是屏幕显示的物理范围
Rectangle ScreenArea = System.Windows.Forms.Screen.GetBounds(this);
int width1 = ScreenArea.Width; Screen width
int height1 = ScreenArea.Height; Screen height
this.locatio removes n = new System.Drawing.Point(width1 - form width, height1 - form height);  The specified form is displayed in the lower right corner
//2、在母窗体的中间显示子窗体的位置计算
waitForm.locatio removes n = new Point((this.locatio removes n.X + (this. Width - waitForm.Width) / 2),
                                                (this.locatio removes n.Y + (this. Height - waitForm.Height) / 2));




Previous:C# Regex class usage
Next:The return value of "System.Windows.Forms.Form.Size" cannot be modified because it is not a variable
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com