回答編集履歴

1

追加

2017/02/10 03:37

投稿

hsk
hsk

スコア728

test CHANGED
@@ -114,10 +114,82 @@
114
114
 
115
115
 
116
116
 
117
+ ##閉じるボタンを無効にする
118
+
119
+ Alt+F4も無効になる方法と、有効なままにする方法とありますが、ここでは前者を。
120
+
121
+
122
+
123
+ ```C#
124
+
117
- ほかについては、適宜。。
125
+ using System;
126
+
127
+ using System.Windows.Forms;
128
+
129
+ using System.Security.Permissions;
130
+
131
+
132
+
133
+ namespace WindowsFormsApplication1
134
+
135
+ {
136
+
137
+ public partial class TargetForm : Form
138
+
139
+ {
140
+
141
+ public TargetForm()
142
+
143
+ {
144
+
145
+ InitializeComponent();
146
+
147
+ }
148
+
149
+
150
+
151
+ // ここから
152
+
153
+ protected override CreateParams CreateParams
154
+
155
+ {
156
+
157
+ [SecurityPermission(SecurityAction.Demand,
158
+
159
+ Flags = SecurityPermissionFlag.UnmanagedCode)]
160
+
161
+ get
162
+
163
+ {
164
+
165
+ CreateParams cp = base.CreateParams;
166
+
167
+ cp.ClassStyle = cp.ClassStyle | 0x200; // CS_NOCLOSE を追加
168
+
169
+
170
+
171
+ return cp;
172
+
173
+ }
174
+
175
+ }
176
+
177
+ // ここまで
178
+
179
+ }
180
+
181
+ }
182
+
183
+
184
+
185
+ ```
186
+
187
+
118
188
 
119
189
 
120
190
 
121
191
  ##ご参考
122
192
 
123
193
  - [フォームのサイズを制限する](http://dobon.net/vb/dotnet/form/minimumsize.html) - DOBON.NETさん
194
+
195
+ - [フォームの「閉じる」ボタンを無効にする](http://dobon.net/vb/dotnet/form/disabledclosebutton.html) - DOBON.NETさん