标签:winform style class blog code tar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116 |
1. 窗体最大化时 非全屏 不会遮盖任务栏 private
void btnFormMax_Click( object
sender, EventArgs e) { if
( this .WindowState == FormWindowState.Maximized) { this .WindowState = FormWindowState.Normal; } else { this .WindowState = FormWindowState.Maximized; } } 此时 this .FormBorderStyle. 默认为 Sizable 2. 窗体最大化时 会全屏 及遮盖任务栏 private
void btnFormMax_Click( object
sender, EventArgs e) { if
( this .WindowState == FormWindowState.Maximized) { this .WindowState = FormWindowState.Normal; } else { this .FormBorderStyle. = FormBorderStyle.None; this .WindowState = FormWindowState.Maximized; } } 此时 this .FormBorderStyle. 为 None 不会显示窗体标题栏等相关 3. 窗体最大化时 非全屏 不会遮盖任务栏 private
void btnFormMax_Click( object
sender, EventArgs e) { if
( this .WindowState == FormWindowState.Maximized) { this .WindowState = FormWindowState.Normal; } else { this .FormBorderStyle. = FormBorderStyle.None; this .MaximumSize = new
Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); this .WindowState = FormWindowState.Maximized; } } 此时 this .FormBorderStyle. 为 None 不会显示窗体标题栏等相关 窗体最大化的时候,如何指定窗体的位置、大小(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 //获取窗口的标准标题栏区域的高度(以象素为单位) |
winForm窗体最大化的设置,布布扣,bubuko.com
标签:winform style class blog code tar
原文地址:http://www.cnblogs.com/yellow-Li/p/3772973.html