teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2016/04/11 09:29

投稿

catsforepaw
catsforepaw

スコア5944

answer CHANGED
@@ -8,4 +8,47 @@
8
8
 
9
9
  // Sizeだけ変更したい場合
10
10
  this.MaximizedBounds = new Rectangle(this.MaximizedBounds.Location, new Size(1500, 1000));
11
- ```
11
+ ```
12
+
13
+ ---
14
+ 追記
15
+ 下記コードで最大化時の位置とサイズの指定ができます。
16
+ ```
17
+ using System.Runtime.InteropServices;
18
+
19
+ :
20
+ :
21
+ :
22
+
23
+ private struct POINT
24
+ {
25
+ public int x;
26
+ public int y;
27
+ }
28
+
29
+ private struct MINMAXINFO
30
+ {
31
+ public POINT ptReserved;
32
+ public POINT ptMaxSize; // 最大化フォームのサイズ
33
+ public POINT ptMaxPosition; // 最大化フォームの位置
34
+ public POINT ptMinTrackSize; // フォームの最大サイズ
35
+ public POINT ptMaxTrackSize; // フォームの最小サイズ
36
+ }
37
+
38
+ private const int WM_GETMINMAXINFO = 0x0024;
39
+
40
+ protected override void WndProc(ref Message m)
41
+ {
42
+ if(m.Msg == WM_GETMINMAXINFO)
43
+ {
44
+ MINMAXINFO info = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
45
+ info.ptMaxPosition.x = 15;
46
+ info.ptMaxPosition.y = 10;
47
+ info.ptMaxSize.x = 1500;
48
+ info.ptMaxSize.y = 1000;
49
+ Marshal.StructureToPtr(info, m.LParam, true);
50
+ return;
51
+ }
52
+ base.WndProc(ref m);
53
+ }
54
+ ```