source: dev/trunk/ab5.0/abdev/abdev/DrawWindow.cpp@ 629

Last change on this file since 629 was 629, checked in by dai_9181, 17 years ago

MDIINFO構造体をリファクタリング。

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