質問編集履歴

6

不要な追記の削除

2020/04/30 07:54

投稿

Sukabo
Sukabo

スコア31

test CHANGED
File without changes
test CHANGED
@@ -27,343 +27,3 @@
27
27
  ・ボタン1(button1)を`button1.Location = new Point(100, 100);`でボタン2((100, 100)に手動で配置)に重ねようとしても、右下にずれて表示される
28
28
 
29
29
  ・新規プロジェクトを作成してボタン2つだけ配置して試しても同様
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
- 追記
38
-
39
- 以下、app.config
40
-
41
- ```C#
42
-
43
- <?xml version="1.0" encoding="utf-8" ?>
44
-
45
- <configuration>
46
-
47
- <System.Windows.Forms.ApplicationConfigurationSection>
48
-
49
- <add key="DpiAwareness" value="PerMonitorV2" />
50
-
51
- <add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
52
-
53
- </System.Windows.Forms.ApplicationConfigurationSection>
54
-
55
- </configuration>
56
-
57
- ```
58
-
59
- 以下、Form1.Designer.cs
60
-
61
- ```C#
62
-
63
- namespace typing_game
64
-
65
- {
66
-
67
- partial class Form1
68
-
69
- {
70
-
71
- /// <summary>
72
-
73
- /// 必要なデザイナー変数です。
74
-
75
- /// </summary>
76
-
77
- private System.ComponentModel.IContainer components = null;
78
-
79
-
80
-
81
- /// <summary>
82
-
83
- /// 使用中のリソースをすべてクリーンアップします。
84
-
85
- /// </summary>
86
-
87
- /// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
88
-
89
- protected override void Dispose(bool disposing)
90
-
91
- {
92
-
93
- if (disposing && (components != null))
94
-
95
- {
96
-
97
- components.Dispose();
98
-
99
- }
100
-
101
- base.Dispose(disposing);
102
-
103
- }
104
-
105
-
106
-
107
- #region Windows フォーム デザイナーで生成されたコード
108
-
109
-
110
-
111
- /// <summary>
112
-
113
- /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
114
-
115
- /// コード エディターで変更しないでください。
116
-
117
- /// </summary>
118
-
119
- private void InitializeComponent()
120
-
121
- {
122
-
123
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
124
-
125
- this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
126
-
127
- this.makeButton = new System.Windows.Forms.Button();
128
-
129
- this.gameTitle = new System.Windows.Forms.Label();
130
-
131
- this.playButton = new System.Windows.Forms.Button();
132
-
133
- this.titlePanel = new System.Windows.Forms.Panel();
134
-
135
- this.button1 = new System.Windows.Forms.Button();
136
-
137
- this.button2 = new System.Windows.Forms.Button();
138
-
139
- this.button3 = new System.Windows.Forms.Button();
140
-
141
- ((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).BeginInit();
142
-
143
- this.titlePanel.SuspendLayout();
144
-
145
- this.SuspendLayout();
146
-
147
- //
148
-
149
- // axWindowsMediaPlayer1
150
-
151
- //
152
-
153
- this.axWindowsMediaPlayer1.Enabled = true;
154
-
155
- this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(94, 360);
156
-
157
- this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";
158
-
159
- this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState")));
160
-
161
- this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(559, 44);
162
-
163
- this.axWindowsMediaPlayer1.TabIndex = 0;
164
-
165
- //
166
-
167
- // makeButton
168
-
169
- //
170
-
171
- this.makeButton.Font = new System.Drawing.Font("MS UI Gothic", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
172
-
173
- this.makeButton.Location = new System.Drawing.Point(144, 274);
174
-
175
- this.makeButton.Name = "makeButton";
176
-
177
- this.makeButton.Size = new System.Drawing.Size(167, 57);
178
-
179
- this.makeButton.TabIndex = 1;
180
-
181
- this.makeButton.Text = "つくる";
182
-
183
- this.makeButton.UseVisualStyleBackColor = true;
184
-
185
- this.makeButton.Click += new System.EventHandler(this.makeButton_Click);
186
-
187
- //
188
-
189
- // gameTitle
190
-
191
- //
192
-
193
- this.gameTitle.Font = new System.Drawing.Font("MS 明朝", 70.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
194
-
195
- this.gameTitle.ForeColor = System.Drawing.Color.LightSeaGreen;
196
-
197
- this.gameTitle.Location = new System.Drawing.Point(12, 52);
198
-
199
- this.gameTitle.Name = "gameTitle";
200
-
201
- this.gameTitle.Size = new System.Drawing.Size(776, 138);
202
-
203
- this.gameTitle.TabIndex = 2;
204
-
205
- this.gameTitle.Text = "Typing Game";
206
-
207
- this.gameTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
208
-
209
- //
210
-
211
- // playButton
212
-
213
- //
214
-
215
- this.playButton.Font = new System.Drawing.Font("MS UI Gothic", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
216
-
217
- this.playButton.Location = new System.Drawing.Point(456, 274);
218
-
219
- this.playButton.Name = "playButton";
220
-
221
- this.playButton.Size = new System.Drawing.Size(167, 57);
222
-
223
- this.playButton.TabIndex = 3;
224
-
225
- this.playButton.Text = "あそぶ";
226
-
227
- this.playButton.UseVisualStyleBackColor = true;
228
-
229
- //
230
-
231
- // titlePanel
232
-
233
- //
234
-
235
- this.titlePanel.Controls.Add(this.button3);
236
-
237
- this.titlePanel.Controls.Add(this.playButton);
238
-
239
- this.titlePanel.Controls.Add(this.gameTitle);
240
-
241
- this.titlePanel.Controls.Add(this.makeButton);
242
-
243
- this.titlePanel.Location = new System.Drawing.Point(607, 168);
244
-
245
- this.titlePanel.Name = "titlePanel";
246
-
247
- this.titlePanel.Size = new System.Drawing.Size(800, 450);
248
-
249
- this.titlePanel.TabIndex = 4;
250
-
251
- //
252
-
253
- // button1
254
-
255
- //
256
-
257
- this.button1.Location = new System.Drawing.Point(0, 0);
258
-
259
- this.button1.Name = "button1";
260
-
261
- this.button1.Size = new System.Drawing.Size(75, 23);
262
-
263
- this.button1.TabIndex = 5;
264
-
265
- this.button1.Text = "button1";
266
-
267
- this.button1.UseVisualStyleBackColor = true;
268
-
269
- //
270
-
271
- // button2
272
-
273
- //
274
-
275
- this.button2.Location = new System.Drawing.Point(100, 100);
276
-
277
- this.button2.Name = "button2";
278
-
279
- this.button2.Size = new System.Drawing.Size(75, 23);
280
-
281
- this.button2.TabIndex = 6;
282
-
283
- this.button2.Text = "button2";
284
-
285
- this.button2.UseVisualStyleBackColor = true;
286
-
287
- //
288
-
289
- // button3
290
-
291
- //
292
-
293
- this.button3.Location = new System.Drawing.Point(0, 0);
294
-
295
- this.button3.Name = "button3";
296
-
297
- this.button3.Size = new System.Drawing.Size(75, 23);
298
-
299
- this.button3.TabIndex = 7;
300
-
301
- this.button3.Text = "button3";
302
-
303
- this.button3.UseVisualStyleBackColor = true;
304
-
305
- //
306
-
307
- // Form1
308
-
309
- //
310
-
311
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
312
-
313
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
314
-
315
- this.ClientSize = new System.Drawing.Size(800, 450);
316
-
317
- this.Controls.Add(this.button2);
318
-
319
- this.Controls.Add(this.button1);
320
-
321
- this.Controls.Add(this.titlePanel);
322
-
323
- this.Controls.Add(this.axWindowsMediaPlayer1);
324
-
325
- this.Name = "Form1";
326
-
327
- this.Text = "Typing Game";
328
-
329
- this.Load += new System.EventHandler(this.Form1_Load);
330
-
331
- ((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).EndInit();
332
-
333
- this.titlePanel.ResumeLayout(false);
334
-
335
- this.ResumeLayout(false);
336
-
337
-
338
-
339
- }
340
-
341
-
342
-
343
- #endregion
344
-
345
-
346
-
347
- private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
348
-
349
- private System.Windows.Forms.Button makeButton;
350
-
351
- private System.Windows.Forms.Label gameTitle;
352
-
353
- private System.Windows.Forms.Button playButton;
354
-
355
- private System.Windows.Forms.Panel titlePanel;
356
-
357
- private System.Windows.Forms.Button button1;
358
-
359
- private System.Windows.Forms.Button button2;
360
-
361
- private System.Windows.Forms.Button button3;
362
-
363
- }
364
-
365
- }
366
-
367
-
368
-
369
- ```

5

コードの追記

2020/04/30 07:54

投稿

Sukabo
Sukabo

スコア31

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,26 @@
36
36
 
37
37
  追記
38
38
 
39
+ 以下、app.config
40
+
41
+ ```C#
42
+
43
+ <?xml version="1.0" encoding="utf-8" ?>
44
+
45
+ <configuration>
46
+
47
+ <System.Windows.Forms.ApplicationConfigurationSection>
48
+
49
+ <add key="DpiAwareness" value="PerMonitorV2" />
50
+
51
+ <add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
52
+
53
+ </System.Windows.Forms.ApplicationConfigurationSection>
54
+
55
+ </configuration>
56
+
57
+ ```
58
+
39
59
  以下、Form1.Designer.cs
40
60
 
41
61
  ```C#

4

試したことの追記

2020/04/29 11:06

投稿

Sukabo
Sukabo

スコア31

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,20 @@
20
20
 
21
21
 
22
22
 
23
+ ### 試したこと
24
+
25
+ ・ボタン2(button2)を(100, 100)の位置に`Form1.cs[デザイン]`にて手動で配置して`Console.WriteLine(button2);`として実行すると出力には`{X=75,Y=80}`と出る
26
+
27
+ ・ボタン1(button1)を`button1.Location = new Point(100, 100);`でボタン2((100, 100)に手動で配置)に重ねようとしても、右下にずれて表示される
28
+
29
+ ・新規プロジェクトを作成してボタン2つだけ配置して試しても同様
30
+
31
+
32
+
33
+
34
+
35
+
36
+
23
37
  追記
24
38
 
25
39
  以下、Form1.Designer.cs

3

コードの追記

2020/04/29 00:43

投稿

Sukabo
Sukabo

スコア31

test CHANGED
File without changes
test CHANGED
@@ -22,4 +22,314 @@
22
22
 
23
23
  追記
24
24
 
25
+ 以下、Form1.Designer.cs
26
+
27
+ ```C#
28
+
25
- Panelについての追記は間違っていました。
29
+ namespace typing_game
30
+
31
+ {
32
+
33
+ partial class Form1
34
+
35
+ {
36
+
37
+ /// <summary>
38
+
39
+ /// 必要なデザイナー変数です。
40
+
41
+ /// </summary>
42
+
43
+ private System.ComponentModel.IContainer components = null;
44
+
45
+
46
+
47
+ /// <summary>
48
+
49
+ /// 使用中のリソースをすべてクリーンアップします。
50
+
51
+ /// </summary>
52
+
53
+ /// <param name="disposing">マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
54
+
55
+ protected override void Dispose(bool disposing)
56
+
57
+ {
58
+
59
+ if (disposing && (components != null))
60
+
61
+ {
62
+
63
+ components.Dispose();
64
+
65
+ }
66
+
67
+ base.Dispose(disposing);
68
+
69
+ }
70
+
71
+
72
+
73
+ #region Windows フォーム デザイナーで生成されたコード
74
+
75
+
76
+
77
+ /// <summary>
78
+
79
+ /// デザイナー サポートに必要なメソッドです。このメソッドの内容を
80
+
81
+ /// コード エディターで変更しないでください。
82
+
83
+ /// </summary>
84
+
85
+ private void InitializeComponent()
86
+
87
+ {
88
+
89
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
90
+
91
+ this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
92
+
93
+ this.makeButton = new System.Windows.Forms.Button();
94
+
95
+ this.gameTitle = new System.Windows.Forms.Label();
96
+
97
+ this.playButton = new System.Windows.Forms.Button();
98
+
99
+ this.titlePanel = new System.Windows.Forms.Panel();
100
+
101
+ this.button1 = new System.Windows.Forms.Button();
102
+
103
+ this.button2 = new System.Windows.Forms.Button();
104
+
105
+ this.button3 = new System.Windows.Forms.Button();
106
+
107
+ ((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).BeginInit();
108
+
109
+ this.titlePanel.SuspendLayout();
110
+
111
+ this.SuspendLayout();
112
+
113
+ //
114
+
115
+ // axWindowsMediaPlayer1
116
+
117
+ //
118
+
119
+ this.axWindowsMediaPlayer1.Enabled = true;
120
+
121
+ this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(94, 360);
122
+
123
+ this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";
124
+
125
+ this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState")));
126
+
127
+ this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(559, 44);
128
+
129
+ this.axWindowsMediaPlayer1.TabIndex = 0;
130
+
131
+ //
132
+
133
+ // makeButton
134
+
135
+ //
136
+
137
+ this.makeButton.Font = new System.Drawing.Font("MS UI Gothic", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
138
+
139
+ this.makeButton.Location = new System.Drawing.Point(144, 274);
140
+
141
+ this.makeButton.Name = "makeButton";
142
+
143
+ this.makeButton.Size = new System.Drawing.Size(167, 57);
144
+
145
+ this.makeButton.TabIndex = 1;
146
+
147
+ this.makeButton.Text = "つくる";
148
+
149
+ this.makeButton.UseVisualStyleBackColor = true;
150
+
151
+ this.makeButton.Click += new System.EventHandler(this.makeButton_Click);
152
+
153
+ //
154
+
155
+ // gameTitle
156
+
157
+ //
158
+
159
+ this.gameTitle.Font = new System.Drawing.Font("MS 明朝", 70.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
160
+
161
+ this.gameTitle.ForeColor = System.Drawing.Color.LightSeaGreen;
162
+
163
+ this.gameTitle.Location = new System.Drawing.Point(12, 52);
164
+
165
+ this.gameTitle.Name = "gameTitle";
166
+
167
+ this.gameTitle.Size = new System.Drawing.Size(776, 138);
168
+
169
+ this.gameTitle.TabIndex = 2;
170
+
171
+ this.gameTitle.Text = "Typing Game";
172
+
173
+ this.gameTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
174
+
175
+ //
176
+
177
+ // playButton
178
+
179
+ //
180
+
181
+ this.playButton.Font = new System.Drawing.Font("MS UI Gothic", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
182
+
183
+ this.playButton.Location = new System.Drawing.Point(456, 274);
184
+
185
+ this.playButton.Name = "playButton";
186
+
187
+ this.playButton.Size = new System.Drawing.Size(167, 57);
188
+
189
+ this.playButton.TabIndex = 3;
190
+
191
+ this.playButton.Text = "あそぶ";
192
+
193
+ this.playButton.UseVisualStyleBackColor = true;
194
+
195
+ //
196
+
197
+ // titlePanel
198
+
199
+ //
200
+
201
+ this.titlePanel.Controls.Add(this.button3);
202
+
203
+ this.titlePanel.Controls.Add(this.playButton);
204
+
205
+ this.titlePanel.Controls.Add(this.gameTitle);
206
+
207
+ this.titlePanel.Controls.Add(this.makeButton);
208
+
209
+ this.titlePanel.Location = new System.Drawing.Point(607, 168);
210
+
211
+ this.titlePanel.Name = "titlePanel";
212
+
213
+ this.titlePanel.Size = new System.Drawing.Size(800, 450);
214
+
215
+ this.titlePanel.TabIndex = 4;
216
+
217
+ //
218
+
219
+ // button1
220
+
221
+ //
222
+
223
+ this.button1.Location = new System.Drawing.Point(0, 0);
224
+
225
+ this.button1.Name = "button1";
226
+
227
+ this.button1.Size = new System.Drawing.Size(75, 23);
228
+
229
+ this.button1.TabIndex = 5;
230
+
231
+ this.button1.Text = "button1";
232
+
233
+ this.button1.UseVisualStyleBackColor = true;
234
+
235
+ //
236
+
237
+ // button2
238
+
239
+ //
240
+
241
+ this.button2.Location = new System.Drawing.Point(100, 100);
242
+
243
+ this.button2.Name = "button2";
244
+
245
+ this.button2.Size = new System.Drawing.Size(75, 23);
246
+
247
+ this.button2.TabIndex = 6;
248
+
249
+ this.button2.Text = "button2";
250
+
251
+ this.button2.UseVisualStyleBackColor = true;
252
+
253
+ //
254
+
255
+ // button3
256
+
257
+ //
258
+
259
+ this.button3.Location = new System.Drawing.Point(0, 0);
260
+
261
+ this.button3.Name = "button3";
262
+
263
+ this.button3.Size = new System.Drawing.Size(75, 23);
264
+
265
+ this.button3.TabIndex = 7;
266
+
267
+ this.button3.Text = "button3";
268
+
269
+ this.button3.UseVisualStyleBackColor = true;
270
+
271
+ //
272
+
273
+ // Form1
274
+
275
+ //
276
+
277
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
278
+
279
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
280
+
281
+ this.ClientSize = new System.Drawing.Size(800, 450);
282
+
283
+ this.Controls.Add(this.button2);
284
+
285
+ this.Controls.Add(this.button1);
286
+
287
+ this.Controls.Add(this.titlePanel);
288
+
289
+ this.Controls.Add(this.axWindowsMediaPlayer1);
290
+
291
+ this.Name = "Form1";
292
+
293
+ this.Text = "Typing Game";
294
+
295
+ this.Load += new System.EventHandler(this.Form1_Load);
296
+
297
+ ((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).EndInit();
298
+
299
+ this.titlePanel.ResumeLayout(false);
300
+
301
+ this.ResumeLayout(false);
302
+
303
+
304
+
305
+ }
306
+
307
+
308
+
309
+ #endregion
310
+
311
+
312
+
313
+ private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
314
+
315
+ private System.Windows.Forms.Button makeButton;
316
+
317
+ private System.Windows.Forms.Label gameTitle;
318
+
319
+ private System.Windows.Forms.Button playButton;
320
+
321
+ private System.Windows.Forms.Panel titlePanel;
322
+
323
+ private System.Windows.Forms.Button button1;
324
+
325
+ private System.Windows.Forms.Button button2;
326
+
327
+ private System.Windows.Forms.Button button3;
328
+
329
+ }
330
+
331
+ }
332
+
333
+
334
+
335
+ ```

2

追記の削除

2020/04/29 00:22

投稿

Sukabo
Sukabo

スコア31

test CHANGED
File without changes
test CHANGED
@@ -22,4 +22,4 @@
22
22
 
23
23
  追記
24
24
 
25
- Panelコンテナコントロールを入れるとなぜかうまくきます(Panelプログラム内で動かしも実行時にずれなようです)
25
+ Panelにての追記間違っていました。

1

うまくいく場合の追記

2020/04/28 12:02

投稿

Sukabo
Sukabo

スコア31

test CHANGED
File without changes
test CHANGED
@@ -17,3 +17,9 @@
17
17
  これでデバッグすると、なぜかボタンがドラッグして置いたときよりも右下にずれて表示されます。
18
18
 
19
19
  解決方法を教えてくださると幸いです。
20
+
21
+
22
+
23
+ 追記
24
+
25
+ Panelコンテナにコントロールを入れるとなぜかうまくいきます(Panelはプログラム内で動かしても実行時にずれないようです)