source: dev/trunk/ab5.0/abdev/abdev/IconEditor.cpp@ 626

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

MdiInfoをリファクタリング

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