winform 窗体最大化 分类: WinForm 2014-07-17 15:57 215人阅读 评论(0) 收藏
2014-07-17 15:57
666 查看
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):主窗体
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;
相关文章推荐
- winform 窗体关闭按钮禁用、不显示最大化、最小化、关闭按钮 分类: WinForm 2014-12-22 16:09 82人阅读 评论(0) 收藏
- [分享]外部exe窗体嵌入winform 分类: .NET 2015-03-12 11:26 68人阅读 评论(0) 收藏
- 窗体控件 回车事件 分类: WinForm 2014-11-21 10:45 233人阅读 评论(0) 收藏
- winform 跨窗体给控件传值 分类: WinForm 2014-08-02 16:33 195人阅读 评论(0) 收藏
- winform 子窗体数据改变刷新父窗体 分类: WinForm 2014-05-06 18:30 246人阅读 评论(0) 收藏
- Winform异步解决窗体耗时操作(Action专门用于无返回值,Func专门用于有返回值) 分类: .NET 2014-05-12 03:03 836人阅读 评论(0) 收藏
- winform combobox控件绑定 分类: WinForm 2014-04-17 14:34 118人阅读 评论(0) 收藏
- winform 读取TXT文件 放在Label中 分类: WinForm 2014-07-31 09:56 310人阅读 评论(0) 收藏
- 【solr专题之四】在Tomcat 中部署Solr4.x 分类: H_HISTORY 2014-07-17 16:08 1286人阅读 评论(0) 收藏
- winform 判断鼠标在一段时间内是否移动 分类: .NET 2012-04-06 15:40 1236人阅读 评论(2) 收藏
- winform 菜单项显示历史记录 分类: WinForm 2014-07-11 18:15 196人阅读 评论(0) 收藏
- ListView 分类: WinForm 2014-07-18 22:03 289人阅读 评论(0) 收藏
- C# WinForm 透明控件 PictureBox透明 分类: WinForm 2014-07-30 13:27 591人阅读 评论(0) 收藏
- winform 猜猜看 分类: WinForm 2014-08-21 14:12 267人阅读 评论(0) 收藏
- winform 加密 解密 分类: WinForm 2014-05-16 15:05 400人阅读 评论(0) 收藏
- winform 曲线(贝塞尔) 分类: WinForm 2014-12-29 16:52 109人阅读 评论(0) 收藏
- winform 分页 分类: WinForm 2014-05-16 15:30 257人阅读 评论(0) 收藏
- winform 获取文件夹的名称 分类: WinForm 2014-08-04 15:50 242人阅读 评论(0) 收藏
- DateTimePicker控件为空 分类: WinForm 2014-04-15 09:46 239人阅读 评论(0) 收藏
- winform 解决界面闪动、提升加载速度 分类: WinForm 2015-02-03 16:34 161人阅读 评论(0) 收藏