source: dev/trunk/abdev/ProjectEditor/DrawWindow.cpp@ 219

Last change on this file since 219 was 3, checked in by dai_9181, 18 years ago
File size: 56.7 KB
Line 
1#include "Common.h"
2
3void DrawLineInClient(int WndNum,long StartX,long StartY,long EndX,long EndY){
4 extern MDIINFO MdiInfo[MAX_WNDNUM];
5 MoveToEx(MdiInfo[WndNum].MdiRadInfo->hMemDC,
6 StartX+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
7 StartY+MdiInfo[WndNum].MdiRadInfo->ClientPos.y,
8 NULL);
9 LineTo(MdiInfo[WndNum].MdiRadInfo->hMemDC,
10 EndX+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
11 EndY+MdiInfo[WndNum].MdiRadInfo->ClientPos.y);
12}
13void DrawRectangleInClient(int WndNum,long left,long top,long right,long bottom,COLORREF RGB_Pen,COLORREF RGB_Brush,BOOL bBrushing){
14 extern MDIINFO MdiInfo[MAX_WNDNUM];
15 HPEN hPen,hOldPen;
16 HBRUSH hBrush,hOldBrush;
17
18 hPen=CreatePen(PS_SOLID,0,RGB_Pen);
19 if(bBrushing) hBrush=CreateSolidBrush(RGB_Brush);
20 else hBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
21 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
22 hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hBrush);
23
24 Rectangle(MdiInfo[WndNum].MdiRadInfo->hMemDC,
25 left+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
26 top+MdiInfo[WndNum].MdiRadInfo->ClientPos.y,
27 right+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
28 bottom+MdiInfo[WndNum].MdiRadInfo->ClientPos.y);
29
30 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
31 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldBrush);
32 DeleteObject(hPen);
33 if(bBrushing) DeleteObject(hBrush);
34}
35void DrawButtonEdge(int WndNum,POINT *pPos,SIZE *pSize){
36 extern MDIINFO MdiInfo[MAX_WNDNUM];
37 HPEN hPen,hOldPen;
38
39 //光源方向の縁
40 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
41 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
42 DrawLineInClient(WndNum,
43 pPos->x, pPos->y,
44 pPos->x+pSize->cx-1, pPos->y);
45 DrawLineInClient(WndNum,
46 pPos->x, pPos->y,
47 pPos->x, pPos->y+pSize->cy-1);
48 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
49 DeleteObject(hPen);
50
51 //影側の縁
52 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DDKSHADOW));
53 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
54 DrawLineInClient(WndNum,
55 pPos->x, pPos->y+pSize->cy-1,
56 pPos->x+pSize->cx, pPos->y+pSize->cy-1);
57 DrawLineInClient(WndNum,
58 pPos->x+pSize->cx-1, pPos->y,
59 pPos->x+pSize->cx-1, pPos->y+pSize->cy-1);
60 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
61 DeleteObject(hPen);
62
63 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW));
64 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
65 DrawLineInClient(WndNum,
66 pPos->x+1, pPos->y+pSize->cy-2,
67 pPos->x+pSize->cx-1, pPos->y+pSize->cy-2);
68 DrawLineInClient(WndNum,
69 pPos->x+pSize->cx-2, pPos->y+1,
70 pPos->x+pSize->cx-2, pPos->y+pSize->cy-2);
71 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
72 DeleteObject(hPen);
73
74 //内部
75 DrawRectangleInClient(WndNum,
76 pPos->x+1,pPos->y+1,
77 pPos->x+pSize->cx-2,pPos->y+pSize->cy-2,
78 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
79
80 pPos->x+=3;
81 pPos->y+=2;
82 pSize->cx-=5;
83 pSize->cy-=4;
84}
85void DrawItemEdgeByExStyle(int WndNum,int ExStyle,POINT *pPos,SIZE *pSize){
86 extern MDIINFO MdiInfo[MAX_WNDNUM];
87 HPEN hPen,hOldPen;
88 RECT rect;
89
90 if(ExStyle&WS_EX_DLGMODALFRAME){
91 ///////////////////////////
92 //モーダル フレーム境界線
93
94 rect.left=pPos->x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
95 rect.top=pPos->y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
96 rect.right=pPos->x+pSize->cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
97 rect.bottom=pPos->y+pSize->cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
98 DrawEdge(MdiInfo[WndNum].MdiRadInfo->hMemDC,&rect,EDGE_RAISED,BF_RECT);
99 pPos->x+=2;
100 pPos->y+=2;
101 pSize->cx-=4;
102 pSize->cy-=4;
103
104 //細枠
105 DrawRectangleInClient(WndNum,
106 pPos->x,pPos->y,
107 pPos->x+pSize->cx,pPos->y+pSize->cy,
108 GetSysColor(COLOR_ACTIVEBORDER),0,0);
109
110 pPos->x+=1;
111 pPos->y+=1;
112 pSize->cx-=2;
113 pSize->cy-=2;
114 }
115 else if(ExStyle&WS_EX_STATICEDGE){
116 //////////////////////
117 //スタティック境界線
118
119 //影側の色
120 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW));
121 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
122 DrawLineInClient(WndNum,
123 pPos->x,
124 pPos->y,
125 pPos->x,
126 pPos->y+pSize->cy-1);
127 DrawLineInClient(WndNum,
128 pPos->x,
129 pPos->y,
130 pPos->x+pSize->cx-1,
131 pPos->y);
132 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
133 DeleteObject(hPen);
134
135 //光源方向の縁
136 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
137 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
138 DrawLineInClient(WndNum,
139 pPos->x,
140 pPos->y+pSize->cy-1,
141 pPos->x+pSize->cx-1,
142 pPos->y+pSize->cy-1);
143 DrawLineInClient(WndNum,
144 pPos->x+pSize->cx-1,
145 pPos->y,
146 pPos->x+pSize->cx-1,
147 pPos->y+pSize->cy);
148 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
149 DeleteObject(hPen);
150
151 pPos->x+=1;
152 pPos->y+=1;
153 pSize->cx-=2;
154 pSize->cy-=2;
155 }
156 if(ExStyle&WS_EX_CLIENTEDGE){
157 //////////////////////
158 //クライアント境界線
159
160 rect.left=pPos->x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
161 rect.top=pPos->y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
162 rect.right=pPos->x+pSize->cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
163 rect.bottom=pPos->y+pSize->cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
164 DrawEdge(MdiInfo[WndNum].MdiRadInfo->hMemDC,&rect,EDGE_SUNKEN,BF_RECT);
165 pPos->x+=2;
166 pPos->y+=2;
167 pSize->cx-=4;
168 pSize->cy-=4;
169 }
170}
171void DrawScrollBar(int WndNum,DWORD style,BOOL bSwitch,POINT *pPos,SIZE *pSize){
172 extern PROJECTINFO ProjectInfo;
173 extern MDIINFO MdiInfo[MAX_WNDNUM];
174 int i,i2;
175 HPEN hPen,hOldPen;
176 COLORREF rgb;
177 POINT pos;
178 SIZE size;
179
180 if(bSwitch==0){
181 //水平スクロールバー
182
183 //左ボタン
184 if(pSize->cx>16*2){
185 pos=*pPos;
186 size.cx=16;
187 size.cy=pSize->cy;
188 }
189 else{
190 pos=*pPos;
191 size.cx=pSize->cx/2;
192 size.cy=pSize->cy;
193 }
194 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
195
196 //内部
197 DrawRectangleInClient(WndNum,
198 pos.x,pos.y,
199 pos.x+size.cx,pos.y+size.cy,
200 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
201
202 if(style&WS_DISABLED){
203 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
204 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
205 pos.x++;
206 pos.y++;
207 i2=pos.y+(size.cy/2);
208 for(i=0;i<4;i++,i2--){
209 DrawLineInClient(WndNum,i+pos.x+2,i2,i+pos.x+2,i2+(i*2)+1);
210 }
211 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
212 DeleteObject(hPen);
213 rgb=GetSysColor(COLOR_GRAYTEXT);
214 pos.x--;
215 pos.y--;
216 }
217 else rgb=GetSysColor(COLOR_BTNTEXT);
218 hPen=CreatePen(PS_SOLID,0,rgb);
219 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
220 i2=pos.y+(size.cy/2);
221 for(i=0;i<4;i++,i2--){
222 DrawLineInClient(WndNum,i+pos.x+2,i2,i+pos.x+2,i2+(i*2)+1);
223 }
224 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
225 DeleteObject(hPen);
226
227 //右ボタン
228 if(pSize->cx>16*2){
229 pos.x=pPos->x+pSize->cx-16;
230 pos.y=pPos->y;
231 size.cx=16;
232 size.cy=pSize->cy;
233 }
234 else{
235 pos.x=pPos->x+pSize->cx/2+pSize->cx%2;
236 pos.y=pPos->y;
237 size.cx=pSize->cx/2;
238 size.cy=pSize->cy;
239 }
240 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
241
242 //内部
243 DrawRectangleInClient(WndNum,
244 pos.x,pos.y,
245 pos.x+size.cx,pos.y+size.cy,
246 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
247
248 if(style&WS_DISABLED){
249 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
250 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
251 pos.x++;
252 pos.y++;
253 i2=pos.y+(size.cy/2);
254 for(i=3;i>=0;i--,i2--){
255 DrawLineInClient(WndNum,i+pos.x+3,i2,i+pos.x+3,i2+((3-i)*2)+1);
256 }
257 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
258 DeleteObject(hPen);
259 rgb=GetSysColor(COLOR_GRAYTEXT);
260 pos.x--;
261 pos.y--;
262 }
263 else rgb=GetSysColor(COLOR_BTNTEXT);
264 hPen=CreatePen(PS_SOLID,0,rgb);
265 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
266 i2=pos.y+(size.cy/2);
267 for(i=3;i>=0;i--,i2--){
268 DrawLineInClient(WndNum,i+pos.x+3,i2,i+pos.x+3,i2+((3-i)*2)+1);
269 }
270 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
271 DeleteObject(hPen);
272
273 if(pSize->cx>16*3){
274 if(!(style&WS_DISABLED)){
275 pos.x=pPos->x+16;
276 pos.y=pPos->y;
277 size.cx=16;
278 size.cy=pSize->cy;
279 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
280
281 //内部
282 DrawRectangleInClient(WndNum,
283 pos.x,pos.y,
284 pos.x+size.cx,pos.y+size.cy,
285 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
286
287 pos.x=pPos->x+16*2;
288 pos.y=pPos->y;
289 size.cx=pSize->cx-16*3;
290 size.cy=pSize->cy;
291 }
292 else{
293 pos.x=pPos->x+16;
294 pos.y=pPos->y;
295 size.cx=pSize->cx-16*2;
296 size.cy=pSize->cy;
297 }
298 }
299 else if(pSize->cx>16*2){
300 pos.x=pPos->x+16;
301 pos.y=pPos->y;
302 size.cx=pSize->cx-16*2;
303 size.cy=pSize->cy;
304 }
305 else{
306 pos.x=pPos->x+pSize->cx/2;
307 pos.y=pPos->y;
308 size.cx=pSize->cx%2;
309 size.cy=pSize->cy;
310 }
311 }
312 else{
313 //垂直スクロールバー
314
315 //上ボタン
316 if(pSize->cy>16*2){
317 pos=*pPos;
318 size.cy=16;
319 size.cx=pSize->cx;
320 }
321 else{
322 pos=*pPos;
323 size.cy=pSize->cy/2;
324 size.cx=pSize->cx;
325 }
326 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
327
328 //内部
329 DrawRectangleInClient(WndNum,
330 pos.x,pos.y,
331 pos.x+size.cx,pos.y+size.cy,
332 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
333
334 pos.y++;
335 if(style&WS_DISABLED){
336 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
337 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
338 pos.x++;
339 pos.y++;
340 i2=pos.x+(size.cx/2)-1;
341 for(i=0;i<4;i++,i2--){
342 DrawLineInClient(WndNum,i2,i+pos.y+2,i2+(i*2)+1,i+pos.y+2);
343 }
344 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
345 DeleteObject(hPen);
346 rgb=GetSysColor(COLOR_GRAYTEXT);
347 pos.x--;
348 pos.y--;
349 }
350 else rgb=GetSysColor(COLOR_BTNTEXT);
351 hPen=CreatePen(PS_SOLID,0,rgb);
352 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
353 i2=pos.x+(size.cx/2)-1;
354 for(i=0;i<4;i++,i2--){
355 DrawLineInClient(WndNum,i2,i+pos.y+2,i2+(i*2)+1,i+pos.y+2);
356 }
357 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
358 DeleteObject(hPen);
359
360 //下ボタン
361 if(pSize->cy>16*2){
362 pos.x=pPos->x;
363 pos.y=pPos->y+pSize->cy-16;
364 size.cx=pSize->cx;
365 size.cy=16;
366 }
367 else{
368 pos.x=pPos->x;
369 pos.y=pPos->y+pSize->cy/2+pSize->cy%2;
370 size.cx=pSize->cx;
371 size.cy=pSize->cy/2;
372 }
373 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
374
375 //内部
376 DrawRectangleInClient(WndNum,
377 pos.x,pos.y,
378 pos.x+size.cx,pos.y+size.cy,
379 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
380
381 pos.x--;
382 if(style&WS_DISABLED){
383 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
384 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
385 pos.x++;
386 pos.y++;
387 i2=pos.x+(size.cx/2);
388 for(i=3;i>=0;i--,i2--){
389 DrawLineInClient(WndNum,i2,i+pos.y+3,i2+((3-i)*2)+1,i+pos.y+3);
390 }
391 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
392 DeleteObject(hPen);
393 rgb=GetSysColor(COLOR_GRAYTEXT);
394 pos.x--;
395 pos.y--;
396 }
397 else rgb=GetSysColor(COLOR_BTNTEXT);
398 hPen=CreatePen(PS_SOLID,0,rgb);
399 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
400 i2=pos.x+(size.cx/2);
401 for(i=3;i>=0;i--,i2--){
402 DrawLineInClient(WndNum,i2,i+pos.y+3,i2+((3-i)*2)+1,i+pos.y+3);
403 }
404 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
405 DeleteObject(hPen);
406
407 if(pSize->cy>16*3){
408 if(!(style&WS_DISABLED)){
409 pos.x=pPos->x;
410 pos.y=pPos->y+16;
411 size.cx=pSize->cx;
412 size.cy=16;
413 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
414
415 //内部
416 DrawRectangleInClient(WndNum,
417 pos.x,pos.y,
418 pos.x+size.cx,pos.y+size.cy,
419 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
420
421 pos.x=pPos->x;
422 pos.y=pPos->y+16*2;
423 size.cx=pSize->cx;
424 size.cy=pSize->cy-16*3;
425 }
426 else{
427 pos.x=pPos->x;
428 pos.y=pPos->y+16;
429 size.cx=pSize->cx;
430 size.cy=pSize->cy-16*2;
431 }
432 }
433 else if(pSize->cy>16*2){
434 pos.x=pPos->x;
435 pos.y=pPos->y+16;
436 size.cx=pSize->cx;
437 size.cy=pSize->cy-16*2;
438 }
439 else{
440 pos.x=pPos->x;
441 pos.y=pPos->y+pSize->cy/2;
442 size.cx=pSize->cx;
443 size.cy=pSize->cy%2;
444 }
445 }
446
447 if(size.cx){
448 int x,y;
449 HBITMAP hBitmap;
450 BITMAPINFO BitmapInfo;
451 BYTE *pByte;
452
453 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
454 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
455 BitmapInfo.bmiHeader.biWidth=size.cx;
456 BitmapInfo.bmiHeader.biHeight=size.cy;
457 BitmapInfo.bmiHeader.biPlanes=1;
458 BitmapInfo.bmiHeader.biBitCount=24;
459
460 hBitmap=CreateDIBSection(MdiInfo[WndNum].MdiRadInfo->hMemDC,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
461 i=BitmapInfo.bmiHeader.biWidth*3;
462 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
463 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
464 if(y%2==0) rgb=GetSysColor(COLOR_3DFACE);
465 else rgb=RGB(255,255,255);
466 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
467 i2=y*i+x*3;
468 pByte[i2+2]=LOBYTE(LOWORD(rgb));
469 pByte[i2+1]=HIBYTE(LOWORD(rgb));
470 pByte[i2]=LOBYTE(HIWORD(rgb));
471 if(rgb==RGB(255,255,255)) rgb=GetSysColor(COLOR_3DFACE);
472 else rgb=RGB(255,255,255);
473 }
474 }
475 SetDIBitsToDevice(MdiInfo[WndNum].MdiRadInfo->hMemDC,
476 pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
477 pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y,
478 BitmapInfo.bmiHeader.biWidth, BitmapInfo.bmiHeader.biHeight,
479 0,0,
480 0,BitmapInfo.bmiHeader.biHeight,
481 pByte,
482 &BitmapInfo,
483 DIB_RGB_COLORS);
484 DeleteObject(hBitmap);
485 }
486}
487void DrawUpDownControl(int WndNum,DWORD style,BOOL bSwitch,POINT *pPos,SIZE *pSize){
488 extern PROJECTINFO ProjectInfo;
489 extern MDIINFO MdiInfo[MAX_WNDNUM];
490 int i,i2;
491 HPEN hPen,hOldPen;
492 COLORREF rgb;
493 POINT pos;
494 SIZE size;
495
496 if(bSwitch==0){
497 //水平
498
499 //左ボタン
500 pos=*pPos;
501 size.cx=pSize->cx/2;
502 size.cy=pSize->cy;
503 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
504
505 //内部
506 DrawRectangleInClient(WndNum,
507 pos.x,pos.y,
508 pos.x+size.cx,pos.y+size.cy,
509 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
510
511 if(style&WS_DISABLED){
512 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
513 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
514 pos.x++;
515 pos.y++;
516 i2=pos.y+(size.cy/2);
517 for(i=0;i<4;i++,i2--){
518 DrawLineInClient(WndNum,i+pos.x+2,i2,i+pos.x+2,i2+(i*2)+1);
519 }
520 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
521 DeleteObject(hPen);
522 rgb=GetSysColor(COLOR_GRAYTEXT);
523 pos.x--;
524 pos.y--;
525 }
526 else rgb=GetSysColor(COLOR_BTNTEXT);
527 hPen=CreatePen(PS_SOLID,0,rgb);
528 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
529 i2=pos.y+(size.cy/2);
530 for(i=0;i<4;i++,i2--){
531 DrawLineInClient(WndNum,i+pos.x+2,i2,i+pos.x+2,i2+(i*2)+1);
532 }
533 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
534 DeleteObject(hPen);
535
536 //右ボタン
537 pos.x=pPos->x+pSize->cx/2+pSize->cx%2;
538 pos.y=pPos->y;
539 size.cx=pSize->cx/2;
540 size.cy=pSize->cy;
541 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
542
543 //内部
544 DrawRectangleInClient(WndNum,
545 pos.x,pos.y,
546 pos.x+size.cx,pos.y+size.cy,
547 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
548
549 if(style&WS_DISABLED){
550 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
551 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
552 pos.x++;
553 pos.y++;
554 i2=pos.y+(size.cy/2);
555 for(i=3;i>=0;i--,i2--){
556 DrawLineInClient(WndNum,i+pos.x+3,i2,i+pos.x+3,i2+((3-i)*2)+1);
557 }
558 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
559 DeleteObject(hPen);
560 rgb=GetSysColor(COLOR_GRAYTEXT);
561 pos.x--;
562 pos.y--;
563 }
564 else rgb=GetSysColor(COLOR_BTNTEXT);
565 hPen=CreatePen(PS_SOLID,0,rgb);
566 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
567 i2=pos.y+(size.cy/2);
568 for(i=3;i>=0;i--,i2--){
569 DrawLineInClient(WndNum,i+pos.x+3,i2,i+pos.x+3,i2+((3-i)*2)+1);
570 }
571 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
572 DeleteObject(hPen);
573 }
574 else{
575 //垂直
576
577 //上ボタン
578 pos=*pPos;
579 size.cy=pSize->cy/2;
580 size.cx=pSize->cx;
581 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
582
583 //内部
584 DrawRectangleInClient(WndNum,
585 pos.x,pos.y,
586 pos.x+size.cx,pos.y+size.cy,
587 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
588
589 pos.y++;
590 if(style&WS_DISABLED){
591 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
592 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
593 pos.x++;
594 pos.y++;
595 i2=pos.x+(size.cx/2)-1;
596 for(i=0;i<4;i++,i2--){
597 DrawLineInClient(WndNum,i2,i+pos.y+2,i2+(i*2)+1,i+pos.y+2);
598 }
599 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
600 DeleteObject(hPen);
601 rgb=GetSysColor(COLOR_GRAYTEXT);
602 pos.x--;
603 pos.y--;
604 }
605 else rgb=GetSysColor(COLOR_BTNTEXT);
606 hPen=CreatePen(PS_SOLID,0,rgb);
607 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
608 i2=pos.x+(size.cx/2)-1;
609 for(i=0;i<4;i++,i2--){
610 DrawLineInClient(WndNum,i2,i+pos.y+2,i2+(i*2)+1,i+pos.y+2);
611 }
612 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
613 DeleteObject(hPen);
614
615 //下ボタン
616 pos.x=pPos->x;
617 pos.y=pPos->y+pSize->cy/2+pSize->cy%2;
618 size.cx=pSize->cx;
619 size.cy=pSize->cy/2;
620 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos,&size);
621
622 //内部
623 DrawRectangleInClient(WndNum,
624 pos.x,pos.y,
625 pos.x+size.cx,pos.y+size.cy,
626 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
627
628 pos.x--;
629 if(style&WS_DISABLED){
630 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
631 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
632 pos.x++;
633 pos.y++;
634 i2=pos.x+(size.cx/2);
635 for(i=3;i>=0;i--,i2--){
636 DrawLineInClient(WndNum,i2,i+pos.y+3,i2+((3-i)*2)+1,i+pos.y+3);
637 }
638 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
639 DeleteObject(hPen);
640 rgb=GetSysColor(COLOR_GRAYTEXT);
641 pos.x--;
642 pos.y--;
643 }
644 else rgb=GetSysColor(COLOR_BTNTEXT);
645 hPen=CreatePen(PS_SOLID,0,rgb);
646 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hPen);
647 i2=pos.x+(size.cx/2);
648 for(i=3;i>=0;i--,i2--){
649 DrawLineInClient(WndNum,i2,i+pos.y+3,i2+((3-i)*2)+1,i+pos.y+3);
650 }
651 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldPen);
652 DeleteObject(hPen);
653 }
654}
655void DrawWindowScrollBar(int WndNum,DWORD style,POINT *pPos,SIZE *pSize){
656 POINT pos;
657 SIZE size;
658 if(style&WS_HSCROLL){
659 pos.x=pPos->x;
660 pos.y=pPos->y+pSize->cy-GetSystemMetrics(SM_CYVSCROLL);
661 if(style&WS_VSCROLL) size.cx=pSize->cx-GetSystemMetrics(SM_CXVSCROLL);
662 else size.cx=pSize->cx;
663 size.cy=GetSystemMetrics(SM_CYVSCROLL);
664 DrawScrollBar(WndNum,style,0,&pos,&size);
665 }
666 if(style&WS_VSCROLL){
667 pos.x=pPos->x+pSize->cx-GetSystemMetrics(SM_CXHSCROLL);
668 pos.y=pPos->y;
669 size.cx=GetSystemMetrics(SM_CXHSCROLL);
670 if(style&WS_HSCROLL) size.cy=pSize->cy-GetSystemMetrics(SM_CYHSCROLL);
671 else size.cy=pSize->cy;
672 DrawScrollBar(WndNum,style,1,&pos,&size);
673 }
674}
675void DrawOEMImage(HDC hdc,POINT *pPos,SIZE *pSize,DWORD dwImage){
676 HBITMAP hBmp,hOldBmp;
677 HDC memdc;
678
679 //未完成(XPのみに対応?)
680
681 memdc=CreateCompatibleDC(hdc);
682 hBmp=LoadBitmap(NULL,(LPSTR)dwImage);
683 hOldBmp=(HBITMAP)SelectObject(memdc,hBmp);
684 BitBlt(hdc,pPos->x,pPos->y,pSize->cx,pSize->cy,memdc,0,0,SRCCOPY);
685 SelectObject(memdc,hOldBmp);
686 DeleteDC(memdc);
687 DeleteObject(hBmp);
688}
689void DesigningWindow(int WndNum,HDC hdc,POINT *pBasePos,WINDOW_INFO *pWindowInfo){
690 extern MDIINFO MdiInfo[MAX_WNDNUM];
691 extern PROJECTINFO ProjectInfo;
692 int i,i2,i3,i4;
693 double red,green,blue,d_red,d_green,d_blue;
694 char temporary[MAX_PATH];
695 COLORREF rgb;
696 HPEN hPen,hOldPen;
697 HBRUSH hBrush,hOldBrush;
698 HFONT hFont,hOldFont;
699 HANDLE hImage;
700 RECT InsideRect,rect,rc2;
701 POINT pos,pos2;
702 SIZE size,size2;
703
704 HGLOBAL hResource;
705 BITMAPINFO *pBitmapInfo;
706 BYTE *pByte,*pByte2;
707
708
709 ////////////////////////
710 //ウィンドウの縁を描画
711 InsideRect.left=pBasePos->x;
712 InsideRect.top=pBasePos->y;
713 InsideRect.right=InsideRect.left+pWindowInfo->size.cx;
714 InsideRect.bottom=InsideRect.top+pWindowInfo->size.cy;
715
716 if(pWindowInfo->style&(WS_BORDER|WS_THICKFRAME)){
717 DrawEdge(hdc,&InsideRect,EDGE_RAISED,BF_RECT);
718
719 InsideRect.left+=2;
720 InsideRect.top+=2;
721 InsideRect.right-=2;
722 InsideRect.bottom-=2;
723 }
724
725
726 ////////////
727 //枠を描画
728 if(pWindowInfo->style&(WS_BORDER|WS_THICKFRAME)){
729 //細枠
730 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_ACTIVEBORDER));
731 hBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
732 hOldPen=(HPEN)SelectObject(hdc,hPen);
733 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
734 Rectangle(hdc,InsideRect.left,InsideRect.top,InsideRect.right,InsideRect.bottom);
735
736 InsideRect.left+=1;
737 InsideRect.top+=1;
738 InsideRect.right-=1;
739 InsideRect.bottom-=1;
740
741 //サイズ変更枠
742 if(pWindowInfo->style&WS_THICKFRAME){
743 Rectangle(hdc,InsideRect.left,InsideRect.top,InsideRect.right,InsideRect.bottom);
744
745 InsideRect.left+=1;
746 InsideRect.top+=1;
747 InsideRect.right-=1;
748 InsideRect.bottom-=1;
749 }
750 SelectObject(hdc,hOldPen);
751 SelectObject(hdc,hOldBrush);
752 DeleteObject(hPen);
753 DeleteObject(hBrush);
754 }
755
756
757 //Draw...InClient関数のため
758 MdiInfo[WndNum].MdiRadInfo->ClientPos.x=0;
759 MdiInfo[WndNum].MdiRadInfo->ClientPos.y=0;
760
761 if(pWindowInfo->style&(WS_CAPTION&(~WS_BORDER))){
762 //////////////////////
763 //タイトルバーを描画
764
765 //背景を描画(グラデーション可)
766 i=GetSysColor(COLOR_ACTIVECAPTION);
767 OSVERSIONINFO OsVersionInfo;
768 OsVersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
769 GetVersionEx(&OsVersionInfo);
770 if((OsVersionInfo.dwPlatformId==VER_PLATFORM_WIN32_NT&&OsVersionInfo.dwMajorVersion>=5)||
771 (OsVersionInfo.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS&&LOWORD(OsVersionInfo.dwBuildNumber)>=1998)){
772#define COLOR_GRADIENTACTIVECAPTION 27
773 i2=GetSysColor(COLOR_GRADIENTACTIVECAPTION);
774 }
775 else i2=i;
776 if(pWindowInfo->ExStyle&WS_EX_TOOLWINDOW)
777 i3=GetSystemMetrics(SM_CYSMCAPTION);
778 else i3=GetSystemMetrics(SM_CYCAPTION);
779 d_red=((double)((i2&0xFF)-(i&0xFF)))/(double)(InsideRect.right-InsideRect.left);
780 d_green=((double)(((i2>>8)&0xFF))-((i>>8)&0xFF))/(double)(InsideRect.right-InsideRect.left);
781 d_blue=((double)(((i2>>16)&0xFF))-((i>>16)&0xFF))/(double)(InsideRect.right-InsideRect.left);
782
783 red=(double)(i&0xFF);
784 green=(double)((i>>8)&0xFF);
785 blue=(double)((i>>16)&0xFF);
786 for(i4=InsideRect.left;i4<InsideRect.right;i4++){
787 hPen=CreatePen(PS_SOLID,0,RGB((_int8)red,(_int8)green,(_int8)blue));
788 hOldPen=(HPEN)SelectObject(hdc,hPen);
789 MoveToEx(hdc,i4,InsideRect.top,NULL);
790 LineTo(hdc,i4,InsideRect.top+i3-1);
791 SelectObject(hdc,hOldPen);
792 DeleteObject(hPen);
793 red+=d_red;
794 green+=d_green;
795 blue+=d_blue;
796 }
797
798 //タイトルテキストの描画
799 LOGFONT LogFont;
800 SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(LOGFONT),&LogFont,0);
801 hFont=CreateFontIndirect(&LogFont);
802 hOldFont=(HFONT)SelectObject(hdc,hFont);
803 SetTextColor(hdc,GetSysColor(COLOR_CAPTIONTEXT));
804 rect.left=InsideRect.left+20;
805 rect.top=InsideRect.top;
806 rect.right=InsideRect.right;
807 rect.bottom=InsideRect.top+i3;
808 DrawText(hdc,pWindowInfo->caption,lstrlen(pWindowInfo->caption),&rect,DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX);
809 SelectObject(hdc,hOldFont);
810 DeleteObject(hFont);
811
812 //ボタン
813 if(pWindowInfo->style&WS_SYSMENU){
814 //終了ボタン
815 size.cx=GetSystemMetrics(SM_CXSIZE)-2;
816 size.cy=GetSystemMetrics(SM_CYSIZE)-4;
817 pos.x=InsideRect.right-2-size.cx;
818 pos.y=InsideRect.top+2;
819 DrawButtonEdge(WndNum,&pos,&size);
820
821 hResource=LoadResource(hResInst,FindResource(hResInst,MAKEINTRESOURCE(IDB_TITLE_BUTTON_CLOSE),RT_BITMAP));
822 pBitmapInfo=(BITMAPINFO *)LockResource(hResource);
823 pByte=(BYTE *)pBitmapInfo+pBitmapInfo->bmiHeader.biSize;
824
825 i2=pBitmapInfo->bmiHeader.biWidth*3;
826 if(i2%sizeof(LONG)!=0) i2+=sizeof(LONG)-(i2%sizeof(LONG));
827 pByte2=(BYTE *)GlobalAlloc(GMEM_FIXED,pBitmapInfo->bmiHeader.biHeight*i2);
828 int x,y;
829 for(y=0;y<pBitmapInfo->bmiHeader.biHeight;y++){
830 if(y%2==0) rgb=GetSysColor(COLOR_3DFACE);
831 else rgb=RGB(255,255,255);
832 for(x=0;x<pBitmapInfo->bmiHeader.biWidth;x++){
833 i4=y*i2+x*3;
834 rgb=RGB(pByte[i4+2],pByte[i4+1],pByte[i4]);
835 if(rgb==RGB(0,0,0)){
836 rgb=GetSysColor(COLOR_BTNTEXT);
837 pByte2[i4+2]=LOBYTE(LOWORD(rgb));
838 pByte2[i4+1]=HIBYTE(LOWORD(rgb));
839 pByte2[i4]=LOBYTE(HIWORD(rgb));
840 }
841 else if(rgb==RGB(255,255,255)){
842 rgb=GetSysColor(COLOR_3DFACE);
843 pByte2[i4+2]=LOBYTE(LOWORD(rgb));
844 pByte2[i4+1]=HIBYTE(LOWORD(rgb));
845 pByte2[i4]=LOBYTE(HIWORD(rgb));
846 }
847 }
848 }
849 SetStretchBltMode(hdc,COLORONCOLOR);
850 StretchDIBits(hdc,
851 pos.x+(int)((double)size.cx*0.17), pos.y+(int)((double)size.cy*0.17),
852 (int)((double)size.cx*0.65)+1, (int)((double)size.cy*0.65)+1,
853 0,0,
854 pBitmapInfo->bmiHeader.biWidth,pBitmapInfo->bmiHeader.biHeight,
855 pByte2,
856 pBitmapInfo,
857 DIB_RGB_COLORS,SRCCOPY);
858 GlobalFree(pByte2);
859
860 if(pWindowInfo->style&WS_MAXIMIZEBOX||pWindowInfo->style&WS_MINIMIZEBOX){
861 //最大化ボタン
862 size.cx=GetSystemMetrics(SM_CXSIZE)-2;
863 size.cy=GetSystemMetrics(SM_CYSIZE)-4;
864 pos.x=InsideRect.right-size.cx*2-4;
865 pos.y=InsideRect.top+2;
866 DrawButtonEdge(WndNum,&pos,&size);
867 if(!(pWindowInfo->style&WS_MAXIMIZEBOX)){
868 pos.x++;
869 pos.y++;
870 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
871 hOldPen=(HPEN)SelectObject(hdc,hPen);
872 hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(NULL_BRUSH));
873 Rectangle(hdc,pos.x,pos.y,pos.x+size.cx-2,pos.y+size.cy-1);
874 MoveToEx(hdc,pos.x,pos.y+1,NULL);
875 LineTo(hdc,pos.x+size.cx-2,pos.y+1);
876 SelectObject(hdc,hOldPen);
877 SelectObject(hdc,hOldBrush);
878 DeleteObject(hPen);
879 pos.x--;
880 pos.y--;
881 rgb=GetSysColor(COLOR_GRAYTEXT);
882 }
883 else rgb=GetSysColor(COLOR_BTNTEXT);
884 hPen=CreatePen(PS_SOLID,0,rgb);
885 hOldPen=(HPEN)SelectObject(hdc,hPen);
886 hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(NULL_BRUSH));
887 Rectangle(hdc,pos.x,pos.y,pos.x+size.cx-2,pos.y+size.cy-1);
888 MoveToEx(hdc,pos.x,pos.y+1,NULL);
889 LineTo(hdc,pos.x+size.cx-2,pos.y+1);
890 SelectObject(hdc,hOldPen);
891 SelectObject(hdc,hOldBrush);
892 DeleteObject(hPen);
893
894 //最小化ボタン
895 size.cx=GetSystemMetrics(SM_CXSIZE)-2;
896 size.cy=GetSystemMetrics(SM_CYSIZE)-4;
897 pos.x=InsideRect.right-size.cx*3-4;
898 pos.y=InsideRect.top+2;
899 DrawButtonEdge(WndNum,&pos,&size);
900 if(!(pWindowInfo->style&WS_MINIMIZEBOX)){
901 pos.x++;
902 pos.y++;
903 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
904 hOldPen=(HPEN)SelectObject(hdc,hPen);
905 MoveToEx(hdc,pos.x+1,pos.y+size.cy-2,NULL);
906 LineTo(hdc,pos.x+size.cy-3,pos.y+size.cy-2);
907 MoveToEx(hdc,pos.x+1,pos.y+size.cy-3,NULL);
908 LineTo(hdc,pos.x+size.cy-3,pos.y+size.cy-3);
909 SelectObject(hdc,hOldPen);
910 DeleteObject(hPen);
911 pos.x--;
912 pos.y--;
913 rgb=GetSysColor(COLOR_GRAYTEXT);
914 }
915 else rgb=GetSysColor(COLOR_BTNTEXT);
916 hPen=CreatePen(PS_SOLID,0,rgb);
917 hOldPen=(HPEN)SelectObject(hdc,hPen);
918 MoveToEx(hdc,pos.x+1,pos.y+size.cy-2,NULL);
919 LineTo(hdc,pos.x+size.cy-3,pos.y+size.cy-2);
920 MoveToEx(hdc,pos.x+1,pos.y+size.cy-3,NULL);
921 LineTo(hdc,pos.x+size.cy-3,pos.y+size.cy-3);
922 SelectObject(hdc,hOldPen);
923 DeleteObject(hPen);
924 }
925 }
926
927 InsideRect.top+=i3;
928 }
929
930 if(pWindowInfo->MenuID){
931 //メニューラインを3DFACEで描画
932 rgb=GetSysColor(COLOR_3DFACE);
933 i=GetSystemMetrics(SM_CYMENU);
934 hPen=CreatePen(PS_SOLID,0,rgb);
935 hBrush=CreateSolidBrush(rgb);
936 hOldPen=(HPEN)SelectObject(hdc,hPen);
937 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
938 Rectangle(hdc,
939 InsideRect.left,InsideRect.top-1,InsideRect.right,InsideRect.top+i);
940 SelectObject(hdc,hOldPen);
941 SelectObject(hdc,hOldBrush);
942 DeleteObject(hPen);
943 DeleteObject(hBrush);
944
945 InsideRect.top+=i;
946 }
947
948 //クライアント左上ポジションを設定
949 MdiInfo[WndNum].MdiRadInfo->ClientPos.x=InsideRect.left;
950 MdiInfo[WndNum].MdiRadInfo->ClientPos.y=InsideRect.top;
951
952 //ExStyleによる縁を描画
953 pos.x=0;
954 pos.y=0;
955 size.cx=InsideRect.right-InsideRect.left;
956 size.cy=InsideRect.bottom-InsideRect.top;
957 DrawItemEdgeByExStyle(WndNum,pWindowInfo->ExStyle,&pos,&size);
958
959 //スクロールバーを描画
960 DrawWindowScrollBar(WndNum,pWindowInfo->style,&pos,&size);
961
962 //クライアント領域のサイズを設定
963 MdiInfo[WndNum].MdiRadInfo->ClientSize=size;
964
965
966 //////////////
967 //背景を描画
968 if(pWindowInfo->bgColor==COLOR_3DFACE){
969 //3DFACE
970 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DFACE));
971 hBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
972 hOldPen=(HPEN)SelectObject(hdc,hPen);
973 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
974 Rectangle(hdc,InsideRect.left,InsideRect.top,InsideRect.right,InsideRect.bottom);
975 SelectObject(hdc,hOldPen);
976 SelectObject(hdc,hOldBrush);
977 DeleteObject(hPen);
978 DeleteObject(hBrush);
979 }
980 else if(pWindowInfo->bgColor<=0){
981 //色指定
982 hPen=CreatePen(PS_SOLID,0,-pWindowInfo->bgColor);
983 hBrush=CreateSolidBrush(-pWindowInfo->bgColor);
984 hOldPen=(HPEN)SelectObject(hdc,hPen);
985 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
986 Rectangle(hdc,InsideRect.left,InsideRect.top,InsideRect.right,InsideRect.bottom);
987 SelectObject(hdc,hOldPen);
988 SelectObject(hdc,hOldBrush);
989 DeleteObject(hPen);
990 DeleteObject(hBrush);
991 }
992 else if(pWindowInfo->bgColor>=0x1000){
993 //ビットマップ
994 for(i2=0;i2<ProjectInfo.res.NumberOfBitmapRes;i2++){
995 if(lstrcmp(ProjectInfo.res.pBitmapResInfo[pWindowInfo->bgColor-0x1000].IdName,
996 ProjectInfo.res.pBitmapResInfo[i2].IdName)==0) break;
997 }
998 if(i2!=ProjectInfo.res.NumberOfBitmapRes){
999 lstrcpy(temporary,ProjectInfo.res.pBitmapResInfo[i2].path);
1000 GetFullPath(temporary,ProjectInfo.dir);
1001 hImage=LoadImage(NULL,temporary,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
1002
1003 hBrush=CreatePatternBrush((HBITMAP)hImage);
1004 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
1005 SetBrushOrgEx(hdc,InsideRect.left,InsideRect.top,&pos);
1006 PatBlt(hdc,
1007 InsideRect.left, InsideRect.top,
1008 InsideRect.right-InsideRect.left, InsideRect.bottom-InsideRect.top,PATCOPY);
1009 SetBrushOrgEx(hdc,pos.x,pos.y,0);
1010 SelectObject(hdc,hOldBrush);
1011 DeleteObject(hBrush);
1012 DeleteObject(hImage);
1013 }
1014 }
1015
1016
1017 ////////////////////////////////////////////
1018 //子ウィンドウ(ダイアログアイテム)を描画
1019 hFont=CreateFontIndirect(&pWindowInfo->LogFont);
1020 for(i=0;i<pWindowInfo->NumberOfChildWindows;i++){
1021 pos=pWindowInfo->pChildInfo[i].pos;
1022 size=pWindowInfo->pChildInfo[i].size;
1023
1024 //ExStyleによる縁を描画
1025 DrawItemEdgeByExStyle(WndNum,pWindowInfo->pChildInfo[i].ExStyle,&pos,&size);
1026
1027 if(pWindowInfo->pChildInfo[i].Control==CT_BUTTON){
1028 ////////////////////////
1029 // Button コントロール
1030
1031 if((pWindowInfo->pChildInfo[i].style&0x0000000F)==BS_DEFPUSHBUTTON){
1032 //標準のボタンの場合(黒枠描画)
1033 DrawRectangleInClient(WndNum,
1034 pos.x, pos.y,
1035 pos.x+size.cx, pos.y+size.cy,
1036 RGB(0,0,0),0,0);
1037 pos.x++;
1038 pos.y++;
1039 size.cx-=2;
1040 size.cy-=2;
1041 }
1042
1043 //ボタンの縁を描画
1044 DrawButtonEdge(WndNum,&pos,&size);
1045
1046 if(!(pWindowInfo->pChildInfo[i].style&(BS_ICON|BS_BITMAP))){
1047 //キャプション テキスト
1048
1049 rect.left=pos.x+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1050 rect.top=pos.y+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1051 rect.right=pos.x+size.cx-2+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1052 rect.bottom=pos.y+size.cy-2+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1053
1054 if(pWindowInfo->pChildInfo[i].style&BS_MULTILINE) i4=0;
1055 else i4=DT_SINGLELINE;
1056
1057 //ビットを考慮してBS_CENTERを最初に比較する
1058 if((pWindowInfo->pChildInfo[i].style&BS_CENTER)==BS_CENTER) i2=DT_CENTER;
1059 else if(pWindowInfo->pChildInfo[i].style&BS_LEFT) i2=DT_LEFT;
1060 else if(pWindowInfo->pChildInfo[i].style&BS_RIGHT) i2=DT_RIGHT;
1061 else i2=DT_CENTER;
1062
1063 //ビットを考慮してBS_VCENTERを最初に比較する
1064 if((pWindowInfo->pChildInfo[i].style&BS_VCENTER)==BS_VCENTER) i3=DT_VCENTER;
1065 else if(pWindowInfo->pChildInfo[i].style&BS_TOP) i3=DT_TOP;
1066 else if(pWindowInfo->pChildInfo[i].style&BS_BOTTOM) i3=DT_BOTTOM;
1067 else i3=DT_VCENTER;
1068
1069 hOldFont=(HFONT)SelectObject(hdc,hFont);
1070 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED){
1071 SetTextColor(hdc,RGB(255,255,255));
1072 rc2.left=rect.left+1;
1073 rc2.top=rect.top+1;
1074 rc2.right=rect.right+1;
1075 rc2.bottom=rect.bottom+1;
1076 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rc2,i4|i2|i3);
1077 SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
1078 }
1079 else SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
1080
1081 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rect,i4|i2|i3);
1082 SelectObject(hdc,hOldFont);
1083 }
1084 }
1085 else if(pWindowInfo->pChildInfo[i].Control==CT_CHECKBOX){
1086 //////////////////////////
1087 // CheckBox コントロール
1088
1089 if(pWindowInfo->pChildInfo[i].style&BS_PUSHLIKE){
1090 //ボタンの縁を描画
1091 DrawButtonEdge(WndNum,&pos,&size);
1092 }
1093 else{
1094 //チェックボックスを描画
1095 size2.cx=13;
1096 size2.cy=13;
1097 if(pWindowInfo->pChildInfo[i].style&BS_LEFTTEXT)
1098 pos2.x=pos.x+size.cx-size2.cx;
1099 else pos2.x=pos.x;
1100 if((pWindowInfo->pChildInfo[i].style&BS_VCENTER)==BS_VCENTER||
1101 (pWindowInfo->pChildInfo[i].style&BS_VCENTER)==0)
1102 pos2.y=pos.y+(size.cy/2)-(size2.cy/2);
1103 else if(pWindowInfo->pChildInfo[i].style&BS_TOP)
1104 pos2.y=pos.y+1;
1105 else if(pWindowInfo->pChildInfo[i].style&BS_BOTTOM)
1106 pos2.y=pos.y+size.cy-size2.cy-1;
1107 DrawItemEdgeByExStyle(WndNum,WS_EX_CLIENTEDGE,&pos2,&size2);
1108
1109 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED)
1110 rgb=GetSysColor(COLOR_3DFACE);
1111 else rgb=GetSysColor(COLOR_WINDOW);
1112 DrawRectangleInClient(WndNum,pos2.x, pos2.y,
1113 pos2.x+size2.cx, pos2.y+size2.cy,
1114 rgb,rgb,1);
1115 if(!(pWindowInfo->pChildInfo[i].style&BS_LEFTTEXT)) pos.x+=17;
1116 else pos.x++;
1117 size.cx-=17;
1118 }
1119
1120 if(!(pWindowInfo->pChildInfo[i].style&(BS_ICON|BS_BITMAP))){
1121 //キャプション テキスト
1122 rect.left=pos.x+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1123 rect.top=pos.y+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1124 rect.right=pos.x+size.cx-2+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1125 rect.bottom=pos.y+size.cy-2+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1126
1127 if(pWindowInfo->pChildInfo[i].style&BS_MULTILINE) i4=0;
1128 else i4=DT_SINGLELINE;
1129
1130 //ビットを考慮してBS_CENTERを最初に比較する
1131 if((pWindowInfo->pChildInfo[i].style&BS_CENTER)==BS_CENTER) i2=DT_CENTER;
1132 else if(pWindowInfo->pChildInfo[i].style&BS_LEFT) i2=DT_LEFT;
1133 else if(pWindowInfo->pChildInfo[i].style&BS_RIGHT) i2=DT_RIGHT;
1134 else i2=DT_LEFT;
1135
1136 //ビットを考慮してBS_VCENTERを最初に比較する
1137 if((pWindowInfo->pChildInfo[i].style&BS_VCENTER)==BS_VCENTER) i3=DT_VCENTER;
1138 else if(pWindowInfo->pChildInfo[i].style&BS_TOP) i3=DT_TOP;
1139 else if(pWindowInfo->pChildInfo[i].style&BS_BOTTOM) i3=DT_BOTTOM;
1140 else i3=DT_VCENTER;
1141
1142 hOldFont=(HFONT)SelectObject(hdc,hFont);
1143 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED){
1144 SetTextColor(hdc,RGB(255,255,255));
1145 rc2.left=rect.left+1;
1146 rc2.top=rect.top+1;
1147 rc2.right=rect.right+1;
1148 rc2.bottom=rect.bottom+1;
1149 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rc2,i4|i2|i3);
1150 SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
1151 }
1152 else SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
1153
1154 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rect,i4|i2|i3);
1155 SelectObject(hdc,hOldFont);
1156 }
1157 }
1158 else if(pWindowInfo->pChildInfo[i].Control==CT_COMBOBOX){
1159 //////////////////////////
1160 // ComboBox コントロール
1161
1162 pos2=pos;
1163 size2.cx=size.cx;
1164 size2.cy=20;
1165 DrawItemEdgeByExStyle(WndNum,WS_EX_CLIENTEDGE,&pos2,&size2);
1166
1167 //内部
1168 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED)
1169 rgb=GetSysColor(COLOR_3DFACE);
1170 else rgb=GetSysColor(COLOR_WINDOW);
1171 DrawRectangleInClient(WndNum,
1172 pos2.x,pos2.y,
1173 pos2.x+size2.cx,pos2.y+size2.cy,
1174 rgb,rgb,1);
1175
1176 if((pWindowInfo->pChildInfo[i].style&0x000F)==CBS_SIMPLE){
1177 pos.y+=20;
1178 size.cy-=20;
1179 DrawItemEdgeByExStyle(WndNum,WS_EX_CLIENTEDGE,&pos,&size);
1180
1181 //内部
1182 rgb=GetSysColor(COLOR_WINDOW);
1183 DrawRectangleInClient(WndNum,
1184 pos.x,pos.y,
1185 pos.x+size.cx,pos.y+size.cy,
1186 rgb,rgb,1);
1187 }
1188 else{
1189 //下ボタン
1190 pos2.x+=size2.cx-16;
1191 size2.cx=16;
1192 size2.cy=16;
1193 DrawItemEdgeByExStyle(WndNum,WS_EX_DLGMODALFRAME,&pos2,&size2);
1194
1195 //内部
1196 DrawRectangleInClient(WndNum,
1197 pos2.x,pos2.y,
1198 pos2.x+size2.cx,pos2.y+size2.cy,
1199 GetSysColor(COLOR_3DFACE),GetSysColor(COLOR_3DFACE),1);
1200
1201 pos2.x--;
1202 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED){
1203 hPen=CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DHIGHLIGHT));
1204 hOldPen=(HPEN)SelectObject(hdc,hPen);
1205 pos2.x++;
1206 pos2.y++;
1207 i3=pos2.x+(size2.cx/2);
1208 for(i2=3;i2>=0;i2--,i3--){
1209 DrawLineInClient(WndNum,i3,i2+pos2.y+3,i3+((3-i2)*2)+1,i2+pos2.y+3);
1210 }
1211 SelectObject(hdc,hOldPen);
1212 DeleteObject(hPen);
1213 rgb=GetSysColor(COLOR_GRAYTEXT);
1214 pos2.x--;
1215 pos2.y--;
1216 }
1217 else rgb=GetSysColor(COLOR_BTNTEXT);
1218 hPen=CreatePen(PS_SOLID,0,rgb);
1219 hOldPen=(HPEN)SelectObject(hdc,hPen);
1220 i3=pos2.x+(size2.cx/2);
1221 for(i2=3;i2>=0;i2--,i3--){
1222 DrawLineInClient(WndNum,i3,i2+pos2.y+3,i3+((3-i2)*2)+1,i2+pos2.y+3);
1223 }
1224 SelectObject(hdc,hOldPen);
1225 DeleteObject(hPen);
1226 }
1227 }
1228 else if(pWindowInfo->pChildInfo[i].Control==CT_EDIT){
1229 //////////////////////
1230 // Edit コントロール
1231
1232 //内部
1233 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED||pWindowInfo->pChildInfo[i].style&ES_READONLY)
1234 rgb=GetSysColor(COLOR_3DFACE);
1235 else rgb=GetSysColor(COLOR_WINDOW);
1236 DrawRectangleInClient(WndNum,
1237 pos.x,pos.y,
1238 pos.x+size.cx,pos.y+size.cy,
1239 rgb,rgb,1);
1240
1241 //キャプション テキスト
1242 rect.left=pos.x+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1243 rect.top=pos.y+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1244 rect.right=pos.x+size.cx-1+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1245 rect.bottom=pos.y+size.cy-1+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1246
1247 if(pWindowInfo->pChildInfo[i].style&ES_MULTILINE) i4=0;
1248 else i4=DT_SINGLELINE;
1249
1250 //ビットを考慮してES_LEFTを最後に検討する
1251 if(pWindowInfo->pChildInfo[i].style&ES_CENTER) i2=DT_CENTER;
1252 else if(pWindowInfo->pChildInfo[i].style&ES_RIGHT) i2=DT_RIGHT;
1253 else i2=DT_LEFT;
1254
1255 //文字色を設定
1256 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED)
1257 SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
1258 else
1259 SetTextColor(hdc,GetSysColor(COLOR_WINDOWTEXT));
1260
1261 hOldFont=(HFONT)SelectObject(hdc,hFont);
1262 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rect,i4|i2);
1263 SelectObject(hdc,hOldFont);
1264 }
1265
1266 else if(pWindowInfo->pChildInfo[i].Control==CT_GROUPBOX){
1267 ///////////////////////////////////
1268 // グループ ボックス コントロール
1269
1270 hOldFont=(HFONT)SelectObject(hdc,hFont);
1271 GetTextExtentPoint32(hdc,pWindowInfo->pChildInfo[i].caption,lstrlen(pWindowInfo->pChildInfo[i].caption),&size2);
1272
1273 //枠を描画
1274 rect.left=pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1275 rect.top=pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y+(size2.cy/2);
1276 rect.right=pos.x+size.cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1277 rect.bottom=pos.y+size.cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1278 DrawEdge(hdc,&rect,EDGE_ETCHED,BF_RECT);
1279
1280 //ビットを考慮してBS_CENTERを最初に検討する
1281 if((pWindowInfo->pChildInfo[i].style&BS_CENTER)==BS_CENTER){
1282 rect.left=pos.x+(size.cx/2)-(size2.cx/2)-3;
1283 rect.right=rect.left+size2.cx+4;
1284 }
1285 else if(pWindowInfo->pChildInfo[i].style&BS_RIGHT){
1286 rect.right=pos.x+size.cx-7;
1287 rect.left=rect.right-size2.cx-4;
1288 }
1289 else{
1290 rect.left=pos.x+7;
1291 rect.right=rect.left+size2.cx+4;
1292 }
1293 rect.top=pos.y;
1294 rect.bottom=pos.y+size2.cy;
1295
1296 if(pWindowInfo->bgColor==COLOR_3DFACE) rgb=GetSysColor(COLOR_3DFACE);
1297 else rgb=-pWindowInfo->bgColor;
1298 DrawRectangleInClient(WndNum,rect.left,rect.top,rect.right,rect.bottom,rgb,rgb,1);
1299
1300 if(!((pWindowInfo->pChildInfo[i].style&BS_ICON)||(pWindowInfo->pChildInfo[i].style&BS_BITMAP))){
1301 rect.left+=MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1302 rect.top+=MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1303 rect.right+=MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1304 rect.bottom+=MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1305 rect.left+=2;
1306 rect.right-=2;
1307
1308 //テキストを描画
1309 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED){
1310 SetTextColor(hdc,RGB(255,255,255));
1311 rc2.left=rect.left+1;
1312 rc2.top=rect.top+1;
1313 rc2.right=rect.right+1;
1314 rc2.bottom=rect.bottom+1;
1315 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rc2,DT_SINGLELINE);
1316 SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
1317 }
1318 else
1319 SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
1320
1321 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rect,DT_SINGLELINE);
1322 }
1323 SelectObject(hdc,hOldFont);
1324 }
1325
1326 else if(pWindowInfo->pChildInfo[i].Control==CT_HSCROLLBAR){
1327 ////////////////////////////////////
1328 // 水平スクロールバー コントロール
1329 DrawScrollBar(WndNum,pWindowInfo->pChildInfo[i].style,0,&pos,&size);
1330 }
1331
1332 else if(pWindowInfo->pChildInfo[i].Control==CT_IMAGEBOX){
1333 /////////////////////
1334 // イメージ ボックス
1335 HDC memdc;
1336
1337 if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_BLACKFRAME)
1338 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,RGB(0,0,0),0,0);
1339 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_GRAYFRAME)
1340 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,GetSysColor(COLOR_3DSHADOW),0,0);
1341 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_WHITEFRAME)
1342 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,RGB(255,255,255),0,0);
1343 else if((pWindowInfo->pChildInfo[i].style&0x0000001F)==SS_ETCHEDFRAME){
1344 rect.left=pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1345 rect.top=pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1346 rect.right=pos.x+size.cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1347 rect.bottom=pos.y+size.cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1348 DrawEdge(hdc,&rect,EDGE_ETCHED,BF_RECT);
1349 }
1350 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_BLACKRECT)
1351 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,GetSysColor(COLOR_3DDKSHADOW),GetSysColor(COLOR_3DDKSHADOW),1);
1352 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_GRAYRECT)
1353 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DSHADOW),1);
1354 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_WHITERECT)
1355 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,RGB(255,255,255),RGB(255,255,255),1);
1356 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_ICON){
1357 if(pWindowInfo->pChildInfo[i].ImageCtrlInfo.type==IMGTYPE_FILE)
1358 lstrcpy(temporary,pWindowInfo->pChildInfo[i].ImageCtrlInfo.path);
1359 else{
1360 for(i2=0;i2<ProjectInfo.res.NumberOfIconRes;i2++){
1361 if(lstrcmp(pWindowInfo->pChildInfo[i].ImageCtrlInfo.path,
1362 ProjectInfo.res.pIconResInfo[i2].IdName)==0) break;
1363 }
1364 if(i2==ProjectInfo.res.NumberOfIconRes) goto NonIconImage;
1365
1366 lstrcpy(temporary,ProjectInfo.res.pIconResInfo[i2].path);
1367 }
1368 GetFullPath(temporary,ProjectInfo.dir);
1369 hImage=LoadImage(NULL,temporary,IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
1370 if(hImage){
1371 pWindowInfo->pChildInfo[i].size.cx=32+(pWindowInfo->pChildInfo[i].size.cx-size.cx);
1372 pWindowInfo->pChildInfo[i].size.cy=32+(pWindowInfo->pChildInfo[i].size.cy-size.cy);
1373 pos=pWindowInfo->pChildInfo[i].pos;
1374 size=pWindowInfo->pChildInfo[i].size;
1375
1376 //ExStyleによる縁を再描画
1377 DrawItemEdgeByExStyle(WndNum,pWindowInfo->pChildInfo[i].ExStyle,&pos,&size);
1378
1379 DrawIcon(hdc,
1380 pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
1381 pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y,
1382 (HICON)hImage);
1383 DestroyIcon((HICON)hImage);
1384 }
1385 else{
1386NonIconImage:
1387 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,RGB(0,0,0),0,0);
1388 hOldFont=(HFONT)SelectObject(hdc,hFont);
1389 rect.left=pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1390 rect.top=pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1391 rect.right=pos.x+size.cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1392 rect.bottom=pos.y+size.cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1393 SetTextColor(hdc,GetSysColor(COLOR_WINDOWTEXT));
1394 DrawText(hdc,"icon...",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
1395 SelectObject(hdc,hOldFont);
1396 }
1397 }
1398 else if((pWindowInfo->pChildInfo[i].style&0x0000000F)==SS_BITMAP){
1399 BITMAP Bitmap;
1400
1401 if(pWindowInfo->pChildInfo[i].ImageCtrlInfo.type==IMGTYPE_FILE)
1402 lstrcpy(temporary,pWindowInfo->pChildInfo[i].ImageCtrlInfo.path);
1403 else{
1404 for(i2=0;i2<ProjectInfo.res.NumberOfBitmapRes;i2++){
1405 if(lstrcmp(pWindowInfo->pChildInfo[i].ImageCtrlInfo.path,
1406 ProjectInfo.res.pBitmapResInfo[i2].IdName)==0) break;
1407 }
1408 if(i2==ProjectInfo.res.NumberOfBitmapRes) goto NonBitmapImage;
1409
1410 lstrcpy(temporary,ProjectInfo.res.pBitmapResInfo[i2].path);
1411 }
1412 GetFullPath(temporary,ProjectInfo.dir);
1413 hImage=LoadImage(NULL,temporary,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
1414 if(hImage){
1415 GetObject(hImage,sizeof(BITMAP),&Bitmap);
1416
1417 pWindowInfo->pChildInfo[i].size.cx=Bitmap.bmWidth+(pWindowInfo->pChildInfo[i].size.cx-size.cx);
1418 pWindowInfo->pChildInfo[i].size.cy=Bitmap.bmHeight+(pWindowInfo->pChildInfo[i].size.cy-size.cy);
1419 pos=pWindowInfo->pChildInfo[i].pos;
1420 size=pWindowInfo->pChildInfo[i].size;
1421
1422 //ExStyleによる縁を再描画
1423 DrawItemEdgeByExStyle(WndNum,pWindowInfo->pChildInfo[i].ExStyle,&pos,&size);
1424
1425 memdc=CreateCompatibleDC(hdc);
1426 SelectObject(memdc,hImage);
1427 BitBlt(hdc,
1428 pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
1429 pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y,
1430 size.cx, size.cy,
1431 memdc, 0,0,
1432 SRCCOPY);
1433 DeleteDC(memdc);
1434 DeleteObject(hImage);
1435 }
1436 else{
1437NonBitmapImage:
1438 DrawRectangleInClient(WndNum,pos.x,pos.y,pos.x+size.cx,pos.y+size.cy,RGB(0,0,0),0,0);
1439 hOldFont=(HFONT)SelectObject(hdc,hFont);
1440 rect.left=pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1441 rect.top=pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1442 rect.right=pos.x+size.cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1443 rect.bottom=pos.y+size.cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1444 SetTextColor(hdc,GetSysColor(COLOR_WINDOWTEXT));
1445 DrawText(hdc,"bmp...",-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
1446 SelectObject(hdc,hOldFont);
1447 }
1448 }
1449 }
1450
1451 else if(pWindowInfo->pChildInfo[i].Control==CT_LISTBOX){
1452 /////////////////////////
1453 // ListBox コントロール
1454
1455 //内部
1456 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED)
1457 rgb=GetSysColor(COLOR_3DFACE);
1458 else rgb=GetSysColor(COLOR_WINDOW);
1459 DrawRectangleInClient(WndNum,
1460 pos.x,pos.y,
1461 pos.x+size.cx,pos.y+size.cy,
1462 rgb,rgb,1);
1463
1464 if(pWindowInfo->pChildInfo[i].style&LBS_DISABLENOSCROLL)
1465 DrawWindowScrollBar(WndNum,pWindowInfo->pChildInfo[i].style|WS_DISABLED,&pos,&size);
1466 }
1467
1468 else if(pWindowInfo->pChildInfo[i].Control==CT_LISTVIEW){
1469 //////////////////////////
1470 // ListView コントロール
1471
1472 //内部
1473 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED)
1474 rgb=GetSysColor(COLOR_3DFACE);
1475 else rgb=GetSysColor(COLOR_WINDOW);
1476 DrawRectangleInClient(WndNum,
1477 pos.x,pos.y,
1478 pos.x+size.cx,pos.y+size.cy,
1479 rgb,rgb,1);
1480
1481 if((pWindowInfo->pChildInfo[i].style&LVS_REPORT)&&
1482 (!((pWindowInfo->pChildInfo[i].style&LVS_LIST)==LVS_LIST))){
1483 //レポート ビュー
1484 size.cy=16;
1485 DrawButtonEdge(WndNum,&pos,&size);
1486 }
1487 }
1488
1489 else if(pWindowInfo->pChildInfo[i].Control==CT_PROGRESSBAR){
1490 /////////////////////////////
1491 // ProgressBar コントロール
1492
1493 //内部
1494 pos.x++;
1495 pos.y++;
1496 size.cx-=2;
1497 size.cy-=2;
1498 rgb=GetSysColor(COLOR_ACTIVECAPTION);
1499 if(pWindowInfo->pChildInfo[i].style&PBS_SMOOTH){
1500 if(pWindowInfo->pChildInfo[i].style&PBS_VERTICAL){
1501 pos.y+=(long)((double)size.cy*0.3);
1502 DrawRectangleInClient(WndNum,
1503 pos.x,pos.y,
1504 pos.x+size.cx,pos.y+(long)((double)size.cy*0.7),
1505 rgb,rgb,1);
1506 }
1507 else{
1508 DrawRectangleInClient(WndNum,
1509 pos.x,pos.y,
1510 pos.x+(long)((double)size.cx*0.7),pos.y+size.cy,
1511 rgb,rgb,1);
1512 }
1513 }
1514 else{
1515 if(pWindowInfo->pChildInfo[i].style&PBS_VERTICAL){
1516 pos.y+=(long)((double)size.cy*0.3);
1517 i3=(size.cx*2)/3;
1518 i2=(int)((double)size.cy*0.7);
1519 for(;i2>i3;i2-=i3+2){
1520 DrawRectangleInClient(WndNum,
1521 pos.x,pos.y+i2-i3,
1522 pos.x+size.cx,pos.y+i2,
1523 rgb,rgb,1);
1524 }
1525 }
1526 else{
1527 i3=(size.cy*2)/3;
1528 i4=(int)((double)size.cx*0.7);
1529 for(i2=0;i2+i3<i4;i2+=i3+2){
1530 DrawRectangleInClient(WndNum,
1531 pos.x+i2,pos.y,
1532 pos.x+i2+i3,pos.y+size.cy,
1533 rgb,rgb,1);
1534 }
1535 }
1536 }
1537 }
1538
1539 else if(pWindowInfo->pChildInfo[i].Control==CT_RADIOBUTTON){
1540 /////////////////////////////
1541 // RadioButton コントロール
1542
1543 if(pWindowInfo->pChildInfo[i].style&BS_PUSHLIKE){
1544 //ボタンの縁を描画
1545 DrawButtonEdge(WndNum,&pos,&size);
1546 }
1547 else{
1548 //ラジオボタンを描画
1549 size2.cx=12;
1550 size2.cy=12;
1551 if(pWindowInfo->pChildInfo[i].style&BS_LEFTTEXT)
1552 pos2.x=pos.x+size.cx-size2.cx;
1553 else pos2.x=pos.x+1;
1554 if((pWindowInfo->pChildInfo[i].style&BS_VCENTER)==BS_VCENTER||
1555 (pWindowInfo->pChildInfo[i].style&BS_VCENTER)==0)
1556 pos2.y=pos.y+(size.cy/2)-(size2.cy/2);
1557 else if(pWindowInfo->pChildInfo[i].style&BS_TOP)
1558 pos2.y=pos.y+1;
1559 else if(pWindowInfo->pChildInfo[i].style&BS_BOTTOM)
1560 pos2.y=pos.y+size.cy-size2.cy-1;
1561
1562 hResource=LoadResource(hResInst,FindResource(hResInst,MAKEINTRESOURCE(IDB_RADIOBUTTON),RT_BITMAP));
1563 pBitmapInfo=(BITMAPINFO *)LockResource(hResource);
1564 pByte=(BYTE *)pBitmapInfo+pBitmapInfo->bmiHeader.biSize;
1565 pByte2=(BYTE *)GlobalAlloc(GMEM_FIXED,pBitmapInfo->bmiHeader.biWidth*pBitmapInfo->bmiHeader.biHeight*3);
1566 for(i2=0,i3=0;i2<pBitmapInfo->bmiHeader.biWidth*pBitmapInfo->bmiHeader.biHeight;i2++,i3+=3){
1567 rgb=RGB(pByte[i3+2],pByte[i3+1],pByte[i3]);
1568
1569 if(rgb==RGB(255,255,0)){
1570 if(pWindowInfo->bgColor==COLOR_3DFACE) rgb=GetSysColor(COLOR_3DFACE);
1571 else rgb=-pWindowInfo->bgColor;
1572 }
1573
1574 //影側
1575 else if(rgb==RGB(0,0,0)) rgb=GetSysColor(COLOR_3DSHADOW);
1576 else if(rgb==RGB(255,0,0)) rgb=GetSysColor(COLOR_3DDKSHADOW);
1577
1578 //光源側
1579 else if(rgb==RGB(0,0,255)) rgb=GetSysColor(COLOR_3DLIGHT);
1580 else if(rgb==RGB(0,255,0)) rgb=GetSysColor(COLOR_3DHIGHLIGHT);
1581
1582 //内部
1583 else if(rgb==RGB(255,255,255)){
1584 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED) rgb=GetSysColor(COLOR_3DFACE);
1585 }
1586
1587 pByte2[i3+2]=LOBYTE(LOWORD(rgb));
1588 pByte2[i3+1]=HIBYTE(LOWORD(rgb));
1589 pByte2[i3]=LOBYTE(HIWORD(rgb));
1590 }
1591 SetDIBitsToDevice(hdc,
1592 pos2.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x,
1593 pos2.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y,
1594 pBitmapInfo->bmiHeader.biWidth, pBitmapInfo->bmiHeader.biHeight,
1595 0,0,
1596 0,pBitmapInfo->bmiHeader.biHeight,
1597 pByte2,
1598 pBitmapInfo,
1599 DIB_RGB_COLORS);
1600 GlobalFree(pByte2);
1601
1602 if(!(pWindowInfo->pChildInfo[i].style&BS_LEFTTEXT)) pos.x+=17;
1603 else pos.x++;
1604 size.cx-=17;
1605 }
1606
1607 if(!(pWindowInfo->pChildInfo[i].style&(BS_ICON|BS_BITMAP))){
1608 //キャプション テキスト
1609 rect.left=pos.x+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1610 rect.top=pos.y+1+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1611 rect.right=pos.x+size.cx-2+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1612 rect.bottom=pos.y+size.cy-2+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1613
1614 if(pWindowInfo->pChildInfo[i].style&BS_MULTILINE) i4=0;
1615 else i4=DT_SINGLELINE;
1616
1617 //ビットを考慮してBS_CENTERを最初に比較する
1618 if((pWindowInfo->pChildInfo[i].style&BS_CENTER)==BS_CENTER) i2=DT_CENTER;
1619 else if(pWindowInfo->pChildInfo[i].style&BS_LEFT) i2=DT_LEFT;
1620 else if(pWindowInfo->pChildInfo[i].style&BS_RIGHT) i2=DT_RIGHT;
1621 else i2=DT_LEFT;
1622
1623 //ビットを考慮してBS_VCENTERを最初に比較する
1624 if((pWindowInfo->pChildInfo[i].style&BS_VCENTER)==BS_VCENTER) i3=DT_VCENTER;
1625 else if(pWindowInfo->pChildInfo[i].style&BS_TOP) i3=DT_TOP;
1626 else if(pWindowInfo->pChildInfo[i].style&BS_BOTTOM) i3=DT_BOTTOM;
1627 else i3=DT_VCENTER;
1628
1629 hOldFont=(HFONT)SelectObject(hdc,hFont);
1630 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED){
1631 SetTextColor(hdc,RGB(255,255,255));
1632 rc2.left=rect.left+1;
1633 rc2.top=rect.top+1;
1634 rc2.right=rect.right+1;
1635 rc2.bottom=rect.bottom+1;
1636 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rc2,i4|i2|i3);
1637 SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
1638 }
1639 else SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
1640
1641 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rect,i4|i2|i3);
1642 SelectObject(hdc,hOldFont);
1643 }
1644 }
1645
1646 else if(pWindowInfo->pChildInfo[i].Control==CT_STATIC){
1647 ////////////////////////
1648 // Static コントロール
1649
1650 //キャプション テキスト
1651 rect.left=pos.x+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1652 rect.top=pos.y+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1653 rect.right=pos.x+size.cx+MdiInfo[WndNum].MdiRadInfo->ClientPos.x;
1654 rect.bottom=pos.y+size.cy+MdiInfo[WndNum].MdiRadInfo->ClientPos.y;
1655
1656 //ビットを考慮してSS_LEFTを最後に検討する
1657 if(pWindowInfo->pChildInfo[i].style&SS_CENTER) i2=DT_CENTER;
1658 else if(pWindowInfo->pChildInfo[i].style&SS_RIGHT) i2=DT_RIGHT;
1659 else i2=DT_LEFT;
1660
1661 hOldFont=(HFONT)SelectObject(hdc,hFont);
1662 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED){
1663 SetTextColor(hdc,RGB(255,255,255));
1664 rc2.left=rect.left+1;
1665 rc2.top=rect.top+1;
1666 rc2.right=rect.right+1;
1667 rc2.bottom=rect.bottom+1;
1668 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rc2,i2);
1669 SetTextColor(hdc,GetSysColor(COLOR_GRAYTEXT));
1670 }
1671 else
1672 SetTextColor(hdc,GetSysColor(COLOR_BTNTEXT));
1673
1674 //折り返すかどうか
1675 if(!(pWindowInfo->pChildInfo[i].style&SS_LEFTNOWORDWRAP)){
1676 i2|=DT_WORDBREAK;
1677 }
1678
1679 DrawText(hdc,pWindowInfo->pChildInfo[i].caption,-1,&rect,i2);
1680 SelectObject(hdc,hOldFont);
1681 }
1682
1683 else if(pWindowInfo->pChildInfo[i].Control==CT_TRACKBAR){
1684 //////////////////////////
1685 // TrackBar コントロール
1686
1687 if(pWindowInfo->pChildInfo[i].style&TBS_VERT){
1688 pos.x+=2;
1689 size.cx-=2;
1690 if(size.cx>21) size.cx=21;
1691 pos.y+=8;
1692 size.cy-=16;
1693
1694 rect.left=MdiInfo[WndNum].MdiRadInfo->ClientPos.x+pos.x+(size.cx/2)-2;
1695 rect.right=MdiInfo[WndNum].MdiRadInfo->ClientPos.x+pos.x+(size.cx/2)+2;
1696 rect.top=MdiInfo[WndNum].MdiRadInfo->ClientPos.y+pos.y;
1697 rect.bottom=MdiInfo[WndNum].MdiRadInfo->ClientPos.y+pos.y+size.cy;
1698 DrawEdge(hdc,&rect,EDGE_SUNKEN,BF_RECT);
1699
1700 size.cy=size.cx/2;
1701 DrawButtonEdge(WndNum,&pos,&size);
1702 }
1703 else{
1704 pos.x+=8;
1705 size.cx-=16;
1706 pos.y+=2;
1707 size.cy-=2;
1708 if(size.cy>21) size.cy=21;
1709
1710 rect.left=MdiInfo[WndNum].MdiRadInfo->ClientPos.x+pos.x;
1711 rect.right=MdiInfo[WndNum].MdiRadInfo->ClientPos.x+pos.x+size.cx;
1712 rect.top=MdiInfo[WndNum].MdiRadInfo->ClientPos.y+pos.y+(size.cy/2)-2;
1713 rect.bottom=MdiInfo[WndNum].MdiRadInfo->ClientPos.y+pos.y+(size.cy/2)+2;
1714 DrawEdge(hdc,&rect,EDGE_SUNKEN,BF_RECT);
1715
1716 size.cx=size.cy/2;
1717 DrawButtonEdge(WndNum,&pos,&size);
1718 }
1719 }
1720
1721 else if(pWindowInfo->pChildInfo[i].Control==CT_TREEVIEW){
1722 //////////////////////////
1723 // TreeView コントロール
1724
1725 //内部
1726 if(pWindowInfo->pChildInfo[i].style&WS_DISABLED)
1727 rgb=GetSysColor(COLOR_3DFACE);
1728 else rgb=GetSysColor(COLOR_WINDOW);
1729 DrawRectangleInClient(WndNum,
1730 pos.x,pos.y,
1731 pos.x+size.cx,pos.y+size.cy,
1732 rgb,rgb,1);
1733 }
1734
1735 else if(pWindowInfo->pChildInfo[i].Control==CT_UPDOWN){
1736 ///////////////////////////////
1737 // アップ ダウン コントロール
1738 if(pWindowInfo->pChildInfo[i].style&UDS_HORZ)
1739 DrawUpDownControl(WndNum,pWindowInfo->pChildInfo[i].style,0,&pos,&size);
1740 else DrawUpDownControl(WndNum,pWindowInfo->pChildInfo[i].style,1,&pos,&size);
1741 }
1742
1743 else if(pWindowInfo->pChildInfo[i].Control==CT_VSCROLLBAR){
1744 ////////////////////////////////////
1745 // 垂直スクロールバー コントロール
1746 DrawScrollBar(WndNum,pWindowInfo->pChildInfo[i].style,1,&pos,&size);
1747 }
1748 }
1749 DeleteObject(hFont);
1750}
1751void DrawRadWindow(int WndNum,WINDOW_INFO *pWindowInfo){
1752 extern MDIINFO MdiInfo[MAX_WNDNUM];
1753 HBRUSH hOldBrush;
1754 POINT pos;
1755
1756 SetBkMode(MdiInfo[WndNum].MdiRadInfo->hMemDC,TRANSPARENT);
1757
1758 hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,GetStockObject(WHITE_BRUSH));
1759 PatBlt(MdiInfo[WndNum].MdiRadInfo->hMemDC,0,0,ScreenX*2,ScreenY*2,PATCOPY);
1760 SelectObject(MdiInfo[WndNum].MdiRadInfo->hMemDC,hOldBrush);
1761
1762 pos.x=LEVER_THICK;
1763 pos.y=LEVER_THICK;
1764 DesigningWindow(WndNum,MdiInfo[WndNum].MdiRadInfo->hMemDC,&pos,pWindowInfo);
1765
1766 InvalidateRect(MdiInfo[WndNum].MdiRadInfo->hRad,NULL,0);
1767}
Note: See TracBrowser for help on using the repository browser.