source: dev/ProjectEditor/IconEditor.cpp@ 6

Last change on this file since 6 was 3, checked in by dai_9181, 18 years ago
File size: 16.6 KB
Line 
1#include "Common.h"
2
3RGBQUAD DefaultColorTable16[16]={
4 0,0,0,0,
5 0,0,128,0,
6 0,128,0,0,
7 0,128,128,0,
8 128,0,0,0,
9 128,0,128,0,
10 128,128,0,0,
11 128,128,128,0,
12 192,192,192,0,
13 0,0,255,0,
14 0,255,0,0,
15 0,255,255,0,
16 255,0,0,0,
17 255,0,255,0,
18 255,255,0,0,
19 255,255,255,0,
20};
21RGBQUAD DefaultColorTable256[256]; //ファイルから読み込む(SetupProjectEditor関数を参照)
22
23void ResizeIconWindow(HWND hMain,HWND hToolDlg,HWND hColorDlg,int width,int height){
24 MoveWindow(hMain,0,0,width-170,height-50,1);
25 MoveWindow(hToolDlg,width-170,0,170,height,1);
26 MoveWindow(hColorDlg,0,height-50,width-170,50,1);
27}
28void ResetIconType(int WndNum){
29 extern MDIINFO MdiInfo[MAX_WNDNUM];
30 int i;
31 HWND hCombo;
32 char temporary[MAX_PATH];
33 BITMAPINFOHEADER *pBmpInfoHdr;
34
35 hCombo=GetDlgItem(MdiInfo[WndNum].MdiIconEditInfo->hToolDlg,IDC_ICONTYPECOMBO);
36
37 for(i=0;i<MdiInfo[WndNum].MdiIconEditInfo->num;i++){
38 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i];
39
40 //例: "32*32 (xxxx色)"
41 sprintf(temporary,"%d*%d (%d%s)",
42 pBmpInfoHdr->biWidth,
43 pBmpInfoHdr->biHeight/2,
44 (int)pow((double)2,(double)pBmpInfoHdr->biBitCount),
45 STRING_UNIT_COLORS);
46 SendMessage(hCombo,CB_ADDSTRING,0,(long)temporary);
47 }
48 SendMessage(hCombo,CB_SETCURSEL,0,0);
49}
50BYTE *CreateIconType(int IconType,DWORD *dwBytes){
51 extern HANDLE hHeap;
52 int i,width,BitCount,dwBytesInRes;
53 BITMAPINFOHEADER *pBmpHdr;
54 BYTE *pImageBuffer;
55
56 switch(IconType){
57 case ICONTYPE_16_16:
58 width=16;
59 BitCount=4;
60 break;
61 case ICONTYPE_16_256:
62 width=16;
63 BitCount=8;
64 break;
65 case ICONTYPE_32_16:
66 width=32;
67 BitCount=4;
68 break;
69 case ICONTYPE_32_256:
70 width=32;
71 BitCount=8;
72 break;
73 }
74
75 //イメージサイズを計算
76 dwBytesInRes=sizeof(BITMAPINFOHEADER)+
77 sizeof(RGBQUAD)*(int)pow((double)2,(double)BitCount)+
78 BitCount*width*width/8;
79 if(width==16) dwBytesInRes+=width*width*2/8;
80 else dwBytesInRes+=width*width/8;
81 *dwBytes=dwBytesInRes;
82
83 //メモリ領域を確保
84 pImageBuffer=(BYTE *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,dwBytesInRes);
85
86 //ヘッダ情報をセット
87 pBmpHdr=(BITMAPINFOHEADER *)pImageBuffer;
88 pBmpHdr->biSize=sizeof(BITMAPINFOHEADER);
89 pBmpHdr->biWidth=width;
90 pBmpHdr->biHeight=width*2;
91 pBmpHdr->biPlanes=1;
92 pBmpHdr->biBitCount=BitCount;
93
94 //カラーテーブルをセット
95 RGBQUAD *pRgbq;
96 pRgbq=(RGBQUAD *)(pImageBuffer+sizeof(BITMAPINFOHEADER));
97 if(BitCount==4){
98 //16色
99 memcpy(pRgbq,DefaultColorTable16,sizeof(RGBQUAD)*16);
100 }
101 else if(BitCount==8){
102 //256色
103 memcpy(pRgbq,DefaultColorTable256,sizeof(RGBQUAD)*256);
104 }
105
106 //マスクビットをセット
107 BYTE *pMaskBuf;
108 pMaskBuf=pImageBuffer+
109 sizeof(BITMAPINFOHEADER)+
110 sizeof(RGBQUAD)*(int)pow((double)2,(double)BitCount)+
111 BitCount*width*width/8;
112 if(width==16){
113 //一行の4バイト境界を考慮
114 for(i=0;i<16;i++){
115 pMaskBuf[i*4]=0xFF;
116 pMaskBuf[i*4+1]=0xFF;
117 pMaskBuf[i*4+2]=0;
118 pMaskBuf[i*4+3]=0;
119 }
120 }
121 else memset(pMaskBuf,0xFF,width*width/8);
122
123 return pImageBuffer;
124}
125void AddIconType(int WndNum,int IconType){
126 extern HANDLE hHeap;
127 extern MDIINFO MdiInfo[MAX_WNDNUM];
128 int i,width,BitCount;
129
130 switch(IconType){
131 case ICONTYPE_16_16:
132 width=16;
133 BitCount=4;
134 break;
135 case ICONTYPE_16_256:
136 width=16;
137 BitCount=8;
138 break;
139 case ICONTYPE_32_16:
140 width=32;
141 BitCount=4;
142 break;
143 case ICONTYPE_32_256:
144 width=32;
145 BitCount=8;
146 break;
147 }
148
149 MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->num]=
150 CreateIconType(IconType,
151 &MdiInfo[WndNum].MdiIconEditInfo->dwBytesInRes[MdiInfo[WndNum].MdiIconEditInfo->num]);
152
153 //イメージ選択用のメモリを解放
154 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2)
155 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
156 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
157
158 //アイコンタイプを追加
159 MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum=MdiInfo[WndNum].MdiIconEditInfo->num;
160 MdiInfo[WndNum].MdiIconEditInfo->num++;
161
162 //変更情報を初期化
163 i=MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum;
164 MdiInfo[WndNum].MdiIconEditInfo->undo[i].NowPos=0;
165 memset(MdiInfo[WndNum].MdiIconEditInfo->undo[i].lpData,0,sizeof(BYTE *)*MAX_ICONEDIT_UNDONUM);
166
167 //アイコンタイプコンボボックスに追加
168 char temporary[32];
169 HWND hCombo;
170 hCombo=GetDlgItem(MdiInfo[WndNum].MdiIconEditInfo->hToolDlg,IDC_ICONTYPECOMBO);
171
172 //例: "32*32 (xxxx色)"
173 sprintf(temporary,"%d*%d (%d%s)",
174 width,
175 width,
176 (int)pow((double)2,(double)BitCount),
177 STRING_UNIT_COLORS);
178 i=SendMessage(hCombo,CB_ADDSTRING,0,(long)temporary);
179
180 SendMessage(hCombo,CB_SETCURSEL,i,0);
181
182 //再描画
183 HBRUSH hOldBrush;
184 hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,GetStockObject(WHITE_BRUSH));
185 PatBlt(MdiInfo[WndNum].MdiIconEditInfo->memdc,0,0,400,400,PATCOPY);
186 SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hOldBrush);
187 DrawIconToMemBmp(WndNum,0);
188 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,1);
189 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hColorDlg,NULL,0);
190}
191void DeleteIconType(int WndNum){
192 extern MDIINFO MdiInfo[MAX_WNDNUM];
193 int i;
194
195 //変更情報を解放
196 for(i=0;i<MAX_ICONEDIT_UNDONUM;i++){
197 if(MdiInfo[WndNum].MdiIconEditInfo->undo[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum].lpData[i])
198 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo->undo[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum].lpData[i]);
199 }
200
201 //メモリを解放
202 HeapDefaultFree(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]);
203
204 //イメージ選択用のメモリを解放
205 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2)
206 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
207 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
208
209 ////////////////////////
210 // アイコンタイプを削除
211 for(i=MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum;i<MdiInfo[WndNum].MdiIconEditInfo->num-1;i++){
212 MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i]=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i+1];
213 MdiInfo[WndNum].MdiIconEditInfo->dwBytesInRes[i]=MdiInfo[WndNum].MdiIconEditInfo->dwBytesInRes[i+1];
214 MdiInfo[WndNum].MdiIconEditInfo->undo[i]=MdiInfo[WndNum].MdiIconEditInfo->undo[i+1];
215 }
216 MdiInfo[WndNum].MdiIconEditInfo->num--;
217 if(MdiInfo[WndNum].MdiIconEditInfo->num==MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum)
218 MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum=MdiInfo[WndNum].MdiIconEditInfo->num-1;
219
220 //コンボボックスからアイコンタイプを削除
221 HWND hCombo;
222 hCombo=GetDlgItem(MdiInfo[WndNum].MdiIconEditInfo->hToolDlg,IDC_ICONTYPECOMBO);
223 i=SendMessage(hCombo,CB_DELETESTRING,
224 SendMessage(hCombo,CB_GETCURSEL,0,0),
225 0);
226 SendMessage(hCombo,CB_SETCURSEL,MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum,0);
227
228 //再描画
229 HBRUSH hOldBrush;
230 hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,GetStockObject(WHITE_BRUSH));
231 PatBlt(MdiInfo[WndNum].MdiIconEditInfo->memdc,0,0,400,400,PATCOPY);
232 SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hOldBrush);
233 DrawIconToMemBmp(WndNum,0);
234 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,1);
235 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hColorDlg,NULL,0);
236}
237void NewIconEditWindow(char *filepath){
238 extern HINSTANCE hInst,hResInst;
239 extern HANDLE hHeap;
240 extern HWND hDocCombo;
241 extern MDIINFO MdiInfo[MAX_WNDNUM];
242 int i,i2,IconNum;
243 char str[MAX_PATH],str2[32],*buffer;
244 BYTE *pImageBuffer[8];
245 DWORD dwBytesInRes[8];
246 HWND hChild;
247 HDC hdc;
248 MDICREATESTRUCT mdic;
249
250 if(filepath){
251
252 //すでに指定されたファイルが開かれている場合
253 hChild=GetWindow(hClient,GW_CHILD);
254 while(hChild){
255 i=GetWndNum(hChild);
256 if(MdiInfo[i].DocType==WNDTYPE_ICONEDIT){
257 if(lstrcmpi(MdiInfo[i].path,filepath)==0) break;
258 }
259 hChild=GetNextWindow(hChild,GW_HWNDNEXT);
260 }
261 if(hChild){
262 BringWindowToTop(hChild);
263 return;
264 }
265
266 //ファイル読み込み(正常に読み込めるかの確認も含む)
267 HANDLE hFile;
268 DWORD dw;
269 hFile=CreateFile(filepath,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
270 if(hFile==INVALID_HANDLE_VALUE){
271 //"\"%s\" ファイルの読み込みに失敗しました。"
272 sprintf(str,STRING_ERROR_CANT_FILEOPEN,filepath);
273 MessageBox(hOwner,str,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
274 return;
275 }
276 i=GetFileSize(hFile,NULL);
277 buffer=(char *)GlobalAlloc(GMEM_FIXED,i+1);
278 ReadFile(hFile,buffer,i,&dw,NULL);
279 CloseHandle(hFile);
280
281 ICONDIR *pIconDir;
282 ICONDIRENTRY *pIconDirEntry;
283 pIconDir=(ICONDIR *)buffer;
284 IconNum=pIconDir->idCount;
285 for(i=0;i<IconNum;i++){
286 pIconDirEntry=(ICONDIRENTRY *)(buffer+sizeof(ICONDIR)+sizeof(ICONDIRENTRY)*i);
287
288 pImageBuffer[i]=(BYTE *)HeapAlloc(hHeap,0,pIconDirEntry->dwBytesInRes);
289 memcpy(pImageBuffer[i],buffer+pIconDirEntry->dwImageOffset,pIconDirEntry->dwBytesInRes);
290
291 dwBytesInRes[i]=pIconDirEntry->dwBytesInRes;
292 }
293
294 _splitpath(filepath,NULL,NULL,str,str2);
295 lstrcat(str,str2);
296 mdic.szTitle=str;
297 }
298 else{
299 extern int DocumentCounter;
300 buffer=0;
301 DocumentCounter++;
302 sprintf(str,"Icon[%d]",DocumentCounter);
303 mdic.szTitle=str;
304
305 IconNum=1;
306 pImageBuffer[0]=CreateIconType(ICONTYPE_32_16,&dwBytesInRes[0]);
307 }
308 mdic.szClass="MDIClientWindow_IconEdit";
309 mdic.hOwner=hInst;
310 mdic.x=CW_USEDEFAULT;
311 mdic.y=CW_USEDEFAULT;
312 mdic.cx=CW_USEDEFAULT;
313 mdic.cy=CW_USEDEFAULT;
314
315 hChild=GetWindow(hClient,GW_CHILD);
316 if(IsWindow(hChild)){
317 if(IsZoomed(hChild)) mdic.style=WS_MAXIMIZE;
318 else mdic.style=0;
319 }
320 else{
321 if(pobj_nv->bMDIZoomed) mdic.style=WS_MAXIMIZE;
322 else mdic.style=0;
323 }
324
325 mdic.lParam=0;
326 hChild=(HWND)SendMessage(hClient,WM_MDICREATE,0,(long)&mdic); //ウィンドウ作成
327
328 ////////////////////
329 //子ウィンドウ作成
330
331 //エディタ中央部分を作成
332 HWND hMain;
333 hMain=CreateWindowEx(WS_EX_CLIENTEDGE,"IconEditWindowProc",NULL,
334 WS_CHILD|WS_VISIBLE,
335 0,0,0,0,
336 hChild,NULL,hInst,NULL);
337
338 //ツールダイアログ部分を作成
339 HWND hToolDlg;
340 hToolDlg=CreateDialog(hResInst,MAKEINTRESOURCE(IDD_ICONEDIT_TOOL),hChild,(DLGPROC)DlgIconToolProc);
341
342 //ツールダイアログのボタン部分を作成
343 HWND hButtonsDlg;
344 hButtonsDlg=CreateDialog(hResInst,MAKEINTRESOURCE(IDD_ICONEDIT_BUTTONS),hToolDlg,(DLGPROC)DlgIconButtons);
345
346 //カラーテーブルダイアログ部分を作成
347 HWND hColorDlg;
348 hColorDlg=CreateDialog(hResInst,MAKEINTRESOURCE(IDD_ICONEDIT_COLOR),hChild,(DLGPROC)DlgIconColorProc);
349
350 //ウィンドウのID登録
351 for(i=0;i<MAX_WNDNUM;i++){
352 if(MdiInfo[i].hwnd==0){
353 MdiInfo[i].hwnd=hChild;
354 MdiInfo[i].DocType=WNDTYPE_ICONEDIT;
355 MdiInfo[i].title=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(str)+1);
356 lstrcpy(MdiInfo[i].title,str);
357 if(filepath){
358 MdiInfo[i].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(filepath)+1);
359 lstrcpy(MdiInfo[i].path,filepath);
360 }
361 else MdiInfo[i].path=(char *)GlobalAlloc(GPTR,1);
362
363 MdiInfo[i].edit_undo=(TEXTEDIT_UNDOSTATE *)GlobalAlloc(GPTR,sizeof(TEXTEDIT_UNDOSTATE));
364 MdiInfo[i].edit_undo->NowPos=0;
365
366 MdiInfo[i].MdiIconEditInfo=(MDIICONEDITINFO *)HeapAlloc(hHeap,0,sizeof(MDIICONEDITINFO));
367 MdiInfo[i].MdiIconEditInfo->hMain=hMain;
368 MdiInfo[i].MdiIconEditInfo->hToolDlg=hToolDlg;
369 MdiInfo[i].MdiIconEditInfo->hButtonsDlg=hButtonsDlg;
370 MdiInfo[i].MdiIconEditInfo->hColorDlg=hColorDlg;
371 hdc=GetDC(hMain);
372 MdiInfo[i].MdiIconEditInfo->memdc=CreateCompatibleDC(hdc);
373 MdiInfo[i].MdiIconEditInfo->hMemBmp=CreateCompatibleBitmap(hdc,600,400);
374 SelectObject(MdiInfo[i].MdiIconEditInfo->memdc,MdiInfo[i].MdiIconEditInfo->hMemBmp);
375 ReleaseDC(hMain,hdc);
376
377 MdiInfo[i].MdiIconEditInfo->SelectLevel=0;
378
379 MdiInfo[i].MdiIconEditInfo->num=IconNum;
380 MdiInfo[i].MdiIconEditInfo->SelectIconNum=0;
381 memcpy(MdiInfo[i].MdiIconEditInfo->pIconImage,pImageBuffer,sizeof(DWORD)*IconNum);
382
383 memcpy(MdiInfo[i].MdiIconEditInfo->dwBytesInRes,dwBytesInRes,sizeof(DWORD)*IconNum);
384
385 MdiInfo[i].MdiIconEditInfo->NowTool=IDC_TOOL_PEN;
386 MdiInfo[i].MdiIconEditInfo->MainColor=RGB(0,0,0);
387 extern COLORREF TransparentClrRef;
388 MdiInfo[i].MdiIconEditInfo->SubColor=TransparentClrRef;
389
390 for(i2=0;i2<MdiInfo[i].MdiIconEditInfo->num;i2++){
391 MdiInfo[i].MdiIconEditInfo->undo[i2].NowPos=0;
392 memset(MdiInfo[i].MdiIconEditInfo->undo[i2].lpData,0,sizeof(BYTE *)*MAX_ICONEDIT_UNDONUM);
393 }
394 MdiInfo[i].MdiIconEditInfo->bModify=0;
395 break;
396 }
397 }
398
399 //メモリへ初期描画を行う
400 HBRUSH hOldBrush;
401 hOldBrush=(HBRUSH)SelectObject(MdiInfo[i].MdiIconEditInfo->memdc,GetStockObject(WHITE_BRUSH));
402 PatBlt(MdiInfo[i].MdiIconEditInfo->memdc,0,0,600,400,PATCOPY);
403 SelectObject(MdiInfo[i].MdiIconEditInfo->memdc,hOldBrush);
404 DrawIconToMemBmp(i,0);
405
406 //ウィンドウ位置を初期化
407 RECT rc;
408 GetClientRect(hChild,&rc);
409 ResizeIconWindow(hMain,hToolDlg,hColorDlg,rc.right,rc.bottom);
410
411 //アイコンタイプコンボボックスをセット
412 ResetIconType(i);
413
414 if(MdiInfo[i].MdiIconEditInfo->num<=1)
415 EnableWindow(GetDlgItem(hToolDlg,IDC_DELETE_ICONTYPE),0);
416
417 //Docコンボボックスに追加
418 i=SendMessage(hDocCombo,CB_ADDSTRING,0,(long)str);
419 SendMessage(hDocCombo,CB_SETCURSEL,i,0);
420
421 //タブに追加
422 pobj_MainTab->insert(str,1);
423
424 SetStatusText(NULL);
425
426 //メニュー状態を設定
427 ResetState_DocMenu();
428}
429void SaveIconFile(char *filepath,HWND hwnd){
430 extern MDIINFO MdiInfo[MAX_WNDNUM];
431 int i,i2,WndNum;
432 char buffer[8192],temporary[MAX_PATH];
433 int ImgBufSize[8];
434
435 WndNum=GetWndNum(hwnd);
436
437 i2=0;
438
439 ///////////
440 // ICONDIR
441 *((WORD *)(buffer+i2))=0; //idReserved
442 i2+=sizeof(WORD);
443 *((WORD *)(buffer+i2))=1; //idType
444 i2+=sizeof(WORD);
445 *((WORD *)(buffer+i2))=MdiInfo[WndNum].MdiIconEditInfo->num; //idCount
446 i2+=sizeof(WORD);
447
448 ////////////////
449 // ICONDIRENTRY
450 ICONDIRENTRY IconDirEntry;
451 memset(&IconDirEntry,0,sizeof(ICONDIRENTRY));
452
453 //イメージバッファの初期位置
454 IconDirEntry.dwImageOffset=sizeof(ICONDIR)+
455 sizeof(ICONDIRENTRY)*MdiInfo[WndNum].MdiIconEditInfo->num;
456
457 for(i=0;i<MdiInfo[WndNum].MdiIconEditInfo->num;i++){
458 BITMAPINFOHEADER *pBmpInfoHdr;
459 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i];
460
461 IconDirEntry.bWidth=(BYTE)pBmpInfoHdr->biWidth;
462 IconDirEntry.bHeight=(BYTE)pBmpInfoHdr->biHeight/2;
463 if(pBmpInfoHdr->biBitCount<=8)
464 IconDirEntry.bColorCount=(BYTE)pow((double)2,(double)pBmpInfoHdr->biBitCount);
465 else IconDirEntry.bColorCount=0;
466
467 IconDirEntry.dwBytesInRes=sizeof(BITMAPINFOHEADER);
468 if(pBmpInfoHdr->biBitCount<=8) //256色以下の場合はカラーパレットのサイズを考慮
469 IconDirEntry.dwBytesInRes+=(DWORD)pow((double)2,(double)pBmpInfoHdr->biBitCount)*sizeof(long);
470 IconDirEntry.dwBytesInRes+=pBmpInfoHdr->biBitCount*pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8;
471 if(pBmpInfoHdr->biWidth==16){
472 //16*16のアイコン
473 IconDirEntry.dwBytesInRes+=pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8*2;
474 }
475 else{
476 //32*32のアイコン
477 IconDirEntry.dwBytesInRes+=pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8;
478 }
479
480 ImgBufSize[i]=IconDirEntry.dwBytesInRes;
481
482 memcpy(buffer+i2,&IconDirEntry,sizeof(ICONDIRENTRY));
483 i2+=sizeof(ICONDIRENTRY);
484
485 IconDirEntry.dwImageOffset+=IconDirEntry.dwBytesInRes;
486 }
487
488 ////////////////////
489 // イメージバッファ
490 for(i=0;i<MdiInfo[WndNum].MdiIconEditInfo->num;i++){
491 memcpy(buffer+i2,
492 MdiInfo[WndNum].MdiIconEditInfo->pIconImage[i],
493 ImgBufSize[i]);
494
495 i2+=ImgBufSize[i];
496 }
497
498
499 //ファイルへ書き込み
500 HANDLE hFile;
501 DWORD dummy;
502 hFile=CreateFile(filepath,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
503 if(hFile==INVALID_HANDLE_VALUE){
504 //"\"%s\" ファイルへの書き込みに失敗しました。"
505 sprintf(temporary,STRING_ERROR_CANT_FILESAVE,filepath);
506 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONSTOP);
507 return;
508 }
509 WriteFile(hFile,buffer,i2,&dummy,NULL);
510 CloseHandle(hFile);
511}
512
513LRESULT CALLBACK MDIClientWindow_IconEdit(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
514 extern HWND hDocCombo;
515 extern MDIINFO MdiInfo[MAX_WNDNUM];
516 extern PROJECTINFO ProjectInfo;
517 int i,WndNum;
518
519 switch(message){
520 case WM_MDIACTIVATE:
521 if(!lParam) return 0;
522 i=GetWndNum((HWND)lParam);
523 if(i==-1) return 0; //ウィンドウが初期状態の場合
524
525 i=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[i].title);
526 SendMessage(hDocCombo,CB_SETCURSEL,i,0);
527 SetStatusText(NULL);
528 ResetState_EditMenu();
529 return 0;
530 case WM_SIZE:
531 WndNum=GetWndNum(hwnd);
532 if(WndNum==-1) break;
533 ResizeIconWindow(MdiInfo[WndNum].MdiIconEditInfo->hMain,
534 MdiInfo[WndNum].MdiIconEditInfo->hToolDlg,
535 MdiInfo[WndNum].MdiIconEditInfo->hColorDlg,
536 LOWORD(lParam),HIWORD(lParam));
537 break;
538 case WM_CLOSE:
539 CloseDocWindow(GetWndNum(hwnd));
540 pobj_nv->bMDIZoomed=IsZoomed(hwnd);
541 i=DefMDIChildProc(hwnd,message,wParam,lParam);
542
543 //メニュー状態を設定
544 ResetState_DocMenu();
545
546 return i;
547 }
548 return DefMDIChildProc(hwnd,message,wParam,lParam);
549}
Note: See TracBrowser for help on using the repository browser.