1:窗体首次加载时最大化

(1):主窗体

this.WindowState = FormWindowState.Maximized;

//窗体显示中间部分,不显示窗体名称和最小化、最大化、关闭按钮

            this.FormBorderStyle = FormBorderStyle.None;

this.WindowState = FormWindowState.Maximized;

(2):子窗体

设置父窗体的属性:IsMdiContainer=True

Form f = new Form();

            f.MdiParent = this;

f.WindowState = FormWindowState.Maximized;



[转]窗体最大化的时候,如何指定窗体的位置、大小(C#)

using System; 

using System.Collections.Generic; 

using System.ComponentModel; 

using System.Data; 

using System.Drawing; 

using System.Text; 

using System.Windows.Forms; 

namespace WindowsApplication1 



public partial class FormRegion : Form. 



private const long WM_GETMINMAXINFO = 0x24; 

public struct POINTAPI 



public int x; 

public int y; 



public struct MINMAXINFO 



public POINTAPI ptReserved; 

public POINTAPI ptMaxSize; 

public POINTAPI ptMaxPosition; 

public POINTAPI ptMinTrackSize; 

public POINTAPI ptMaxTrackSize; 



public FormRegion() 



InitializeComponent(); 

this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); 



protected override void WndProc(ref System.Windows.Forms.Message m) 



base.WndProc(ref m); 

if (m.Msg == WM_GETMINMAXINFO) 



MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO)); 

mmi.ptMinTrackSize.x = this.MinimumSize.Width; 

mmi.ptMinTrackSize.y = this.MinimumSize.Height; 

if (this.MaximumSize.Width != 0 || this.MaximumSize.Height != 0) 



mmi.ptMaxTrackSize.x = this.MaximumSize.Width; 

mmi.ptMaxTrackSize.y = this.MaximumSize.Height; 



mmi.ptMaxPosition.x = 1; 

mmi.ptMaxPosition.y = 1; 

System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true); 







}

MessageBox.Show("当前窗体标题栏高度"+(this.Height
- this.ClientRectangle.Height).ToString());//获得当前窗体标题栏高度 

ClientRectangle//获取表示控件的工作区的矩形 

MessageBox.Show(SystemInformation.PrimaryMonitorSize.ToString()); //获取主显示器屏幕的尺寸(像素) 

//获取主显示器当前当前视频模式的尺寸(以象素为单位) 

MessageBox.Show("菜单栏高度"+SystemInformation.MenuHeight.ToString());
//获取标准菜单栏的高度 

MessageBox.Show("标题栏高度"+SystemInformation.CaptionHeight.ToString());
//获取标准标题栏的高度 

MenuHeight//获取一个菜单行的高度(以象素为单位) 

CaptionHeight//获取窗口的标准标题栏区域的高度(以象素为单位)

当前的屏幕除任务栏外的工作域大小

    this.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;

    this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;



当前的屏幕包括任务栏的工作域大小

this.Width=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;

this.Height=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;



任务栏大小

this.Width=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width-System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;

this.Height=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height-System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;



winform实现全屏显示

WinForm:

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

this.TopMost = true;  

版权声明:本文为博主原创文章,未经博主允许不得转载。

最新文章

  1. 用Razor做静态页面生成器
  2. c#链接数据库
  3. 搜索服务solr 一二事(1) - solr-5.5 使用自带Jetty或者tomcat 搭建单机版搜索服务器
  4. [php] 处理图像
  5. VBA在WORD中给表格外的字体设置为标题
  6. Informatica9.6.1在Linux Red Hat 5.8上安装遇到的有关问题整理_3
  7. 在线压缩zip
  8. EDM排版table设置padding在ie7下bug
  9. Java线程间通信-回调的实现方式
  10. aliyun硬盘挂载
  11. AppiumDriver升级到2.0.0版本引发的问题--Cannot instantiate the type AppiumDriver
  12. H5加载优化
  13. 将notepad++打造成java快速开发IDE
  14. [PHP]PDO占位符预处理在 IN 和 LIKE 中用法
  15. 放下技术,是PM迈出的第一步
  16. PYTHON BS 四大对象
  17. leetcode网学习笔记(1)
  18. 2017-9-24-Linux移植:ubuntu server 16.04无法联网&无法apt-get update解决
  19. hdu3879 最大权闭合回路
  20. 8.11 数据库ORM(5)

热门文章

  1. View.setTag()的作用
  2. [Lua]cocos framework
  3. js 通过function来定义函数
  4. new Image()的用途
  5. 5亿投资A站G站:中文在线的二次元野心
  6. 浅谈购物车中cookie的使用
  7. 转: QtCreator调试程序时GDB崩溃
  8. Quartz源码阅读
  9. iOS 开发常用的一些工具
  10. NEURAL NETWORKS, PART 2: THE NEURON