質問編集履歴
2
コードの要約
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,9 +56,7 @@
|
|
56
56
|
|
57
57
|
case WM_DESTROY:
|
58
58
|
|
59
|
-
DeleteObject(hBitmap);
|
60
|
-
|
61
|
-
|
59
|
+
...
|
62
60
|
|
63
61
|
return 0;
|
64
62
|
|
@@ -96,144 +94,28 @@
|
|
96
94
|
|
97
95
|
);
|
98
96
|
|
99
|
-
hChildWndTil = CreateMDIWindow(MDI_CHILD, TEXT("タイル"), WS_OVERLAPPEDWINDOW,
|
100
|
-
|
101
|
-
0, 300,
|
102
|
-
|
103
|
-
300, 300,
|
104
|
-
|
105
|
-
hClientWindow, hIns, 0
|
106
|
-
|
107
|
-
);
|
108
|
-
|
109
97
|
}
|
110
98
|
|
111
|
-
|
99
|
+
...
|
100
|
+
|
101
|
+
return 0;
|
102
|
+
|
103
|
+
case WM_SIZE:
|
104
|
+
|
105
|
+
...
|
106
|
+
|
107
|
+
return 0;
|
108
|
+
|
109
|
+
case WM_PAINT:
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
break;
|
114
|
+
|
115
|
+
case WM_COMMAND:
|
112
116
|
|
113
117
|
|
114
118
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
hBitmap = LoadBitmap(
|
120
|
-
|
121
|
-
((LPCREATESTRUCT)lp)->hInstance,
|
122
|
-
|
123
|
-
TEXT("IDB_BITMAP2")
|
124
|
-
|
125
|
-
);
|
126
|
-
|
127
|
-
hToolbar = CreateToolbarEx(
|
128
|
-
|
129
|
-
hWnd,
|
130
|
-
|
131
|
-
WS_CHILD | WS_VISIBLE,
|
132
|
-
|
133
|
-
IDR_TOOLBAR1,
|
134
|
-
|
135
|
-
10,
|
136
|
-
|
137
|
-
NULL,
|
138
|
-
|
139
|
-
(UINT_PTR)hBitmap,
|
140
|
-
|
141
|
-
tbs,
|
142
|
-
|
143
|
-
18,
|
144
|
-
|
145
|
-
0, 0,
|
146
|
-
|
147
|
-
16, 16,
|
148
|
-
|
149
|
-
sizeof(TBBUTTON)
|
150
|
-
|
151
|
-
);
|
152
|
-
|
153
|
-
hStatus = CreateWindowEx(
|
154
|
-
|
155
|
-
NULL,
|
156
|
-
|
157
|
-
STATUSCLASSNAME,
|
158
|
-
|
159
|
-
NULL,
|
160
|
-
|
161
|
-
WS_CHILD
|
162
|
-
|
163
|
-
| SBARS_SIZEGRIP
|
164
|
-
|
165
|
-
| CCS_BOTTOM
|
166
|
-
|
167
|
-
| WS_VISIBLE,
|
168
|
-
|
169
|
-
0, 0, 0, 0,
|
170
|
-
|
171
|
-
hWnd,
|
172
|
-
|
173
|
-
(HMENU)ID_STATUS,
|
174
|
-
|
175
|
-
((LPCREATESTRUCT)lp)->hInstance,
|
176
|
-
|
177
|
-
NULL
|
178
|
-
|
179
|
-
);
|
180
|
-
|
181
|
-
return 0;
|
182
|
-
|
183
|
-
case WM_SIZE:
|
184
|
-
|
185
|
-
int wx, wy, sx, sy;
|
186
|
-
|
187
|
-
RECT rc;
|
188
|
-
|
189
|
-
GetWindowRect(hToolbar, &rc);
|
190
|
-
|
191
|
-
SendMessage(hToolbar, WM_SIZE, wp, lp);
|
192
|
-
|
193
|
-
SendMessage(hStatus, msg, wp, lp);
|
194
|
-
|
195
|
-
SbSize[0] = LOWORD(lp) - 400;
|
196
|
-
|
197
|
-
SbSize[1] = -1;
|
198
|
-
|
199
|
-
SendMessage(hStatus, SB_SETPARTS, 2, (LPARAM)SbSize);
|
200
|
-
|
201
|
-
//文字を挿入
|
202
|
-
|
203
|
-
SendMessage(hStatus, SB_SETTEXT, 0 | 1, (WPARAM)TEXT("マップのサイズ:100x40 グリッドのサイズ:16x16"));
|
204
|
-
|
205
|
-
SendMessage(hStatus, SB_SETTEXT, 0 | 0, (WPARAM)TEXT("X:0 Y:0 種類:0 横幅:16 高さ:16"));
|
206
|
-
|
207
|
-
SendMessage(hStatus, WM_SIZE, wp, lp);
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
GetWindowRect(hStatus, &rc);
|
212
|
-
|
213
|
-
sx = rc.right - rc.left;
|
214
|
-
|
215
|
-
sy = rc.bottom - rc.top;
|
216
|
-
|
217
|
-
wx = LOWORD(lp);
|
218
|
-
|
219
|
-
wy = HIWORD(lp);
|
220
|
-
|
221
|
-
wy -= sy;
|
222
|
-
|
223
|
-
MoveWindow(hClientWindow, 0, 30, wx, wy-30, TRUE);
|
224
|
-
|
225
|
-
return 0;
|
226
|
-
|
227
|
-
case WM_PAINT:
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
break;
|
232
|
-
|
233
|
-
case WM_COMMAND:
|
234
|
-
|
235
|
-
|
236
|
-
|
237
119
|
switch (LOWORD(wp))
|
238
120
|
|
239
121
|
{
|
@@ -252,7 +134,7 @@
|
|
252
134
|
|
253
135
|
else {//ついていない
|
254
136
|
|
255
|
-
hCHildWndMap = CreateMDIWindow(MDI_CHILD, TEXT("
|
137
|
+
hCHildWndMap = CreateMDIWindow(MDI_CHILD, TEXT("マップ"), 0,
|
256
138
|
|
257
139
|
0, 0,
|
258
140
|
|
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,335 @@
|
|
1
1
|
二つ以上のMDI子ウィンドウから成るMDIアプリケーションに於いて、利用者が自らの手でそのウィンドウを削除したときに、どのMDI子ウィンドウが削除されたかを知る術はありますか。
|
2
2
|
|
3
3
|
もしあったら、その方法も教えてださい。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
```C++
|
8
|
+
|
9
|
+
#include <windows.h>
|
10
|
+
|
11
|
+
#include <commctrl.h>
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
#include "resource.h"
|
16
|
+
|
17
|
+
#include "common.h"
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
#pragma comment(lib,"comctl32.lib")
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
#define TITLE TEXT("MDI")
|
26
|
+
|
27
|
+
#define MDI_FRAME TEXT("FRAMEWINDOW")
|
28
|
+
|
29
|
+
#define MDI_CHILD TEXT("MDICHILD")
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
HINSTANCE hIns;//現在のインターフェース
|
34
|
+
|
35
|
+
HWND hCHildWndMap;
|
36
|
+
|
37
|
+
HWND hChildWndTil;
|
38
|
+
|
39
|
+
HWND hToolWnd;
|
40
|
+
|
41
|
+
#define ID_CHILDWND 0x100
|
42
|
+
|
43
|
+
LRESULT CALLBACK FrameProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
44
|
+
|
45
|
+
static HWND hToolbar;
|
46
|
+
|
47
|
+
static HBITMAP hBitmap;
|
48
|
+
|
49
|
+
CLIENTCREATESTRUCT ccsClient;
|
50
|
+
|
51
|
+
static HWND hClientWindow;
|
52
|
+
|
53
|
+
switch (msg)
|
54
|
+
|
55
|
+
{
|
56
|
+
|
57
|
+
case WM_DESTROY:
|
58
|
+
|
59
|
+
DeleteObject(hBitmap);
|
60
|
+
|
61
|
+
PostQuitMessage(0);
|
62
|
+
|
63
|
+
return 0;
|
64
|
+
|
65
|
+
case WM_CREATE:
|
66
|
+
|
67
|
+
InitCommonControls();
|
68
|
+
|
69
|
+
ccsClient.idFirstChild = ID_CHILDWND;
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
hClientWindow = CreateWindow(TEXT("MDICLIENT"), NULL,
|
74
|
+
|
75
|
+
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_CLIPSIBLINGS,
|
76
|
+
|
77
|
+
0, 0, 0, 0, hWnd, (HMENU)1, ((LPCREATESTRUCT)lp)->hInstance, &ccsClient
|
78
|
+
|
79
|
+
);
|
80
|
+
|
81
|
+
{
|
82
|
+
|
83
|
+
RECT wndrct;
|
84
|
+
|
85
|
+
GetWindowRect(hWnd, &wndrct);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
hCHildWndMap = CreateMDIWindow(MDI_CHILD, TEXT("マップ"), 0,
|
90
|
+
|
91
|
+
0, 0,
|
92
|
+
|
93
|
+
300, 300,
|
94
|
+
|
95
|
+
hClientWindow, hIns, 0
|
96
|
+
|
97
|
+
);
|
98
|
+
|
99
|
+
hChildWndTil = CreateMDIWindow(MDI_CHILD, TEXT("タイル"), WS_OVERLAPPEDWINDOW,
|
100
|
+
|
101
|
+
0, 300,
|
102
|
+
|
103
|
+
300, 300,
|
104
|
+
|
105
|
+
hClientWindow, hIns, 0
|
106
|
+
|
107
|
+
);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
hBitmap = LoadBitmap(
|
120
|
+
|
121
|
+
((LPCREATESTRUCT)lp)->hInstance,
|
122
|
+
|
123
|
+
TEXT("IDB_BITMAP2")
|
124
|
+
|
125
|
+
);
|
126
|
+
|
127
|
+
hToolbar = CreateToolbarEx(
|
128
|
+
|
129
|
+
hWnd,
|
130
|
+
|
131
|
+
WS_CHILD | WS_VISIBLE,
|
132
|
+
|
133
|
+
IDR_TOOLBAR1,
|
134
|
+
|
135
|
+
10,
|
136
|
+
|
137
|
+
NULL,
|
138
|
+
|
139
|
+
(UINT_PTR)hBitmap,
|
140
|
+
|
141
|
+
tbs,
|
142
|
+
|
143
|
+
18,
|
144
|
+
|
145
|
+
0, 0,
|
146
|
+
|
147
|
+
16, 16,
|
148
|
+
|
149
|
+
sizeof(TBBUTTON)
|
150
|
+
|
151
|
+
);
|
152
|
+
|
153
|
+
hStatus = CreateWindowEx(
|
154
|
+
|
155
|
+
NULL,
|
156
|
+
|
157
|
+
STATUSCLASSNAME,
|
158
|
+
|
159
|
+
NULL,
|
160
|
+
|
161
|
+
WS_CHILD
|
162
|
+
|
163
|
+
| SBARS_SIZEGRIP
|
164
|
+
|
165
|
+
| CCS_BOTTOM
|
166
|
+
|
167
|
+
| WS_VISIBLE,
|
168
|
+
|
169
|
+
0, 0, 0, 0,
|
170
|
+
|
171
|
+
hWnd,
|
172
|
+
|
173
|
+
(HMENU)ID_STATUS,
|
174
|
+
|
175
|
+
((LPCREATESTRUCT)lp)->hInstance,
|
176
|
+
|
177
|
+
NULL
|
178
|
+
|
179
|
+
);
|
180
|
+
|
181
|
+
return 0;
|
182
|
+
|
183
|
+
case WM_SIZE:
|
184
|
+
|
185
|
+
int wx, wy, sx, sy;
|
186
|
+
|
187
|
+
RECT rc;
|
188
|
+
|
189
|
+
GetWindowRect(hToolbar, &rc);
|
190
|
+
|
191
|
+
SendMessage(hToolbar, WM_SIZE, wp, lp);
|
192
|
+
|
193
|
+
SendMessage(hStatus, msg, wp, lp);
|
194
|
+
|
195
|
+
SbSize[0] = LOWORD(lp) - 400;
|
196
|
+
|
197
|
+
SbSize[1] = -1;
|
198
|
+
|
199
|
+
SendMessage(hStatus, SB_SETPARTS, 2, (LPARAM)SbSize);
|
200
|
+
|
201
|
+
//文字を挿入
|
202
|
+
|
203
|
+
SendMessage(hStatus, SB_SETTEXT, 0 | 1, (WPARAM)TEXT("マップのサイズ:100x40 グリッドのサイズ:16x16"));
|
204
|
+
|
205
|
+
SendMessage(hStatus, SB_SETTEXT, 0 | 0, (WPARAM)TEXT("X:0 Y:0 種類:0 横幅:16 高さ:16"));
|
206
|
+
|
207
|
+
SendMessage(hStatus, WM_SIZE, wp, lp);
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
GetWindowRect(hStatus, &rc);
|
212
|
+
|
213
|
+
sx = rc.right - rc.left;
|
214
|
+
|
215
|
+
sy = rc.bottom - rc.top;
|
216
|
+
|
217
|
+
wx = LOWORD(lp);
|
218
|
+
|
219
|
+
wy = HIWORD(lp);
|
220
|
+
|
221
|
+
wy -= sy;
|
222
|
+
|
223
|
+
MoveWindow(hClientWindow, 0, 30, wx, wy-30, TRUE);
|
224
|
+
|
225
|
+
return 0;
|
226
|
+
|
227
|
+
case WM_PAINT:
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
break;
|
232
|
+
|
233
|
+
case WM_COMMAND:
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
switch (LOWORD(wp))
|
238
|
+
|
239
|
+
{
|
240
|
+
|
241
|
+
case IDM_NEWMINIMAP:
|
242
|
+
|
243
|
+
//チェックがついている
|
244
|
+
|
245
|
+
if (GetMenuState(GetMenu(hWnd), IDM_NEWMINIMAP, MF_BYCOMMAND) & MFS_CHECKED) {
|
246
|
+
|
247
|
+
SendMessage(hClientWindow, WM_MDIDESTROY, (WPARAM)hCHildWndMap, 0);
|
248
|
+
|
249
|
+
CheckMenuItem(GetMenu(hWnd), IDM_NEWMINIMAP, MFS_UNCHECKED);
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
else {//ついていない
|
254
|
+
|
255
|
+
hCHildWndMap = CreateMDIWindow(MDI_CHILD, TEXT("ミニマップ"), 0,
|
256
|
+
|
257
|
+
0, 0,
|
258
|
+
|
259
|
+
300, 300,
|
260
|
+
|
261
|
+
hClientWindow, hIns, 0
|
262
|
+
|
263
|
+
);
|
264
|
+
|
265
|
+
CheckMenuItem(GetMenu(hWnd), IDM_NEWMINIMAP, MFS_CHECKED);
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
break;
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
return DefFrameProc(hWnd, hClientWindow, msg, wp, lp);
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
280
|
+
|
281
|
+
PSTR lpCmdLine, int nCmdShow) {
|
282
|
+
|
283
|
+
HWND hWnd;
|
284
|
+
|
285
|
+
MSG msg;
|
286
|
+
|
287
|
+
WNDCLASS winc;
|
288
|
+
|
289
|
+
hIns = hInstance;
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
...
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
winc.lpfnWndProc = DefMDIChildProc;
|
298
|
+
|
299
|
+
winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
300
|
+
|
301
|
+
winc.lpszClassName = MDI_CHILD;
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
if (!RegisterClass(&winc)) return 1;
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
hWnd = CreateWindow(
|
312
|
+
|
313
|
+
MDI_FRAME, TITLE,
|
314
|
+
|
315
|
+
WS_OVERLAPPEDWINDOW|WS_MAXIMIZE|WS_VISIBLE|WS_CLIPCHILDREN,
|
316
|
+
|
317
|
+
CW_USEDEFAULT, CW_USEDEFAULT,
|
318
|
+
|
319
|
+
CW_USEDEFAULT, CW_USEDEFAULT,
|
320
|
+
|
321
|
+
NULL, NULL, hInstance, NULL
|
322
|
+
|
323
|
+
);
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
...
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
return msg.wParam;
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
```
|