source: dev/trunk/abdev/ProjectEditor/WindowControl.cpp@ 290

Last change on this file since 290 was 64, checked in by dai_9181, 18 years ago

すべてのオブジェクトを参照型に切り替えた。

File size: 82.7 KB
Line 
1#include "Common.h"
2
3#if defined(JPN)
4//日本語
5#include "pj_msg_jpn.h"
6#else
7//英語
8#include "pj_msg_eng.h"
9#endif
10
11int GetWndInfoNum(char *name){
12 extern PROJECTINFO ProjectInfo;
13 int i;
14 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
15 if(lstrcmpi(name,ProjectInfo.pWindowInfo[i].name)==0) return i;
16 }
17 return -1;
18}
19void ChangeDivisionToOrSign(char *CopyBuffer,const char *ReadBuffer){
20 int i,i2;
21 for(i=0,i2=0;;i++,i2++){
22 if(ReadBuffer[i]=='|'){
23 CopyBuffer[i2]=0;
24 lstrcpy(CopyBuffer+i2," or ");
25 i2+=3;
26 continue;
27 }
28 CopyBuffer[i2]=ReadBuffer[i];
29 if(ReadBuffer[i]=='\0') break;
30 }
31}
32void ChangeOrSignToDivision(char *CopyBuffer,const char *ReadBuffer){
33 int i,i2,IsStr;
34 for(i=0,i2=0,IsStr=0;;i++,i2++){
35 if(ReadBuffer[i]=='\"') IsStr^=1;
36 if(ReadBuffer[i]=='\0'){
37 CopyBuffer[i2]=0;
38 break;
39 }
40 if(ReadBuffer[i+3]=='\0'){
41 memcpy(CopyBuffer+i2,ReadBuffer+i,3);
42 CopyBuffer[i2+3]=0;
43 break;
44 }
45 if((ReadBuffer[i]==' '||ReadBuffer[i]=='\t')&&
46 (ReadBuffer[i+1]=='O'||ReadBuffer[i+1]=='o')&&(ReadBuffer[i+2]=='R'||ReadBuffer[i+2]=='r')&&
47 (ReadBuffer[i+3]==' '||ReadBuffer[i+3]=='\t')&&IsStr==0){
48 CopyBuffer[i2]='|';
49 i+=3;
50 continue;
51 }
52 CopyBuffer[i2]=ReadBuffer[i];
53 }
54}
55
56HGLOBAL Rad_GetChildInfoClipboardData(int WndNum,int WndInfoNum){
57 //CHILDINFO構造体をクリップボード用データ(pByteが示すバッファ)に変換する
58 extern PROJECTINFO ProjectInfo;
59 extern MDIINFO MdiInfo[MAX_WNDNUM];
60 HGLOBAL hGlobal;
61 BYTE *pByte;
62 int i2,i3,MemSize;
63 CHILDINFO *pChildInfo;
64
65 for(i3=0;;i3++){
66 if(MdiInfo[WndNum].MdiRadInfo->SelectingItem[i3]==-1) break;
67 }
68
69
70 hGlobal=GlobalAlloc(GMEM_MOVEABLE,sizeof(int));
71 pByte=(BYTE *)GlobalLock(hGlobal);
72 *((int *)pByte)=i3;
73 GlobalUnlock(hGlobal);
74 i2=sizeof(int);
75
76 MemSize=i2;
77
78 for(i3--;i3>=0;i3--){
79 pChildInfo=&ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[MdiInfo[WndNum].MdiRadInfo->SelectingItem[i3]];
80
81 MemSize+=lstrlen(pChildInfo->IdName)+1+
82 sizeof(POINT)+
83 sizeof(SIZE)+
84 lstrlen(pChildInfo->caption)+1+
85 sizeof(DWORD)+
86 sizeof(DWORD)+
87 sizeof(int)+
88 sizeof(int)+
89 lstrlen(pChildInfo->ImageCtrlInfo.path)+1;
90
91 hGlobal=GlobalReAlloc(hGlobal,MemSize,0);
92 pByte=(BYTE *)GlobalLock(hGlobal);
93
94 lstrcpy((char *)pByte+i2,pChildInfo->IdName);
95 i2+=lstrlen(pChildInfo->IdName)+1;
96
97 memcpy(pByte+i2,&pChildInfo->pos,sizeof(POINT));
98 i2+=sizeof(POINT);
99
100 memcpy(pByte+i2,&pChildInfo->size,sizeof(SIZE));
101 i2+=sizeof(SIZE);
102
103 lstrcpy((char *)pByte+i2,pChildInfo->caption);
104 i2+=lstrlen(pChildInfo->caption)+1;
105
106 memcpy(pByte+i2,&pChildInfo->style,sizeof(DWORD));
107 i2+=sizeof(DWORD);
108
109 memcpy(pByte+i2,&pChildInfo->ExStyle,sizeof(DWORD));
110 i2+=sizeof(DWORD);
111
112 memcpy(pByte+i2,&pChildInfo->Control,sizeof(int));
113 i2+=sizeof(int);
114
115 memcpy(pByte+i2,&pChildInfo->ImageCtrlInfo.type,sizeof(int));
116 i2+=sizeof(int);
117
118 if(!pChildInfo->ImageCtrlInfo.path){
119 lstrcpy((char *)pByte+i2,"");
120 i2++;
121 }
122 else{
123 lstrcpy((char *)pByte+i2,pChildInfo->ImageCtrlInfo.path);
124 i2+=lstrlen(pChildInfo->ImageCtrlInfo.path)+1;
125 }
126
127 GlobalUnlock(hGlobal);
128 }
129
130 return hGlobal;
131}
132void Rad_PasteChildInfoClipboardData(int WndNum,HGLOBAL hGlobal){
133 //hGlobalに格納されているクリップボードデータをRAD画面に挿入する
134 extern MDIINFO MdiInfo[MAX_WNDNUM];
135 BYTE *pByte;
136 int i2,i3,WndInfoNum;
137 CHILDINFO ChildInfo;
138 char temporary[255];
139
140 for(i2=1;i2<MAX_RAD_SELITEM;i2++) MdiInfo[WndNum].MdiRadInfo->SelectingItem[i2]=-1;
141
142 WndInfoNum=GetWndInfoNum(MdiInfo[WndNum].path);
143 pByte=(BYTE *)GlobalLock(hGlobal);
144 i3=*((int *)pByte);
145 i2=sizeof(int);
146
147 for(i3--;i3>=0;i3--){
148 //IdNameメンバは変更される可能性がある
149 ChildInfo.IdName=(char *)temporary;
150 lstrcpy(ChildInfo.IdName,(char *)pByte+i2);
151 i2+=lstrlen(ChildInfo.IdName)+1;
152
153 memcpy(&ChildInfo.pos,pByte+i2,sizeof(POINT));
154 i2+=sizeof(POINT);
155
156 memcpy(&ChildInfo.size,pByte+i2,sizeof(SIZE));
157 i2+=sizeof(SIZE);
158
159 ChildInfo.caption=(char *)pByte+i2;
160 i2+=lstrlen(ChildInfo.caption)+1;
161
162 memcpy(&ChildInfo.style,pByte+i2,sizeof(DWORD));
163 i2+=sizeof(DWORD);
164
165 memcpy(&ChildInfo.ExStyle,pByte+i2,sizeof(DWORD));
166 i2+=sizeof(DWORD);
167
168 memcpy(&ChildInfo.Control,pByte+i2,sizeof(int));
169 i2+=sizeof(int);
170
171 memcpy(&ChildInfo.ImageCtrlInfo.type,pByte+i2,sizeof(int));
172 i2+=sizeof(int);
173
174 ChildInfo.ImageCtrlInfo.path=(char *)pByte+i2;
175 if(lstrlen(ChildInfo.ImageCtrlInfo.path)==0){
176 ChildInfo.ImageCtrlInfo.path=0;
177 i2++;
178 }
179 else i2+=lstrlen(ChildInfo.ImageCtrlInfo.path)+1;
180
181 ChildInfo.pos.x+=17;
182 ChildInfo.pos.y+=10;
183
184 MdiInfo[WndNum].MdiRadInfo->SelectingItem[i3]=InsertDlgItem(WndNum,
185 WndInfoNum,
186 -1,
187 &ChildInfo.pos,
188 &ChildInfo.size,
189 ChildInfo.IdName,
190 ChildInfo.caption,
191 ChildInfo.style,
192 ChildInfo.ExStyle,
193 ChildInfo.Control,
194 ChildInfo.ImageCtrlInfo.type,
195 ChildInfo.ImageCtrlInfo.path,
196 2);
197 }
198
199 GlobalUnlock(hGlobal);
200
201 ChangePropertyWindow(WndNum,WndInfoNum);
202}
203
204char *FormatCaption(char *caption){
205 extern HANDLE hHeap;
206 int i2,i3,BufSize;
207 char *buffer;
208
209 BufSize=256*2;
210 buffer=(char *)HeapAlloc(hHeap,0,BufSize);
211 for(i2=0,i3=0;;i2++,i3++){
212 if(i2+256>=BufSize){
213 BufSize+=256;
214 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufSize);
215 }
216 if(caption[i3]=='\"'){
217 lstrcpy(buffer+i2,"\"+Chr$(34)+\"");
218 i2+=lstrlen(buffer+i2);
219 i2--;
220 continue;
221 }
222 buffer[i2]=caption[i3];
223 if(caption[i3]=='\0') break;
224 }
225
226 return buffer;
227}
228char *SetCaptionSequence(char *caption){
229 extern HANDLE hHeap;
230 int i2,i3,BufSize;
231 char *buffer;
232
233 BufSize=256*2;
234 buffer=(char *)HeapAlloc(hHeap,0,BufSize);
235 for(i2=0,i3=0;;i2++,i3++){
236 if(i2+256>=BufSize){
237 BufSize+=256;
238 buffer=(char *)HeapReAlloc(hHeap,0,buffer,BufSize);
239 }
240 buffer[i2]=caption[i3];
241 if(caption[i3]=='\"'){
242 buffer[i2++]='\\';
243 buffer[i2]='1';
244 }
245 else if(caption[i3]=='\\'){
246 buffer[i2++]='\\';
247 buffer[i2]='\\';
248 }
249 else if(caption[i3]=='\0') break;
250 }
251
252 return buffer;
253}
254void RestoreCaptionSequence(char *caption){
255 int i2,i3;
256
257 for(i2=0,i3=0;;i2++,i3++){
258 caption[i2]=caption[i3];
259 if(caption[i3]=='\\'){
260 i3++;
261 if(caption[i3]=='1') caption[i2]='\"';
262 else caption[i2]=caption[i3];
263 }
264 else if(caption[i3]=='\0') break;
265 }
266}
267
268//テンプレートソースファイルに値をセットする
269char *PermutationWndPgmTemplate(char *pBuf,char *pPjName, char *pWndName, char *pHandleName, char *pProcName){
270 extern HANDLE hHeap;
271 int i,i2;
272
273 for(i=0;;i++){
274 if(pBuf[i]=='\0') break;
275 if(memicmp(pBuf+i,"#name#",6)==0){
276 //プロジェクト名を置換
277 i2=lstrlen(pPjName);
278 if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-6)+1);
279 SlideString(pBuf+i+6,i2-6);
280 memcpy(pBuf+i,pPjName,i2);
281 }
282 if(memicmp(pBuf+i,"#window#",8)==0){
283 //ウィンドウ名を置換
284 i2=lstrlen(pWndName);
285 if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-8)+1);
286 SlideString(pBuf+i+8,i2-8);
287 memcpy(pBuf+i,pWndName,i2);
288 }
289 if(memicmp(pBuf+i,"#handle#",8)==0){
290 //ハンドル名を置換
291 i2=lstrlen(pHandleName);
292 if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-8)+1);
293 SlideString(pBuf+i+8,i2-8);
294 memcpy(pBuf+i,pHandleName,i2);
295 }
296 if(memicmp(pBuf+i,"#procedure#",11)==0){
297 //プロシージャ名を置換
298 i2=lstrlen(pProcName);
299 if(i2>6) pBuf=(char *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pBuf,lstrlen(pBuf)+(i2-11)+1);
300 SlideString(pBuf+i+11,i2-11);
301 memcpy(pBuf+i,pProcName,i2);
302 }
303 }
304
305 return pBuf;
306}
307
308BOOL GetItemNotifyMessageNameByEvent(char *buffer,int ClassID,const char *EventName){
309 if(lstrcmp(EventName,"Click")==0) lstrcpy(buffer,"NM_CLICK");
310 else if(lstrcmp(EventName,"CustomDraw")==0) lstrcpy(buffer,"NM_CUSTOMDRAW");
311 else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"NM_DBLCLK");
312 else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"NM_KILLFOCUS");
313 else if(lstrcmp(EventName,"OutOfMemory")==0) lstrcpy(buffer,"NM_OUTOFMEMORY");
314 else if(lstrcmp(EventName,"RClick")==0) lstrcpy(buffer,"NM_RCLICK");
315 else if(lstrcmp(EventName,"RDblClick")==0) lstrcpy(buffer,"NM_RDBLCLK");
316 else if(lstrcmp(EventName,"ReleasedCapture")==0) lstrcpy(buffer,"NM_RELEASEDCAPTURE");
317 else if(lstrcmp(EventName,"Return")==0) lstrcpy(buffer,"NM_RETURN");
318 else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"NM_SETFOCUS");
319 else{
320 if(ClassID==CT_LISTVIEW){
321 if(lstrcmp(EventName,"BeginDrag")==0) lstrcpy(buffer,"LVN_BEGINDRAG");
322 else if(lstrcmp(EventName,"BeginLabelEdit")==0) lstrcpy(buffer,"LVN_BEGINLABELEDIT");
323 else if(lstrcmp(EventName,"BeginRDrag")==0) lstrcpy(buffer,"LVN_BEGINRDRAG");
324 else if(lstrcmp(EventName,"ColumnClick")==0) lstrcpy(buffer,"LVN_COLUMNCLICK");
325 else if(lstrcmp(EventName,"DeleteAllItems")==0) lstrcpy(buffer,"LVN_DELETEALLITEMS");
326 else if(lstrcmp(EventName,"DeleteItem")==0) lstrcpy(buffer,"LVN_DELETEITEM");
327 else if(lstrcmp(EventName,"EndLabelEdit")==0) lstrcpy(buffer,"LVN_ENDLABELEDIT");
328 else if(lstrcmp(EventName,"GetDispInfo")==0) lstrcpy(buffer,"LVN_GETDISPINFO");
329 else if(lstrcmp(EventName,"InsertItem")==0) lstrcpy(buffer,"LVN_INSERTITEM");
330 else if(lstrcmp(EventName,"ItemChanged")==0) lstrcpy(buffer,"LVN_ITEMCHANGED");
331 else if(lstrcmp(EventName,"ItemChanging")==0) lstrcpy(buffer,"LVN_ITEMCHANGING");
332 else if(lstrcmp(EventName,"KeyDown")==0) lstrcpy(buffer,"LVN_KEYDOWN");
333 else if(lstrcmp(EventName,"SetDispInfo")==0) lstrcpy(buffer,"LVN_SETDISPINFO");
334 else return 0;
335 }
336 else if(ClassID==CT_UPDOWN){
337 if(lstrcmp(EventName,"Deltapos")==0) lstrcpy(buffer,"UDN_DELTAPOS");
338 else return 0;
339 }
340 else return 0;
341 //未完成
342 }
343 return 1;
344}
345BOOL GetNotifyCommandByItemMessage(WINDOW_INFO *pWindowInfo,ITEMEVENTINFO *pItemEventInfo,char *Command,char *spaces){
346 int i,i2,i3,sw;
347 char temporary[MAX_PATH];
348
349 i2=0;
350 sw=0;
351 for(i=0;;i++){
352 if(pItemEventInfo[i].IdName==0) break;
353 if(pItemEventInfo[i].ClassID==CT_LISTVIEW||
354 pItemEventInfo[i].ClassID==CT_TREEVIEW||
355 pItemEventInfo[i].ClassID==CT_UPDOWN||
356 pItemEventInfo[i].ClassID==CT_PROGRESSBAR||
357 pItemEventInfo[i].ClassID==CT_TRACKBAR){
358 //コモン コントロール(WM_NOTIFY)
359 sw=1;
360 sprintf(Command+i2,"%sCase %s\r\n",spaces,pItemEventInfo[i].IdName);
361 i2+=lstrlen(Command+i2);
362 sprintf(Command+i2,"%s\tSelect Case pnmHdr->code\r\n",spaces);
363 i2+=lstrlen(Command+i2);
364 for(i3=0;i3<pItemEventInfo[i].EventNum;i3++){
365 if(GetItemNotifyMessageNameByEvent(temporary,pItemEventInfo[i].ClassID,pItemEventInfo[i].pEventNames[i3])){
366 sprintf(Command+i2,"%s\t\tCase %s\r\n",spaces,temporary);
367 i2+=lstrlen(Command+i2);
368 sprintf(Command+i2,"%s\t\t\t%s_%s_%s(ByVal (pnmHdr As VoidPtr))\r\n",spaces,pWindowInfo->name,pItemEventInfo[i].IdName,pItemEventInfo[i].pEventNames[i3]);
369 i2+=lstrlen(Command+i2);
370 }
371 }
372 sprintf(Command+i2,"%s\tEnd Select\r\n",spaces);
373 i2+=lstrlen(Command+i2);
374 }
375 }
376 return sw;
377}
378void GetItemMessageNameByEvent(char *buffer,int ClassID,const char *EventName){
379 if(ClassID==CT_BUTTON||
380 ClassID==CT_CHECKBOX||
381 ClassID==CT_RADIOBUTTON){
382 if(lstrcmp(EventName,"Click")==0) lstrcpy(buffer,"BN_CLICKED");
383 else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"BN_DBLCLK");
384 }
385 else if(ClassID==CT_COMBOBOX){
386 if(lstrcmp(EventName,"CloseUp")==0) lstrcpy(buffer,"CBN_CLOSEUP");
387 else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"CBN_DBLCLK");
388 else if(lstrcmp(EventName,"DropDown")==0) lstrcpy(buffer,"CBN_DROPDOWN");
389 else if(lstrcmp(EventName,"EditChange")==0) lstrcpy(buffer,"CBN_EDITCHANGE");
390 else if(lstrcmp(EventName,"EditUpdate")==0) lstrcpy(buffer,"CBN_EDITUPDATE");
391 else if(lstrcmp(EventName,"ErrSpace")==0) lstrcpy(buffer,"CBN_ERRSPACE");
392 else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"CBN_KILLFOCUS");
393 else if(lstrcmp(EventName,"SelChange")==0) lstrcpy(buffer,"CBN_SELCHANGE");
394 else if(lstrcmp(EventName,"SelEndCancel")==0) lstrcpy(buffer,"CBN_SELENDCANCEL");
395 else if(lstrcmp(EventName,"SelEndOk")==0) lstrcpy(buffer,"CBN_SELENDOK");
396 else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"CBN_SETFOCUS");
397 }
398 else if(ClassID==CT_EDIT){
399 if(lstrcmp(EventName,"Change")==0) lstrcpy(buffer,"EN_CHANGE");
400 else if(lstrcmp(EventName,"ErrSpace")==0) lstrcpy(buffer,"EN_ERRSPACE");
401 else if(lstrcmp(EventName,"HScroll")==0) lstrcpy(buffer,"EN_HSCROLL");
402 else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"EN_KILLFOCUS");
403 else if(lstrcmp(EventName,"MaxText")==0) lstrcpy(buffer,"EN_MAXTEXT");
404 else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"EN_SETFOCUS");
405 else if(lstrcmp(EventName,"Update")==0) lstrcpy(buffer,"EN_UPDATE");
406 else if(lstrcmp(EventName,"VScroll")==0) lstrcpy(buffer,"EN_VSCROLL");
407 }
408 else if(ClassID==CT_IMAGEBOX||
409 ClassID==CT_STATIC){
410 if(lstrcmp(EventName,"Click")==0) lstrcpy(buffer,"STN_CLICKED");
411 else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"STN_DBLCLK");
412 }
413 else if(ClassID==CT_LISTBOX){
414 if(lstrcmp(EventName,"SelChange")==0) lstrcpy(buffer,"LBN_SELCHANGE");
415 else if(lstrcmp(EventName,"DblClick")==0) lstrcpy(buffer,"LBN_DBLCLK");
416 else if(lstrcmp(EventName,"ErrSpace")==0) lstrcpy(buffer,"LBN_ERRSPACE");
417 else if(lstrcmp(EventName,"KillFocus")==0) lstrcpy(buffer,"LBN_KILLFOCUS");
418 else if(lstrcmp(EventName,"SelCancel")==0) lstrcpy(buffer,"LBN_SELCANCEL");
419 else if(lstrcmp(EventName,"SetFocus")==0) lstrcpy(buffer,"LBN_SETFOCUS");
420 }
421}
422void GetCommandByItemMessage(WINDOW_INFO *pWindowInfo,ITEMEVENTINFO *pItemEventInfo,char *Command,char *spaces){
423 extern HANDLE hHeap;
424 int i,i2,i3;
425 char temporary[MAX_PATH];
426
427 i2=0;
428 for(i=0;;i++){
429 if(pItemEventInfo[i].IdName==0) break;
430 if(pItemEventInfo[i].ClassID!=CT_LISTVIEW&&
431 pItemEventInfo[i].ClassID!=CT_PROGRESSBAR&&
432 pItemEventInfo[i].ClassID!=CT_TREEVIEW&&
433 pItemEventInfo[i].ClassID!=CT_TRACKBAR&&
434 pItemEventInfo[i].ClassID!=CT_UPDOWN
435 ){
436 //WM_COMMAND
437 sprintf(Command+i2,"%sCase %s\r\n",spaces,pItemEventInfo[i].IdName);
438 i2+=lstrlen(Command+i2);
439 if(pItemEventInfo[i].ClassID==CT_MENU){
440 sprintf(Command+i2,"%s\t%s_%s_MenuClick()\r\n",spaces,pWindowInfo->name,pItemEventInfo[i].IdName);
441 i2+=lstrlen(Command+i2);
442 for(i3=0;i3<pItemEventInfo[i].EventNum;i3++)
443 HeapDefaultFree(pItemEventInfo[i].pEventNames[i3]);
444 }
445 else{
446 sprintf(Command+i2,"%s\tSelect Case HIWORD(wParam)\r\n",spaces);
447 i2+=lstrlen(Command+i2);
448 for(i3=0;i3<pItemEventInfo[i].EventNum;i3++){
449 GetItemMessageNameByEvent(temporary,pItemEventInfo[i].ClassID,pItemEventInfo[i].pEventNames[i3]);
450 sprintf(Command+i2,"%s\t\tCase %s\r\n",spaces,temporary);
451 i2+=lstrlen(Command+i2);
452 sprintf(Command+i2,"%s\t\t\t%s_%s_%s()\r\n",spaces,pWindowInfo->name,pItemEventInfo[i].IdName,pItemEventInfo[i].pEventNames[i3]);
453 i2+=lstrlen(Command+i2);
454 HeapDefaultFree(pItemEventInfo[i].pEventNames[i3]);
455 }
456 sprintf(Command+i2,"%s\tEnd Select\r\n",spaces);
457 i2+=lstrlen(Command+i2);
458 }
459 HeapDefaultFree(pItemEventInfo[i].IdName);
460 HeapDefaultFree(pItemEventInfo[i].pEventNames);
461 }
462 else{
463 //WM_NOTIFY情報のメモリ解放
464 for(i3=0;i3<pItemEventInfo[i].EventNum;i3++)
465 HeapDefaultFree(pItemEventInfo[i].pEventNames[i3]);
466 HeapDefaultFree(pItemEventInfo[i].IdName);
467 HeapDefaultFree(pItemEventInfo[i].pEventNames);
468 }
469 }
470}
471
472void GetItemClassName(char *buffer,int Control){
473 switch(Control){
474 case CT_BUTTON:
475 case CT_CHECKBOX:
476 case CT_GROUPBOX:
477 case CT_RADIOBUTTON:
478 lstrcpy(buffer,"BUTTON");
479 break;
480 case CT_COMBOBOX:
481 lstrcpy(buffer,"COMBOBOX");
482 break;
483 case CT_EDIT:
484 lstrcpy(buffer,"EDIT");
485 break;
486 case CT_HSCROLLBAR:
487 case CT_VSCROLLBAR:
488 lstrcpy(buffer,"SCROLLBAR");
489 break;
490 case CT_LISTBOX:
491 lstrcpy(buffer,"LISTBOX");
492 break;
493 case CT_LISTVIEW:
494 lstrcpy(buffer,"SysListView32");
495 break;
496 case CT_IMAGEBOX:
497 case CT_STATIC:
498 lstrcpy(buffer,"STATIC");
499 break;
500 case CT_PROGRESSBAR:
501 lstrcpy(buffer,"msctls_progress32");
502 break;
503 case CT_TRACKBAR:
504 lstrcpy(buffer,"msctls_trackbar32");
505 break;
506 case CT_TREEVIEW:
507 lstrcpy(buffer,"SysTreeView32");
508 break;
509 //CT_UPDOWNはCreateUpDownControl関数で独自に作成される
510 }
511}
512long GetCommandByMessage(int WndInfoNum,const char *MessageName,BOOL bProcedureCall,char *Command,char *spaces){
513 extern PROJECTINFO ProjectInfo;
514 int i,i2,sw;
515 char temporary[MAX_PATH],*temp2;
516 WINDOW_INFO *pWindowInfo;
517
518 pWindowInfo=&ProjectInfo.pWindowInfo[WndInfoNum];
519
520 Command[0]=0;
521
522
523 /////////////////////
524 // Default コマンド
525
526 if(lstrcmp(MessageName,"Activate")==0){
527 sprintf(Command,"%sCase WM_ACTIVATE\r\n",spaces);
528 i=lstrlen(Command);
529 sprintf(Command+i,"%s\t%s_%s(LOWORD(wParam),HIWORD(wParam))\r\n",spaces,pWindowInfo->name,MessageName);
530 }
531 else if(lstrcmp(MessageName,"Create")==0){
532 if(pWindowInfo->type==WNDTYPE_MODALDLG||pWindowInfo->type==WNDTYPE_MODELESSDLG)
533 sprintf(Command,"%sCase WM_INITDIALOG\r\n",spaces);
534 else sprintf(Command,"%sCase WM_CREATE\r\n",spaces);
535 i=lstrlen(Command);
536
537 sprintf(Command+i,"%s\t%s=hWnd\r\n",spaces,pWindowInfo->HandleName);
538 i+=lstrlen(Command+i);
539
540 if(pWindowInfo->MenuID){
541 //メニュー作成
542 for(i2=0;i2<ProjectInfo.NumberOfMenu;i2++){
543 if(lstrcmpi(ProjectInfo.pMenuInfo[i2].IdName,pWindowInfo->MenuID)==0) break;
544 }
545 if(i2!=ProjectInfo.NumberOfMenu){
546 sprintf(Command+i,"%s\tSetMenu(hWnd,hMenu_%s)\r\n",spaces,ProjectInfo.pMenuInfo[i2].IdName);
547 i+=lstrlen(Command+i);
548 }
549 }
550
551 //子ウィンドウ作成
552 for(i2=0,sw=0;i2<pWindowInfo->NumberOfChildWindows;i2++){
553 if(pWindowInfo->pChildInfo[i2].Control==CT_UPDOWN){
554 sprintf(Command+i,"%s\tCreateUpDownControl(%d,%d,%d,%d,%d,hWnd,%s,GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,0,0,100,0)\r\n",
555 spaces,
556 pWindowInfo->pChildInfo[i2].style,
557 pWindowInfo->pChildInfo[i2].pos.x,pWindowInfo->pChildInfo[i2].pos.y,
558 pWindowInfo->pChildInfo[i2].size.cx,pWindowInfo->pChildInfo[i2].size.cy,
559 pWindowInfo->pChildInfo[i2].IdName);
560 i+=lstrlen(Command+i);
561 }
562 else{
563 GetItemClassName(temporary,pWindowInfo->pChildInfo[i2].Control);
564 temp2=FormatCaption(pWindowInfo->pChildInfo[i2].caption);
565 sprintf(Command+i,"%s\tCreateWindowEx(&H%08x,\"%s\",\"%s\",&H%08x,%d,%d,%d,%d,hWnd,%s As HMENU,GetModuleHandle(0),0)\r\n",
566 spaces,
567 pWindowInfo->pChildInfo[i2].ExStyle,
568 temporary,
569 temp2,
570 pWindowInfo->pChildInfo[i2].style,
571 pWindowInfo->pChildInfo[i2].pos.x,
572 pWindowInfo->pChildInfo[i2].pos.y,
573 pWindowInfo->pChildInfo[i2].size.cx,
574 pWindowInfo->pChildInfo[i2].size.cy,
575 pWindowInfo->pChildInfo[i2].IdName);
576 i+=lstrlen(Command+i);
577 HeapDefaultFree(temp2);
578 sprintf(Command+i,"%s\tSendMessage(GetDlgItem(hWnd,%s),WM_SETFONT,hFont_%s As WPARAM,0)\r\n",
579 spaces,
580 pWindowInfo->pChildInfo[i2].IdName,
581 pWindowInfo->name);
582 i+=lstrlen(Command+i);
583
584 if(pWindowInfo->pChildInfo[i2].Control==CT_IMAGEBOX){
585 //イメージ ボックスの場合
586 if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_ICON){
587 if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_FILE){
588 if(strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,":")||
589 strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,"\\\\")){
590 sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,\"%s\",IMAGE_ICON,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE)\r\n",
591 spaces,
592 pWindowInfo->name,
593 pWindowInfo->pChildInfo[i2].IdName,
594 pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
595 }
596 else{
597 if(sw==0){
598 sw=1;
599 lstrcpy(Command+i,"\r\n");
600 i+=2;
601 sprintf(Command+i,"%s\tDim ImageFilePath[MAX_PATH] As Byte\r\n",spaces);
602 i+=lstrlen(Command+i);
603 sprintf(Command+i,"%s\tDim ModulePath[MAX_PATH] As Byte, i As Long\r\n",spaces);
604 i+=lstrlen(Command+i);
605 sprintf(Command+i,"%s\tGetModuleFileName(GetModuleHandle(0),ModulePath,MAX_PATH)\r\n",spaces);
606 i+=lstrlen(Command+i);
607 sprintf(Command+i,"%s\tFor i=lstrlen(ModulePath)-1 To 0 Step -1\r\n",spaces);
608 i+=lstrlen(Command+i);
609 sprintf(Command+i,"%s\t\tIf ModulePath[i]=&H5C Then Exit For\r\n",spaces);
610 i+=lstrlen(Command+i);
611 sprintf(Command+i,"%s\tNext\r\n",spaces);
612 i+=lstrlen(Command+i);
613 sprintf(Command+i,"%s\tModulePath[i+1]=0\r\n",spaces);
614 i+=lstrlen(Command+i);
615 lstrcpy(Command+i,"\r\n");
616 i+=2;
617 }
618 sprintf(Command+i,"%s\twsprintf(ImageFilePath,\"%%s%s\",ModulePath)\r\n",spaces,pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
619 i+=lstrlen(Command+i);
620 sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,ImageFilePath,IMAGE_ICON,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE)\r\n",
621 spaces,
622 pWindowInfo->name,
623 pWindowInfo->pChildInfo[i2].IdName);
624 }
625 i+=lstrlen(Command+i);
626 }
627 else if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_RES){
628 sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,%s As *Byte,IMAGE_ICON,0,0,LR_DEFAULTSIZE)\r\n",
629 spaces,
630 pWindowInfo->name,
631 pWindowInfo->pChildInfo[i2].IdName,
632 pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
633 i+=lstrlen(Command+i);
634 }
635 sprintf(Command+i,"%s\tSendMessage(GetDlgItem(hWnd,%s),STM_SETICON,hImage_%s_%s As WPARAM,0)\r\n",
636 spaces,
637 pWindowInfo->pChildInfo[i2].IdName,
638 pWindowInfo->name,
639 pWindowInfo->pChildInfo[i2].IdName);
640 i+=lstrlen(Command+i);
641 }
642 else if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_BITMAP){
643 if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_FILE){
644 if(strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,":")||
645 strstr(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path,"\\\\")){
646 sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,\"%s\",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE)\r\n",
647 spaces,
648 pWindowInfo->name,
649 pWindowInfo->pChildInfo[i2].IdName,
650 pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
651 }
652 else{
653 if(sw==0){
654 sw=1;
655 lstrcpy(Command+i,"\r\n");
656 i+=2;
657 sprintf(Command+i,"%s\tDim ImageFilePath[MAX_PATH] As Byte\r\n",spaces);
658 i+=lstrlen(Command+i);
659 sprintf(Command+i,"%s\tDim ModulePath[MAX_PATH] As Byte, i As Long\r\n",spaces);
660 i+=lstrlen(Command+i);
661 sprintf(Command+i,"%s\tGetModuleFileName(GetModuleHandle(0),ModulePath,MAX_PATH)\r\n",spaces);
662 i+=lstrlen(Command+i);
663 sprintf(Command+i,"%s\tFor i=lstrlen(ModulePath)-1 To 0 Step -1\r\n",spaces);
664 i+=lstrlen(Command+i);
665 sprintf(Command+i,"%s\t\tIf ModulePath[i]=&H5C Then Exit For\r\n",spaces);
666 i+=lstrlen(Command+i);
667 sprintf(Command+i,"%s\tNext\r\n",spaces);
668 i+=lstrlen(Command+i);
669 sprintf(Command+i,"%s\tModulePath[i+1]=0\r\n",spaces);
670 i+=lstrlen(Command+i);
671 lstrcpy(Command+i,"\r\n");
672 i+=2;
673 }
674 sprintf(Command+i,"%s\twsprintf(ImageFilePath,\"%%s%s\",ModulePath)\r\n",spaces,pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
675 i+=lstrlen(Command+i);
676 sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,ImageFilePath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE)\r\n",
677 spaces,
678 pWindowInfo->name,
679 pWindowInfo->pChildInfo[i2].IdName);
680 }
681 i+=lstrlen(Command+i);
682 }
683 else if(pWindowInfo->pChildInfo[i2].ImageCtrlInfo.type==IMGTYPE_RES){
684 sprintf(Command+i,"%s\thImage_%s_%s=LoadImage(GetWindowLongPtr(hWnd,GWLP_HINSTANCE) As HINSTANCE,%s As *Byte,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE)\r\n",
685 spaces,
686 pWindowInfo->name,
687 pWindowInfo->pChildInfo[i2].IdName,
688 pWindowInfo->pChildInfo[i2].ImageCtrlInfo.path);
689 i+=lstrlen(Command+i);
690 }
691 sprintf(Command+i,"%s\tSendMessage(GetDlgItem(hWnd,%s),STM_SETIMAGE,IMAGE_BITMAP,hImage_%s_%s As LPARAM)\r\n",
692 spaces,
693 pWindowInfo->pChildInfo[i2].IdName,
694 pWindowInfo->name,
695 pWindowInfo->pChildInfo[i2].IdName);
696 i+=lstrlen(Command+i);
697 }
698 }
699 }
700 }
701
702 if(bProcedureCall)
703 sprintf(Command+i,"%s\t%s_%s(ByVal (lParam As VoidPtr))\r\n",spaces,pWindowInfo->name,MessageName);
704 return WM_CREATE;
705 }
706 else if(lstrcmp(MessageName,"Destroy")==0){
707 sprintf(Command,"%sCase WM_DESTROY\r\n",spaces);
708 i=lstrlen(Command);
709 if(bProcedureCall){
710 sprintf(Command+i,"%s\t%s_%s()\r\n",spaces,pWindowInfo->name,MessageName);
711 i+=lstrlen(Command+i);
712 }
713
714 if(pWindowInfo->MenuID){
715 //メニューを解放
716 for(i2=0;i2<ProjectInfo.NumberOfMenu;i2++){
717 if(lstrcmpi(ProjectInfo.pMenuInfo[i2].IdName,pWindowInfo->MenuID)==0) break;
718 }
719 if(i2!=ProjectInfo.NumberOfMenu){
720 sprintf(Command+i,"%s\tSetMenu(hWnd,NULL)\r\n",spaces);
721 i+=lstrlen(Command+i);
722 }
723 }
724
725 //イメージ ボックス用の変数を解放
726 for(i2=0;i2<pWindowInfo->NumberOfChildWindows;i2++){
727 if(pWindowInfo->pChildInfo[i2].Control==CT_IMAGEBOX){
728 if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_ICON)
729 sprintf(Command+i,"%s\tDestroyIcon(hImage_%s_%s)\r\n",spaces,pWindowInfo->name,pWindowInfo->pChildInfo[i2].IdName);
730 else if((pWindowInfo->pChildInfo[i2].style&0x000F)==SS_BITMAP)
731 sprintf(Command+i,"%s\tDeleteObject(hImage_%s_%s)\r\n",spaces,pWindowInfo->name,pWindowInfo->pChildInfo[i2].IdName);
732 i+=lstrlen(Command+i);
733 }
734 }
735 return WM_DESTROY;
736 }
737 else if(lstrcmp(MessageName,"DropFiles")==0){
738 sprintf(Command,"%sCase WM_DROPFILES\r\n",spaces);
739 i=lstrlen(Command);
740 sprintf(Command+i,"%s\t%s_%s(wParam As HDROP)\r\n",spaces,pWindowInfo->name,MessageName);
741 }
742 else if(lstrcmp(MessageName,"HScroll")==0){
743 sprintf(Command,"%sCase WM_HSCROLL\r\n",spaces);
744 i=lstrlen(Command);
745 sprintf(Command+i,"%s\t%s_%s(LOWORD(wParam),HIWORD(wParam),lParam As HWND)\r\n",spaces,pWindowInfo->name,MessageName);
746 }
747 else if(lstrcmp(MessageName,"KeyDown")==0){
748 sprintf(Command,"%sCase WM_KEYDOWN\r\n",spaces);
749 i=lstrlen(Command);
750 sprintf(Command+i,"%s\t%s_%s(wParam As Long,lParam As Long)\r\n",spaces,pWindowInfo->name,MessageName);
751 }
752 else if(lstrcmp(MessageName,"KeyPress")==0){
753 sprintf(Command,"%sCase WM_CHAR\r\n",spaces);
754 i=lstrlen(Command);
755 sprintf(Command+i,"%s\t%s_%s(wParam As Long,lParam As Long)\r\n",spaces,pWindowInfo->name,MessageName);
756 }
757 else if(lstrcmp(MessageName,"KeyUp")==0){
758 sprintf(Command,"%sCase WM_KEYUP\r\n",spaces);
759 i=lstrlen(Command);
760 sprintf(Command+i,"%s\t%s_%s(wParam As Long,lParam As Long)\r\n",spaces,pWindowInfo->name,MessageName);
761 }
762 else if(lstrcmp(MessageName,"LButtonDown")==0){
763 sprintf(Command,"%sCase WM_LBUTTONDOWN\r\n",spaces);
764 i=lstrlen(Command);
765 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
766 }
767 else if(lstrcmp(MessageName,"LButtonDblClick")==0){
768 sprintf(Command,"%sCase WM_LBUTTONDBLCLK\r\n",spaces);
769 i=lstrlen(Command);
770 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
771 }
772 else if(lstrcmp(MessageName,"LButtonUp")==0){
773 sprintf(Command,"%sCase WM_LBUTTONUP\r\n",spaces);
774 i=lstrlen(Command);
775 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
776 }
777 else if(lstrcmp(MessageName,"MButtonDown")==0){
778 sprintf(Command,"%sCase WM_MBUTTONDOWN\r\n",spaces);
779 i=lstrlen(Command);
780 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
781 }
782 else if(lstrcmp(MessageName,"MButtonDblClick")==0){
783 sprintf(Command,"%sCase WM_MBUTTONDBLCLK\r\n",spaces);
784 i=lstrlen(Command);
785 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
786 }
787 else if(lstrcmp(MessageName,"MButtonUp")==0){
788 sprintf(Command,"%sCase WM_MBUTTONUP\r\n",spaces);
789 i=lstrlen(Command);
790 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
791 }
792 else if(lstrcmp(MessageName,"MouseMove")==0){
793 sprintf(Command,"%sCase WM_MOUSEMOVE\r\n",spaces);
794 i=lstrlen(Command);
795 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
796 }
797 else if(lstrcmp(MessageName,"Move")==0){
798 sprintf(Command,"%sCase WM_MOVE\r\n",spaces);
799 i=lstrlen(Command);
800 sprintf(Command+i,"%s\t%s_%s(LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
801 }
802 else if(lstrcmp(MessageName,"Notify")==0){
803 //コモンコントロールメッセージと共に挿入
804 return WM_NOTIFY;
805 }
806 else if(lstrcmp(MessageName,"Paint")==0){
807 sprintf(Command,"%sCase WM_PAINT\r\n",spaces);
808 i=lstrlen(Command);
809 sprintf(Command+i,"%s\tDim ps As PAINTSTRUCT\r\n",spaces);
810 i+=lstrlen(Command+i);
811 sprintf(Command+i,"%s\tDim hDC As HDC\r\n",spaces);
812 i+=lstrlen(Command+i);
813 sprintf(Command+i,"%s\thDC=BeginPaint(hWnd,ps)\r\n",spaces);
814 i+=lstrlen(Command+i);
815 sprintf(Command+i,"%s\t%s_%s(hDC)\r\n",spaces,pWindowInfo->name,MessageName);
816 i+=lstrlen(Command+i);
817 sprintf(Command+i,"%s\tEndPaint(hWnd,ps)\r\n",spaces);
818 return WM_PAINT;
819 }
820 else if(lstrcmp(MessageName,"QueryClose")==0){
821 sprintf(Command,"%sCase WM_CLOSE\r\n",spaces);
822 i=lstrlen(Command);
823 sprintf(Command+i,"%s\tDim cancel=0 As Integer\r\n",spaces);
824 i+=lstrlen(Command+i);
825 if(bProcedureCall){
826 sprintf(Command+i,"%s\t%s_%s(cancel)\r\n",spaces,pWindowInfo->name,MessageName);
827 i+=lstrlen(Command+i);
828 }
829 if(pWindowInfo->type==WNDTYPE_MODALDLG)
830 sprintf(Command+i,"%s\tIf cancel=0 Then EndDialog(hWnd,0)\r\n",spaces);
831 else
832 sprintf(Command+i,"%s\tIf cancel=0 Then DestroyWindow(hWnd)\r\n",spaces);
833 return WM_CLOSE;
834 }
835 else if(lstrcmp(MessageName,"RButtonDblClick")==0){
836 sprintf(Command,"%sCase WM_RBUTTONDBLCLK\r\n",spaces);
837 i=lstrlen(Command);
838 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
839 }
840 else if(lstrcmp(MessageName,"RButtonDown")==0){
841 sprintf(Command,"%sCase WM_RBUTTONDOWN\r\n",spaces);
842 i=lstrlen(Command);
843 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
844 }
845 else if(lstrcmp(MessageName,"RButtonUp")==0){
846 sprintf(Command,"%sCase WM_RBUTTONUP\r\n",spaces);
847 i=lstrlen(Command);
848 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
849 }
850 else if(lstrcmp(MessageName,"Resize")==0){
851 sprintf(Command,"%sCase WM_SIZE\r\n",spaces);
852 i=lstrlen(Command);
853 sprintf(Command+i,"%s\t%s_%s(wParam As Long,LOWORD(lParam),HIWORD(lParam))\r\n",spaces,pWindowInfo->name,MessageName);
854 }
855 else if(lstrcmp(MessageName,"SetFocus")==0){
856 sprintf(Command,"%sCase WM_SETFOCUS\r\n",spaces);
857 i=lstrlen(Command);
858 sprintf(Command+i,"%s\t%s_%s()\r\n",spaces,pWindowInfo->name,MessageName);
859 }
860 else if(lstrcmp(MessageName,"Timer")==0){
861 sprintf(Command,"%sCase WM_TIMER\r\n",spaces);
862 i=lstrlen(Command);
863 sprintf(Command+i,"%s\t%s_%s(wParam As DWord)\r\n",spaces,pWindowInfo->name,MessageName);
864 }
865 else if(lstrcmp(MessageName,"VScroll")==0){
866 sprintf(Command,"%sCase WM_VSCROLL\r\n",spaces);
867 i=lstrlen(Command);
868 sprintf(Command+i,"%s\t%s_%s(LOWORD(wParam),HIWORD(wParam),lParam As HWND)\r\n",spaces,pWindowInfo->name,MessageName);
869 }
870
871
872 ///////////////////
873 // MMSYS コマンド
874
875 else if(lstrcmp(MessageName,"MciNotify")==0){
876 sprintf(Command,"%sCase MM_MCINOTIFY\r\n",spaces);
877 i=lstrlen(Command);
878 sprintf(Command+i,"%s\t%s_%s(wParam,lParam)\r\n",spaces,pWindowInfo->name,MessageName);
879 }
880 return 0;
881}
882
883char **GetMenuItemConstData(MENU_INFO *pMenuInfo,int NumberOfMenu,int *ConstNumber,char **ppNames,int *NamesNum,char *buffer,int *base){
884 extern HANDLE hHeap;
885 int i,i2,sw1;
886
887 for(i=0;i<NumberOfMenu;i++){
888 if(pMenuInfo[i].pMenuInfo){
889 //ポップアップ
890 ppNames=GetMenuItemConstData(pMenuInfo[i].pMenuInfo,pMenuInfo[i].NumberOfMenu,ConstNumber,ppNames,NamesNum,buffer,base);
891 }
892 else if(pMenuInfo[i].type==MFT_STRING){
893 //重複チェック
894 for(i2=0,sw1=0;i2<*NamesNum;i2++){
895 if(lstrcmpi(ppNames[i2],pMenuInfo[i].IdName)==0){
896 sw1=1;
897 break;
898 }
899 }
900 if(sw1==0){
901 ppNames=(char **)HeapReAlloc(hHeap,0,ppNames,sizeof(char *)*((*NamesNum)+1));
902 ppNames[*NamesNum]=pMenuInfo[i].IdName;
903 (*NamesNum)++;
904
905 sprintf(buffer+(*base),"Const %s=%d\r\n",pMenuInfo[i].IdName,*ConstNumber);
906 (*base)+=lstrlen(buffer+(*base));
907 (*ConstNumber)++;
908 }
909 }
910 }
911 return ppNames;
912}
913int GetMakeMenuCommand(MENU_INFO *pMenuInfo,int NumberOfMenu,char *MenuHandle,char *Command,BOOL bMain){
914 int i,i2;
915 char temporary[MAX_PATH];
916
917 i=0;
918 sprintf(Command+i,"Dim %s As HMENU\r\n",MenuHandle);
919 i+=lstrlen(Command+i);
920 if(bMain) sprintf(Command+i,"%s=CreateMenu()\r\n",MenuHandle);
921 else sprintf(Command+i,"%s=CreatePopupMenu()\r\n",MenuHandle);
922 i+=lstrlen(Command+i);
923
924 for(i2=NumberOfMenu-1;i2>=0;i2--){
925 if(pMenuInfo[i2].pMenuInfo){
926 sprintf(temporary,"%s_%d",MenuHandle,i2);
927 i+=GetMakeMenuCommand(pMenuInfo[i2].pMenuInfo,pMenuInfo[i2].NumberOfMenu,temporary,Command+i,0);
928 sprintf(Command+i,"InsMenu %s,0,MF_BYPOSITION,Ex\"%s\",0,%s,%d\r\n",
929 MenuHandle,
930 pMenuInfo[i2].caption,
931 temporary,
932 pMenuInfo[i2].state);
933 i+=lstrlen(Command+i);
934 }
935 else{
936 if(pMenuInfo[i2].type==MFT_STRING){
937 sprintf(Command+i,"InsMenu %s,0,MF_BYPOSITION,Ex\"%s\",%s,0,%d\r\n",
938 MenuHandle,
939 pMenuInfo[i2].caption,
940 pMenuInfo[i2].IdName,
941 pMenuInfo[i2].state);
942 i+=lstrlen(Command+i);
943 }
944 else if(pMenuInfo[i2].type==MFT_SEPARATOR){
945 sprintf(Command+i,"InsMenu %s,0,MF_BYPOSITION,\"\"\r\n",
946 MenuHandle);
947 i+=lstrlen(Command+i);
948 }
949 }
950 }
951 return i;
952}
953int GetDestroyMenuCommand(MENU_INFO *pMenuInfo,int NumberOfMenu,char *MenuHandle,char *Command){
954 int i,i2;
955 char temporary[MAX_PATH];
956
957 i=0;
958 sprintf(Command+i,"\tDestroyMenu(%s)\r\n",MenuHandle);
959 i+=lstrlen(Command+i);
960
961 for(i2=NumberOfMenu-1;i2>=0;i2--){
962 if(pMenuInfo[i2].pMenuInfo){
963 sprintf(temporary,"%s_%d",MenuHandle,i2);
964 i+=GetDestroyMenuCommand(pMenuInfo[i2].pMenuInfo,pMenuInfo[i2].NumberOfMenu,temporary,Command+i);
965 }
966 }
967 return i;
968}
969void SaveWindowProgram(){
970 extern HANDLE hHeap;
971 extern PROJECTINFO ProjectInfo;
972 int i,i2,i3,i4,i5,i6,sw1,sw2,sw3,sw4,size;
973 char *buffer,**ppNames,temporary[MAX_PATH];
974 WINDOW_INFO *pWindowInfo;
975
976 pWindowInfo=ProjectInfo.pWindowInfo;
977
978 size=2;
979 buffer=(char *)HeapAlloc(hHeap,0,65535*size);
980 lstrcpy(buffer,"'このファイルはウィンドウ定義ファイル(*.wnd)をもとに生成されています\r\n\r\n");
981 i2=lstrlen(buffer);
982
983 if(ProjectInfo.dwOption&PJ_OP_COMMCTRL){
984 //コマンコントロールを初期化
985 lstrcpy(buffer+i2,"Dim _RadSys_InitCtrls As INITCOMMONCONTROLSEX\r\n");
986 i2+=lstrlen(buffer+i2);
987 lstrcpy(buffer+i2,"_RadSys_InitCtrls.dwSize=Len(_RadSys_InitCtrls)\r\n");
988 i2+=lstrlen(buffer+i2);
989 lstrcpy(buffer+i2,"_RadSys_InitCtrls.dwICC=ICC_WIN95_CLASSES\r\n");
990 i2+=lstrlen(buffer+i2);
991 lstrcpy(buffer+i2,"InitCommonControlsEx(_RadSys_InitCtrls)\r\n\r\n");
992 i2+=lstrlen(buffer+i2);
993 }
994
995
996 ////////////
997 //IDを定義
998
999 ppNames=(char **)HeapAlloc(hHeap,0,1);
1000 for(i=0,i4=1000,i5=0;i<ProjectInfo.NumberOfWindows;i++){
1001 for(i3=0;i3<pWindowInfo[i].NumberOfChildWindows;i3++){
1002
1003 //重複チェック
1004 for(i6=0,sw1=0;i6<i5;i6++){
1005 if(lstrcmpi(ppNames[i6],pWindowInfo[i].pChildInfo[i3].IdName)==0){
1006 sw1=1;
1007 break;
1008 }
1009 }
1010 if(sw1) continue;
1011
1012 ppNames=(char **)HeapReAlloc(hHeap,0,ppNames,sizeof(char *)*(i5+1));
1013 ppNames[i5]=pWindowInfo[i].pChildInfo[i3].IdName;
1014 i5++;
1015
1016 sprintf(buffer+i2,"Const %s=%d\r\n",pWindowInfo[i].pChildInfo[i3].IdName,i4);
1017 i2+=lstrlen(buffer+i2);
1018 i4++;
1019
1020 while(i2>65535*(size-1)){
1021 size++;
1022 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1023 }
1024 }
1025 }
1026
1027 //メニューのIDを定義
1028 ppNames=GetMenuItemConstData(ProjectInfo.pMenuInfo,ProjectInfo.NumberOfMenu,&i4,ppNames,&i5,buffer,&i2);
1029
1030 HeapDefaultFree(ppNames);
1031 lstrcpy(buffer+i2,"\r\n");
1032 i2+=lstrlen(buffer+i2);
1033
1034
1035 //ハンドル変数を定義
1036 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1037 sprintf(buffer+i2,"Dim %s As HWND\r\n",pWindowInfo[i].HandleName);
1038 i2+=lstrlen(buffer+i2);
1039 sprintf(buffer+i2,"Dim hFont_%s As HFONT\r\n",pWindowInfo[i].name);
1040 i2+=lstrlen(buffer+i2);
1041 sprintf(buffer+i2,"hFont_%s=CreateFont(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\"%s\")\r\n",
1042 pWindowInfo[i].name,
1043 pWindowInfo[i].LogFont.lfHeight,
1044 pWindowInfo[i].LogFont.lfWidth,
1045 pWindowInfo[i].LogFont.lfEscapement,
1046 pWindowInfo[i].LogFont.lfOrientation,
1047 pWindowInfo[i].LogFont.lfWeight,
1048 pWindowInfo[i].LogFont.lfItalic,
1049 pWindowInfo[i].LogFont.lfUnderline,
1050 pWindowInfo[i].LogFont.lfStrikeOut,
1051 pWindowInfo[i].LogFont.lfCharSet,
1052 pWindowInfo[i].LogFont.lfOutPrecision,
1053 pWindowInfo[i].LogFont.lfClipPrecision,
1054 pWindowInfo[i].LogFont.lfQuality,
1055 pWindowInfo[i].LogFont.lfPitchAndFamily,
1056 pWindowInfo[i].LogFont.lfFaceName);
1057 i2+=lstrlen(buffer+i2);
1058
1059 while(i2>65535*(size-1)){
1060 size++;
1061 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1062 }
1063 }
1064
1065 //背景に使用するブラシを定義
1066 lstrcpy(buffer+i2,"Dim h3DFaceBrush As HBRUSH\r\n");
1067 i2+=lstrlen(buffer+i2);
1068 lstrcpy(buffer+i2,"h3DFaceBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE))\r\n");
1069 i2+=lstrlen(buffer+i2);
1070 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1071 if(pWindowInfo[i].bgColor<=0&&
1072 pWindowInfo[i].bgColor!=-(int)RGB(255,255,255)&&
1073 pWindowInfo[i].bgColor!=-(int)RGB(0,0,0)){
1074 sprintf(buffer+i2,"Dim _RadSys_hBackBrush%d As HBRUSH\r\n",i);
1075 i2+=lstrlen(buffer+i2);
1076 sprintf(buffer+i2,"_RadSys_hBackBrush%d=CreateSolidBrush(%d)\r\n",i,-pWindowInfo[i].bgColor);
1077 i2+=lstrlen(buffer+i2);
1078 }
1079 if(pWindowInfo[i].bgColor>=0x1000){
1080 sprintf(buffer+i2,"Dim _RadSys_hBackBrush%d As HBRUSH\r\n",i);
1081 i2+=lstrlen(buffer+i2);
1082 sprintf(buffer+i2,"_RadSys_hBackBrush%d=CreatePatternBrush(LoadImage(GetModuleHandle(0),%s,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE or LR_SHARED))\r\n",
1083 i,
1084 ProjectInfo.res.pBitmapResInfo[pWindowInfo[i].bgColor-0x1000].IdName);
1085 i2+=lstrlen(buffer+i2);
1086 }
1087 }
1088
1089 lstrcpy(buffer+i2,"\r\n");
1090 i2+=lstrlen(buffer+i2);
1091
1092 //イメージ ボックス用の変数を定義
1093 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1094 for(i3=0;i3<pWindowInfo[i].NumberOfChildWindows;i3++){
1095 if(pWindowInfo[i].pChildInfo[i3].Control==CT_IMAGEBOX){
1096 if((pWindowInfo[i].pChildInfo[i3].style&0x000F)==SS_ICON||
1097 (pWindowInfo[i].pChildInfo[i3].style&0x000F)==SS_BITMAP){
1098 sprintf(buffer+i2,"Dim hImage_%s_%s As HANDLE\r\n",pWindowInfo[i].name,pWindowInfo[i].pChildInfo[i3].IdName);
1099 i2+=lstrlen(buffer+i2);
1100
1101 while(i2>65535*(size-1)){
1102 size++;
1103 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1104 }
1105 }
1106 }
1107 }
1108 }
1109
1110 lstrcpy(buffer+i2,"\r\n");
1111 i2+=lstrlen(buffer+i2);
1112
1113 //メニュー作成
1114 for(i=0;i<ProjectInfo.NumberOfMenu;i++){
1115 sprintf(temporary,"hMenu_%s",ProjectInfo.pMenuInfo[i].IdName);
1116
1117 //InsertMenuItem郡
1118 i2+=GetMakeMenuCommand(ProjectInfo.pMenuInfo[i].pMenuInfo,ProjectInfo.pMenuInfo[i].NumberOfMenu,temporary,buffer+i2,1);
1119
1120 lstrcpy(buffer+i2,"\r\n");
1121 i2+=lstrlen(buffer+i2);
1122
1123 while(i2>65535*(size-1)){
1124 size++;
1125 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1126 }
1127 }
1128
1129
1130 //////////////////////////
1131 //オブジェクトの解放処理
1132 sprintf(buffer+i2,"Sub %s_DestroyObjects()\r\n",ProjectInfo.name);
1133 i2+=lstrlen(buffer+i2);
1134
1135 //メニュー解放
1136 for(i=0;i<ProjectInfo.NumberOfMenu;i++){
1137 sprintf(temporary,"hMenu_%s",ProjectInfo.pMenuInfo[i].IdName);
1138 i2+=GetDestroyMenuCommand(ProjectInfo.pMenuInfo[i].pMenuInfo,ProjectInfo.pMenuInfo[i].NumberOfMenu,temporary,buffer+i2);
1139
1140 while(i2>65535*(size-1)){
1141 size++;
1142 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1143 }
1144 }
1145
1146 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1147 //フォントハンドル解放
1148 sprintf(buffer+i2,"\tDeleteObject(hFont_%s)\r\n",ProjectInfo.pWindowInfo[i].name);
1149 i2+=lstrlen(buffer+i2);
1150
1151 while(i2>65535*(size-1)){
1152 size++;
1153 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1154 }
1155 }
1156
1157 //背景ブラシを解放
1158 lstrcpy(buffer+i2,"\tDeleteObject(h3DFaceBrush)\r\n");
1159 i2+=lstrlen(buffer+i2);
1160 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1161 if(pWindowInfo[i].bgColor<=0&&
1162 pWindowInfo[i].bgColor!=-(int)RGB(255,255,255)&&
1163 pWindowInfo[i].bgColor!=-(int)RGB(0,0,0)){
1164 sprintf(buffer+i2,"\tDeleteObject(_RadSys_hBackBrush%d)\r\n",i);
1165 i2+=lstrlen(buffer+i2);
1166 }
1167 }
1168
1169 sprintf(buffer+i2,"End Sub\r\n\r\n");
1170 i2+=lstrlen(buffer+i2);
1171
1172 //ユーザー定義のコールバック関数が存在するかどうか
1173 BOOL bAvailUserProc[MAX_WNDNUM];
1174
1175
1176 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1177 if(i!=0){
1178 lstrcpy(buffer+i2,"\r\n");
1179 i2+=lstrlen(buffer+i2);
1180 }
1181
1182 //////////////////////////
1183 //コールバック関数を生成
1184
1185 //処理メッセージを抽出
1186 ITEMEVENTINFO *pItemEventInfo;
1187 ppNames=GetProcedureNamesOfMessageCall(i,&pItemEventInfo,&i3,&bAvailUserProc[i]);
1188
1189 sprintf(buffer+i2,"Function EventCall_%s(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT\r\n",pWindowInfo[i].name);
1190 i2+=lstrlen(buffer+i2);
1191
1192 lstrcpy(buffer+i2,"\tSelect Case message\r\n");
1193 i2+=lstrlen(buffer+i2);
1194
1195 //通常メッセージ郡
1196 for(i4=0,sw1=0,sw2=0,sw3=0,sw4=0;i4<i3;i4++){
1197 i5=GetCommandByMessage(i,ppNames[i4],1,buffer+i2,"\t\t");
1198 i2+=lstrlen(buffer+i2);
1199 if(i5==WM_CREATE) sw1=1;
1200 else if(i5==WM_DESTROY) sw2=1;
1201 else if(i5==WM_CLOSE) sw3=1;
1202 else if(i5==WM_NOTIFY) sw4=1;
1203 HeapDefaultFree(ppNames[i4]);
1204 }
1205 HeapDefaultFree(ppNames);
1206
1207 //WM_CREATE、WM_DESTROY、WM_PAINTが呼び出されていない場合
1208 if(!sw1){
1209 GetCommandByMessage(i,"Create",0,buffer+i2,"\t\t");
1210 i2+=lstrlen(buffer+i2);
1211 }
1212 if(!sw2){
1213 GetCommandByMessage(i,"Destroy",0,buffer+i2,"\t\t");
1214 i2+=lstrlen(buffer+i2);
1215 }
1216 if(!sw3){
1217 GetCommandByMessage(i,"QueryClose",0,buffer+i2,"\t\t");
1218 i2+=lstrlen(buffer+i2);
1219 }
1220
1221 //アイテムメッセージ郡(WM_NOTIFY)
1222 if(pItemEventInfo[0].IdName){
1223 i3=i2;
1224 lstrcpy(buffer+i2,"\t\tCase WM_NOTIFY\r\n");
1225 i2+=lstrlen(buffer+i2);
1226 if(sw4){
1227 sprintf(buffer+i2,"\t\t\t%s_Notify(ByVal (lParam As *NMHDR))\r\n",pWindowInfo[i].name);
1228 i2+=lstrlen(buffer+i2);
1229 }
1230 lstrcpy(buffer+i2,"\t\t\tDim pnmHdr As *NMHDR\r\n");
1231 i2+=lstrlen(buffer+i2);
1232 lstrcpy(buffer+i2,"\t\t\tpnmHdr=lParam As *NMHDR\r\n");
1233 i2+=lstrlen(buffer+i2);
1234 lstrcpy(buffer+i2,"\t\t\tSelect Case LOWORD(wParam)\r\n");
1235 i2+=lstrlen(buffer+i2);
1236
1237 if(GetNotifyCommandByItemMessage(&pWindowInfo[i],pItemEventInfo,buffer+i2,"\t\t\t\t")){
1238 i2+=lstrlen(buffer+i2);
1239
1240 lstrcpy(buffer+i2,"\t\t\tEnd Select\r\n");
1241 i2+=lstrlen(buffer+i2);
1242 }
1243 else{
1244 //WM_NOTIFYを削除
1245 i2=i3;
1246 if(sw4) goto DefaultNotifyEvent;
1247 }
1248 }
1249 else if(sw4){
1250DefaultNotifyEvent:
1251 lstrcpy(buffer+i2,"\t\tCase WM_NOTIFY\r\n");
1252 i2+=lstrlen(buffer+i2);
1253 sprintf(buffer+i2,"\t\t\t%s_Notify(ByVal (lParam As *NMHDR))\r\n",pWindowInfo[i].name);
1254 i2+=lstrlen(buffer+i2);
1255 }
1256
1257 //アイテムメッセージ郡(WM_COMMAND)
1258 if(pItemEventInfo[0].IdName){
1259 lstrcpy(buffer+i2,"\t\tCase WM_COMMAND\r\n");
1260 i2+=lstrlen(buffer+i2);
1261 lstrcpy(buffer+i2,"\t\t\tSelect Case LOWORD(wParam)\r\n");
1262 i2+=lstrlen(buffer+i2);
1263
1264 //pItemEventInfoのIdName、EventNameメンバのメモリ解放はこの関数内で行う
1265 GetCommandByItemMessage(&pWindowInfo[i],pItemEventInfo,buffer+i2,"\t\t\t\t");
1266 i2+=lstrlen(buffer+i2);
1267
1268 lstrcpy(buffer+i2,"\t\t\tEnd Select\r\n");
1269 i2+=lstrlen(buffer+i2);
1270 }
1271 HeapDefaultFree(pItemEventInfo);
1272
1273 // DefWindowProc関数
1274 lstrcpy(buffer+i2,"\t\tCase Else\r\n");
1275 i2+=lstrlen(buffer+i2);
1276 sprintf(buffer+i2,"\t\t\tEventCall_%s=DefWindowProc(hWnd,message,wParam,lParam)\r\n",pWindowInfo[i].name);
1277 i2+=lstrlen(buffer+i2);
1278 lstrcpy(buffer+i2,"\t\t\tExit Function\r\n");
1279 i2+=lstrlen(buffer+i2);
1280
1281 lstrcpy(buffer+i2,"\tEnd Select\r\n");
1282 i2+=lstrlen(buffer+i2);
1283
1284 sprintf(buffer+i2,"\tEventCall_%s=0\r\n",pWindowInfo[i].name);
1285 i2+=lstrlen(buffer+i2);
1286 lstrcpy(buffer+i2,"End Function\r\n");
1287 i2+=lstrlen(buffer+i2);
1288
1289 while(i2>65535*(size-1)){
1290 size++;
1291 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1292 }
1293 }
1294
1295
1296 //////////////////////////
1297 //ダイアログボックス関連
1298
1299 //クラス登録
1300 lstrcpy(buffer+i2,"\r\nFunction DefaultCallProc(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT\r\n");
1301 i2+=lstrlen(buffer+i2);
1302 lstrcpy(buffer+i2,"\tDefaultCallProc=DefWindowProc(hWnd,message,wParam,lParam)\r\n");
1303 i2+=lstrlen(buffer+i2);
1304 lstrcpy(buffer+i2,"End Function\r\n");
1305 i2+=lstrlen(buffer+i2);
1306 lstrcpy(buffer+i2,"\r\nDim _RadSys_dlgwcl As WNDCLASSEX\r\n");
1307 i2+=lstrlen(buffer+i2);
1308 lstrcpy(buffer+i2,"FillMemory(VarPtr(_RadSys_dlgwcl),Len(_RadSys_dlgwcl),0)\r\n");
1309 i2+=lstrlen(buffer+i2);
1310 lstrcpy(buffer+i2,"_RadSys_dlgwcl.cbSize=Len(_RadSys_dlgwcl)\r\n");
1311 i2+=lstrlen(buffer+i2);
1312 lstrcpy(buffer+i2,"_RadSys_dlgwcl.hInstance=GetModuleHandle(0)\r\n");
1313 i2+=lstrlen(buffer+i2);
1314 lstrcpy(buffer+i2,"_RadSys_dlgwcl.style=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS\r\n");
1315 i2+=lstrlen(buffer+i2);
1316 lstrcpy(buffer+i2,"_RadSys_dlgwcl.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION))\r\n");
1317 i2+=lstrlen(buffer+i2);
1318 lstrcpy(buffer+i2,"_RadSys_dlgwcl.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDI_WINLOGO))\r\n");
1319 i2+=lstrlen(buffer+i2);
1320 lstrcpy(buffer+i2,"_RadSys_dlgwcl.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW))\r\n");
1321 i2+=lstrlen(buffer+i2);
1322 lstrcpy(buffer+i2,"_RadSys_dlgwcl.lpszClassName=\"NORMALDLG\"\r\n");
1323 i2+=lstrlen(buffer+i2);
1324 lstrcpy(buffer+i2,"_RadSys_dlgwcl.hbrBackground=h3DFaceBrush\r\n");
1325 i2+=lstrlen(buffer+i2);
1326 lstrcpy(buffer+i2,"_RadSys_dlgwcl.lpfnWndProc=AddressOf(DefaultCallProc)\r\n");
1327 i2+=lstrlen(buffer+i2);
1328 lstrcpy(buffer+i2,"RegisterClassEx(_RadSys_dlgwcl)\r\n");
1329 i2+=lstrlen(buffer+i2);
1330
1331 //DialogBox関数
1332 lstrcpy(buffer+i2,"\r\nFunction DialogBox(hOwnerWnd As HWND, TemplateName As LPSTR) As LONG_PTR\r\n");
1333 i2+=lstrlen(buffer+i2);
1334 lstrcpy(buffer+i2,"\tDim hDlg As HWND\r\n");
1335 i2+=lstrlen(buffer+i2);
1336 for(i=0,sw1=0;i<ProjectInfo.NumberOfWindows;i++){
1337 if(pWindowInfo[i].type==WNDTYPE_MODALDLG){
1338 if(sw1==0){
1339 sprintf(buffer+i2,"\tIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",pWindowInfo[i].name);
1340 i2+=lstrlen(buffer+i2);
1341 sw1=1;
1342 }
1343 else{
1344 sprintf(buffer+i2,"\tElseIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",pWindowInfo[i].name);
1345 i2+=lstrlen(buffer+i2);
1346 }
1347 sprintf(buffer+i2,"\t\t%s=CreateWindowEx(&H%08x,\"NORMALDLG\",\"%s\",&H%08x,%d,%d,%d,%d,hOwnerWnd,%d As HMENU,GetModuleHandle(0),0)\r\n",
1348 pWindowInfo[i].HandleName,
1349 pWindowInfo[i].ExStyle,
1350 pWindowInfo[i].caption,
1351 pWindowInfo[i].style,
1352 pWindowInfo[i].pos.x,
1353 pWindowInfo[i].pos.y,
1354 pWindowInfo[i].size.cx,
1355 pWindowInfo[i].size.cy,
1356 pWindowInfo[i].id);
1357 i2+=lstrlen(buffer+i2);
1358 sprintf(buffer+i2,"\t\thDlg=%s\r\n",
1359 pWindowInfo[i].HandleName);
1360 i2+=lstrlen(buffer+i2);
1361 if(bAvailUserProc[i]){
1362 sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(%s) As LONG_PTR)\r\n",
1363 pWindowInfo[i].HandleName,
1364 pWindowInfo[i].CallBackName);
1365 }
1366 else{
1367 sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(EventCall_%s) As LONG_PTR)\r\n",
1368 pWindowInfo[i].HandleName,
1369 pWindowInfo[i].name);
1370 }
1371 i2+=lstrlen(buffer+i2);
1372 sprintf(buffer+i2,"\t\tSendMessage(%s,WM_INITDIALOG,0,0)\r\n",pWindowInfo[i].HandleName);
1373 i2+=lstrlen(buffer+i2);
1374 if(pWindowInfo[i].IconResName){
1375 sprintf(buffer+i2,"\t\tSendMessage(%s,WM_SETICON,ICON_SMALL,LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(%s)) As LPARAM)\r\n",pWindowInfo[i].HandleName,pWindowInfo[i].IconResName);
1376 i2+=lstrlen(buffer+i2);
1377 }
1378 sprintf(buffer+i2,"\t\tShowWindow(%s,SW_SHOW)\r\n",pWindowInfo[i].HandleName);
1379 i2+=lstrlen(buffer+i2);
1380 }
1381 while(i2>65535*(size-1)){
1382 size++;
1383 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1384 }
1385 }
1386 if(sw1){
1387 lstrcpy(buffer+i2,"\tElse\r\n");
1388 i2+=lstrlen(buffer+i2);
1389 lstrcpy(buffer+i2,"\t\tExit Function\r\n");
1390 i2+=lstrlen(buffer+i2);
1391 lstrcpy(buffer+i2,"\tEnd If\r\n");
1392 i2+=lstrlen(buffer+i2);
1393 lstrcpy(buffer+i2,"\tEnableWindow(hOwnerWnd,0)\r\n\r\n");
1394 i2+=lstrlen(buffer+i2);
1395 lstrcpy(buffer+i2,"\tDim msg As MSG, iResult As Long\r\n");
1396 i2+=lstrlen(buffer+i2);
1397 lstrcpy(buffer+i2,"\tDo\r\n");
1398 i2+=lstrlen(buffer+i2);
1399 lstrcpy(buffer+i2,"\t\tiResult=GetMessage(msg,0,0,0)\r\n");
1400 i2+=lstrlen(buffer+i2);
1401 lstrcpy(buffer+i2,"\t\tIf iResult=0 or iResult=-1 Then Exit Do\r\n");
1402 i2+=lstrlen(buffer+i2);
1403 lstrcpy(buffer+i2,"\t\tIf IsDialogMessage(hDlg,msg) Then Continue\r\n");
1404 i2+=lstrlen(buffer+i2);
1405 lstrcpy(buffer+i2,"\t\tTranslateMessage(msg)\r\n");
1406 i2+=lstrlen(buffer+i2);
1407 lstrcpy(buffer+i2,"\t\tDispatchMessage(msg)\r\n");
1408 i2+=lstrlen(buffer+i2);
1409 lstrcpy(buffer+i2,"\tLoop\r\n");
1410 i2+=lstrlen(buffer+i2);
1411 lstrcpy(buffer+i2,"\tDialogBox=msg.wParam\r\n");
1412 i2+=lstrlen(buffer+i2);
1413 }
1414 lstrcpy(buffer+i2,"End Function\r\n");
1415 i2+=lstrlen(buffer+i2);
1416
1417 //EndDialog関数
1418 lstrcpy(buffer+i2,"Sub EndDialog(hWnd As HWND, lResult As Long)\r\n");
1419 i2+=lstrlen(buffer+i2);
1420 lstrcpy(buffer+i2,"\tEnableWindow(GetWindow(hWnd,GW_OWNER),1)\r\n");
1421 i2+=lstrlen(buffer+i2);
1422 lstrcpy(buffer+i2,"\tDestroyWindow(hWnd)\r\n");
1423 i2+=lstrlen(buffer+i2);
1424 lstrcpy(buffer+i2,"\tPostMessage(0,WM_QUIT,lResult,0)\r\n");
1425 i2+=lstrlen(buffer+i2);
1426 lstrcpy(buffer+i2,"End Sub\r\n");
1427 i2+=lstrlen(buffer+i2);
1428
1429 //CreateDialog関数
1430 lstrcpy(buffer+i2,"\r\nFunction CreateDialog(hOwnerWnd As HWND, TemplateName As LPSTR) As HWND\r\n");
1431 i2+=lstrlen(buffer+i2);
1432 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1433 if(pWindowInfo[i].type==WNDTYPE_MODELESSDLG){
1434 sprintf(buffer+i2,"\tIf lstrcmp(TemplateName,\"%s\")=0 Then\r\n",pWindowInfo[i].name);
1435 i2+=lstrlen(buffer+i2);
1436
1437 sprintf(buffer+i2,"\t\t%s=CreateWindowEx(&H%08x,\"NORMALDLG\",\"%s\",&H%08x,%d,%d,%d,%d,hOwnerWnd,%d As HMENU,GetModuleHandle(0),0)\r\n",
1438 pWindowInfo[i].HandleName,
1439 pWindowInfo[i].ExStyle,
1440 pWindowInfo[i].caption,
1441 pWindowInfo[i].style,
1442 pWindowInfo[i].pos.x,
1443 pWindowInfo[i].pos.y,
1444 pWindowInfo[i].size.cx,
1445 pWindowInfo[i].size.cy,
1446 pWindowInfo[i].id);
1447 i2+=lstrlen(buffer+i2);
1448 sprintf(buffer+i2,"\t\tCreateDialog=%s\r\n",pWindowInfo[i].HandleName);
1449 i2+=lstrlen(buffer+i2);
1450 if(bAvailUserProc[i]){
1451 sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(%s) As LONG_PTR)\r\n",
1452 pWindowInfo[i].HandleName,
1453 pWindowInfo[i].CallBackName);
1454 }
1455 else{
1456 sprintf(buffer+i2,"\t\tSetWindowLongPtr(%s,GWLP_WNDPROC,AddressOf(EventCall_%s) As LONG_PTR)\r\n",
1457 pWindowInfo[i].HandleName,
1458 pWindowInfo[i].name);
1459 }
1460 i2+=lstrlen(buffer+i2);
1461 sprintf(buffer+i2,"\t\tSendMessage(%s,WM_INITDIALOG,0,0)\r\n",pWindowInfo[i].HandleName);
1462 i2+=lstrlen(buffer+i2);
1463 if(pWindowInfo[i].IconResName){
1464 sprintf(buffer+i2,"\t\tSendMessage(%s,WM_SETICON,ICON_SMALL,LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(%s)) As LPARAM)\r\n",pWindowInfo[i].HandleName,pWindowInfo[i].IconResName);
1465 i2+=lstrlen(buffer+i2);
1466 }
1467 sprintf(buffer+i2,"\tEnd If\r\n",pWindowInfo[i].name);
1468 i2+=lstrlen(buffer+i2);
1469 }
1470 while(i2>65535*(size-1)){
1471 size++;
1472 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1473 }
1474 }
1475 lstrcpy(buffer+i2,"End Function\r\n");
1476 i2+=lstrlen(buffer+i2);
1477
1478
1479 ///////////////////////
1480 // 保存(Callback.wbp)
1481 sprintf(temporary,"%sCallback.wbp",ProjectInfo.dir);
1482 WriteBuffer(temporary,buffer,i2);
1483
1484
1485
1486 lstrcpy(buffer,"'このファイルはウィンドウ定義ファイル(*.wnd)をもとに生成されています\r\n\r\n");
1487 i2=lstrlen(buffer);
1488
1489 lstrcpy(buffer+i2,"Dim _RadSys_wcl As WNDCLASSEX\r\n");
1490 i2+=lstrlen(buffer+i2);
1491 lstrcpy(buffer+i2,"FillMemory(VarPtr(_RadSys_wcl),Len(_RadSys_wcl),0)\r\n");
1492 i2+=lstrlen(buffer+i2);
1493 lstrcpy(buffer+i2,"_RadSys_wcl.cbSize=Len(_RadSys_wcl)\r\n");
1494 i2+=lstrlen(buffer+i2);
1495 lstrcpy(buffer+i2,"_RadSys_wcl.hInstance=GetModuleHandle(0)\r\n");
1496 i2+=lstrlen(buffer+i2);
1497 lstrcpy(buffer+i2,"_RadSys_wcl.style=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS\r\n");
1498 i2+=lstrlen(buffer+i2);
1499 lstrcpy(buffer+i2,"_RadSys_wcl.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW))\r\n");
1500 i2+=lstrlen(buffer+i2);
1501
1502 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
1503 if(pWindowInfo[i].type==WNDTYPE_DEFAULT){
1504 //////////////////////
1505 //通常ウィンドウ作成
1506
1507 lstrcpy(buffer+i2,"\r\n");
1508 i2+=2;
1509
1510 if(pWindowInfo[i].IconResName==0){
1511 lstrcpy(buffer+i2,"_RadSys_wcl.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION))\r\n");
1512 i2+=lstrlen(buffer+i2);
1513 lstrcpy(buffer+i2,"_RadSys_wcl.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDI_WINLOGO))\r\n");
1514 i2+=lstrlen(buffer+i2);
1515 }
1516 else{
1517 sprintf(buffer+i2,"_RadSys_wcl.hIcon=LoadIcon(_RadSys_wcl.hInstance,MAKEINTRESOURCE(%s))\r\n",pWindowInfo[i].IconResName);
1518 i2+=lstrlen(buffer+i2);
1519 sprintf(buffer+i2,"_RadSys_wcl.hIconSm=LoadIcon(_RadSys_wcl.hInstance,MAKEINTRESOURCE(%s))\r\n",pWindowInfo[i].IconResName);
1520 i2+=lstrlen(buffer+i2);
1521 }
1522
1523 sprintf(buffer+i2,"_RadSys_wcl.lpszClassName=\"NORMAL%d\"\r\n",i);
1524 i2+=lstrlen(buffer+i2);
1525 if(bAvailUserProc[i])
1526 sprintf(buffer+i2,"_RadSys_wcl.lpfnWndProc=AddressOf(%s)\r\n",pWindowInfo[i].CallBackName);
1527 else sprintf(buffer+i2,"_RadSys_wcl.lpfnWndProc=AddressOf(EventCall_%s)\r\n",pWindowInfo[i].name);
1528 i2+=lstrlen(buffer+i2);
1529 if(pWindowInfo[i].bgColor==COLOR_3DFACE)
1530 lstrcpy(buffer+i2,"_RadSys_wcl.hbrBackground=h3DFaceBrush\r\n");
1531 else if(pWindowInfo[i].bgColor==-(int)RGB(255,255,255))
1532 lstrcpy(buffer+i2,"_RadSys_wcl.hbrBackground=GetStockObject(WHITE_BRUSH)\r\n");
1533 else if(pWindowInfo[i].bgColor==-(int)RGB(0,0,0))
1534 lstrcpy(buffer+i2,"_RadSys_wcl.hbrBackground=GetStockObject(BLACK_BRUSH)\r\n");
1535 else if(pWindowInfo[i].bgColor<=0||
1536 pWindowInfo[i].bgColor>=0x1000){
1537 //色指定またはビットマップ
1538 sprintf(buffer+i2,"_RadSys_wcl.hbrBackground=_RadSys_hBackBrush%d\r\n",i);
1539 }
1540 i2+=lstrlen(buffer+i2);
1541 lstrcpy(buffer+i2,"RegisterClassEx(_RadSys_wcl)\r\n");
1542 i2+=lstrlen(buffer+i2);
1543 sprintf(buffer+i2,"CreateWindowEx(&H%08x,\"%s%d\",\"%s\",&H%08x,%d,%d,%d,%d,0,0,GetModuleHandle(0),0)\r\n",
1544 pWindowInfo[i].ExStyle,
1545 pWindowInfo[i].ClassName,i,
1546 pWindowInfo[i].caption,
1547 pWindowInfo[i].style,
1548 pWindowInfo[i].pos.x,
1549 pWindowInfo[i].pos.y,
1550 pWindowInfo[i].size.cx,
1551 pWindowInfo[i].size.cy);
1552 i2+=lstrlen(buffer+i2);
1553 }
1554
1555 while(i2>65535*(size-1)){
1556 size++;
1557 buffer=(char *)HeapReAlloc(hHeap,0,buffer,65535*size);
1558 }
1559 }
1560
1561
1562 /////////////////////////
1563 // 保存(MakeWindow.wbp)
1564 sprintf(temporary,"%sMakeWindow.wbp",ProjectInfo.dir);
1565 WriteBuffer(temporary,buffer,i2);
1566 HeapDefaultFree(buffer);
1567}
1568int GetSaveMenuData(char *buffer,int SpaceNum,MENU_INFO *pMenuInfo,int ItemNum){
1569 int i,i2;
1570 char spaces[MAX_PATH];
1571
1572 memset(spaces,' ',SpaceNum*4);
1573 spaces[SpaceNum*4]=0;
1574
1575 for(i=0,i2=0;i<ItemNum;i++){
1576 if(pMenuInfo[i].pMenuInfo){
1577 sprintf(buffer+i2,"%sPOPUP = \"%s\",%d\r\n",spaces,pMenuInfo[i].caption,pMenuInfo[i].state);
1578 i2+=lstrlen(buffer+i2);
1579 i2+=GetSaveMenuData(buffer+i2,SpaceNum+1,pMenuInfo[i].pMenuInfo,pMenuInfo[i].NumberOfMenu);
1580 sprintf(buffer+i2,"%sEND\r\n",spaces);
1581 i2+=lstrlen(buffer+i2);
1582 }
1583 else if(pMenuInfo[i].type==MFT_STRING){
1584 sprintf(buffer+i2,"%sITEM = %s,\"%s\",%d\r\n",spaces,pMenuInfo[i].IdName,pMenuInfo[i].caption,pMenuInfo[i].state);
1585 i2+=lstrlen(buffer+i2);
1586 }
1587 else if(pMenuInfo[i].type==MFT_SEPARATOR){
1588 sprintf(buffer+i2,"%sSEPARATOR\r\n",spaces);
1589 i2+=lstrlen(buffer+i2);
1590 }
1591 }
1592 return i2;
1593}
1594void SaveWindowFile(char *path,WINDOW_INFO *pWindowInfo,int NumberOfWindowInfo){
1595 extern HANDLE hHeap;
1596 extern MDIINFO MdiInfo[MAX_WNDNUM];
1597 extern PROJECTINFO ProjectInfo;
1598 int i,i2,i3,size;
1599 char *buffer,*temporary;
1600
1601 size=2;
1602 buffer=(char *)HeapAlloc(hHeap,0,GENERAL_SIZE*size);
1603 for(i=0,i2=0;i<NumberOfWindowInfo;i++){
1604 sprintf(buffer+i2,"WINDOW:%s\r\n",pWindowInfo[i].name);
1605 i2+=lstrlen(buffer+i2);
1606 sprintf(buffer+i2," HANDLE = %s\r\n",pWindowInfo[i].HandleName);
1607 i2+=lstrlen(buffer+i2);
1608 sprintf(buffer+i2," POINT = %d,%d\r\n",pWindowInfo[i].pos.x,pWindowInfo[i].pos.y);
1609 i2+=lstrlen(buffer+i2);
1610 sprintf(buffer+i2," SIZE = %d,%d\r\n",pWindowInfo[i].size.cx,pWindowInfo[i].size.cy);
1611 i2+=lstrlen(buffer+i2);
1612 sprintf(buffer+i2," CAPTION = \"%s\"\r\n",pWindowInfo[i].caption);
1613 i2+=lstrlen(buffer+i2);
1614 sprintf(buffer+i2," STYLE = &H%08x\r\n",pWindowInfo[i].style);
1615 i2+=lstrlen(buffer+i2);
1616 sprintf(buffer+i2," EXSTYLE = &H%08x\r\n",pWindowInfo[i].ExStyle);
1617 i2+=lstrlen(buffer+i2);
1618 if(pWindowInfo[i].MenuID){
1619 sprintf(buffer+i2," MENUID = %s\r\n",pWindowInfo[i].MenuID);
1620 i2+=lstrlen(buffer+i2);
1621 }
1622 sprintf(buffer+i2," ID = %d\r\n",pWindowInfo[i].id);
1623 i2+=lstrlen(buffer+i2);
1624 sprintf(buffer+i2," BGCOLOR = %d\r\n",pWindowInfo[i].bgColor);
1625 i2+=lstrlen(buffer+i2);
1626 sprintf(buffer+i2," FONT = %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\"%s\"\r\n",
1627 pWindowInfo[i].LogFont.lfHeight,
1628 pWindowInfo[i].LogFont.lfWidth,
1629 pWindowInfo[i].LogFont.lfEscapement,
1630 pWindowInfo[i].LogFont.lfOrientation,
1631 pWindowInfo[i].LogFont.lfWeight,
1632 pWindowInfo[i].LogFont.lfItalic,
1633 pWindowInfo[i].LogFont.lfUnderline,
1634 pWindowInfo[i].LogFont.lfStrikeOut,
1635 pWindowInfo[i].LogFont.lfCharSet,
1636 pWindowInfo[i].LogFont.lfOutPrecision,
1637 pWindowInfo[i].LogFont.lfClipPrecision,
1638 pWindowInfo[i].LogFont.lfQuality,
1639 pWindowInfo[i].LogFont.lfPitchAndFamily,
1640 pWindowInfo[i].LogFont.lfFaceName);
1641 i2+=lstrlen(buffer+i2);
1642 if(pWindowInfo[i].IconResName){
1643 sprintf(buffer+i2," ICONID = %s\r\n",pWindowInfo[i].IconResName);
1644 i2+=lstrlen(buffer+i2);
1645 }
1646 sprintf(buffer+i2," CLASS = \"%s\"\r\n",pWindowInfo[i].ClassName);
1647 i2+=lstrlen(buffer+i2);
1648 sprintf(buffer+i2," CALLBACK = %s\r\n",pWindowInfo[i].CallBackName);
1649 i2+=lstrlen(buffer+i2);
1650 sprintf(buffer+i2," TYPE = %d\r\n",pWindowInfo[i].type);
1651 i2+=lstrlen(buffer+i2);
1652 sprintf(buffer+i2," FILEPATH = %s\r\n",pWindowInfo[i].filepath);
1653 i2+=lstrlen(buffer+i2);
1654 for(i3=0;i3<pWindowInfo[i].NumberOfChildWindows;i3++){
1655 temporary=SetCaptionSequence(pWindowInfo[i].pChildInfo[i3].caption);
1656 sprintf(buffer+i2," ITEM = %s,%d,%d,%d,%d,\"%s\",&H%08x,&H%08x,%d",
1657 pWindowInfo[i].pChildInfo[i3].IdName,
1658 pWindowInfo[i].pChildInfo[i3].pos.x,pWindowInfo[i].pChildInfo[i3].pos.y,
1659 pWindowInfo[i].pChildInfo[i3].size.cx,pWindowInfo[i].pChildInfo[i3].size.cy,
1660 temporary,
1661 pWindowInfo[i].pChildInfo[i3].style,
1662 pWindowInfo[i].pChildInfo[i3].ExStyle,
1663 pWindowInfo[i].pChildInfo[i3].Control
1664 );
1665 i2+=lstrlen(buffer+i2);
1666 HeapDefaultFree(temporary);
1667 if(pWindowInfo[i].pChildInfo[i3].Control==CT_IMAGEBOX){
1668 sprintf(buffer+i2,",%d,\"%s\"",pWindowInfo[i].pChildInfo[i3].ImageCtrlInfo.type,pWindowInfo[i].pChildInfo[i3].ImageCtrlInfo.path);
1669 i2+=lstrlen(buffer+i2);
1670 }
1671 lstrcpy(buffer+i2,"\r\n");
1672 i2+=lstrlen(buffer+i2);
1673 if(i2-GENERAL_SIZE<GENERAL_SIZE){
1674 size++;
1675 buffer=(char *)HeapReAlloc(hHeap,0,buffer,GENERAL_SIZE*size);
1676 }
1677 }
1678 sprintf(buffer+i2,"END\r\n",pWindowInfo[i].name);
1679 i2+=lstrlen(buffer+i2);
1680 if(i2-GENERAL_SIZE<GENERAL_SIZE){
1681 size++;
1682 buffer=(char *)HeapReAlloc(hHeap,0,buffer,GENERAL_SIZE*size);
1683 }
1684 }
1685 for(i=0;i<ProjectInfo.NumberOfMenu;i++){
1686 sprintf(buffer+i2,"MENU:%s\r\n",ProjectInfo.pMenuInfo[i].IdName);
1687 i2+=lstrlen(buffer+i2);
1688 i2+=GetSaveMenuData(buffer+i2,1,ProjectInfo.pMenuInfo[i].pMenuInfo,ProjectInfo.pMenuInfo[i].NumberOfMenu);
1689 sprintf(buffer+i2,"END\r\n",pWindowInfo[i].name);
1690 i2+=lstrlen(buffer+i2);
1691 if(i2-GENERAL_SIZE<GENERAL_SIZE){
1692 size++;
1693 buffer=(char *)HeapReAlloc(hHeap,0,buffer,GENERAL_SIZE*size);
1694 }
1695 }
1696 WriteBuffer(path,buffer,i2);
1697 HeapDefaultFree(buffer);
1698
1699 extern PROJECTINFO ProjectInfo;
1700 ProjectInfo.ModifyOfMaterial=0;
1701}
1702
1703MENU_INFO *GetMenuData(char *buffer,int *pPos,int *pMenuNum){
1704 extern HANDLE hHeap;
1705 int i,i2,i3,i4;
1706 char temporary[MAX_PATH],*temp2,temp3[MAX_PATH];
1707 MENU_INFO *pMenuInfo;
1708
1709 temp2=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)+1);
1710
1711 *pMenuNum=0;
1712 pMenuInfo=(MENU_INFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
1713
1714 for(i=*pPos;;i++){
1715 if(buffer[i]=='\0') return 0;
1716 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||i==0){
1717 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i+=2;
1718 for(i2=0;;i++,i2++){
1719 if(!IsVariableChar(buffer[i])){
1720 temporary[i2]=0;
1721 break;
1722 }
1723 temporary[i2]=buffer[i];
1724 }
1725 if(i2==0){
1726 i--;
1727 continue;
1728 }
1729 if(buffer[i]=='='){
1730 for(i++,i2=0;;i++,i2++){
1731 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
1732 temp2[i2]=0;
1733 break;
1734 }
1735 temp2[i2]=buffer[i];
1736 }
1737 }
1738 else{
1739 temp2[0]=0;
1740 i2=0;
1741 }
1742
1743
1744 if(lstrcmpi(temporary,"POPUP")==0){
1745 (*pMenuNum)++;
1746 pMenuInfo=(MENU_INFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pMenuInfo,(*pMenuNum)*sizeof(MENU_INFO));
1747 i3=*pMenuNum-1;
1748
1749 i4=GetOneParameter(temp2,0,temp3);
1750 RemoveStringQuotes(temp3);
1751 pMenuInfo[i3].caption=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1);
1752 lstrcpy(pMenuInfo[i3].caption,temp3);
1753
1754 i4=GetOneParameter(temp2,i4,temp3);
1755 pMenuInfo[i3].state=GetValue(temp3);
1756
1757 pMenuInfo[i3].pMenuInfo=GetMenuData(buffer,&i,&pMenuInfo[i3].NumberOfMenu);
1758 }
1759 else if(lstrcmpi(temporary,"ITEM")==0){
1760 (*pMenuNum)++;
1761 pMenuInfo=(MENU_INFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pMenuInfo,(*pMenuNum)*sizeof(MENU_INFO));
1762 i3=*pMenuNum-1;
1763
1764 i4=GetOneParameter(temp2,0,temp3);
1765 pMenuInfo[i3].IdName=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1);
1766 lstrcpy(pMenuInfo[i3].IdName,temp3);
1767
1768 i4=GetOneParameter(temp2,i4,temp3);
1769 RemoveStringQuotes(temp3);
1770 pMenuInfo[i3].caption=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1);
1771 lstrcpy(pMenuInfo[i3].caption,temp3);
1772
1773 i4=GetOneParameter(temp2,i4,temp3);
1774 pMenuInfo[i3].state=GetValue(temp3);
1775
1776 pMenuInfo[i3].type=0;
1777 }
1778 else if(lstrcmpi(temporary,"SEPARATOR")==0){
1779 (*pMenuNum)++;
1780 pMenuInfo=(MENU_INFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,pMenuInfo,(*pMenuNum)*sizeof(MENU_INFO));
1781 i3=*pMenuNum-1;
1782
1783 pMenuInfo[i3].type=MFT_SEPARATOR;
1784 }
1785 else if(lstrcmpi(temporary,"END")==0) break;
1786 i--;
1787 }
1788 }
1789 *pPos=i;
1790
1791 HeapDefaultFree(temp2);
1792
1793 return pMenuInfo;
1794}
1795_int8 OpenWindowFile(char *path){
1796 extern HANDLE hHeap;
1797 extern PROJECTINFO ProjectInfo;
1798 int i,i2,i3,i4,i5;
1799 char *buffer,temporary[MAX_PATH],*temp2,temp3[MAX_PATH];
1800 CHILDINFO *pChildInfo;
1801
1802 buffer=ReadBuffer(path);
1803 if(!buffer) return 0;
1804 temp2=(char *)HeapAlloc(hHeap,0,lstrlen(buffer)+1);
1805 ChangeOrSignToDivision(temp2,buffer);
1806 KillSpaces(temp2,buffer);
1807 //temp2はこの後の処理の一時保存バッファにも利用するので解放しない
1808
1809 ProjectInfo.NumberOfMenu=0;
1810 ProjectInfo.pMenuInfo=(MENU_INFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
1811
1812 ProjectInfo.NumberOfWindows=0;
1813 ProjectInfo.pWindowInfo=(WINDOW_INFO *)HeapAlloc(hHeap,0,1);
1814
1815 for(i=0,i3=0;;i++){
1816 if(buffer[i]=='\0') break;
1817 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||i==0){
1818 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i+=2;
1819 for(i2=0;;i++,i2++){
1820 if(!IsVariableChar(buffer[i])){
1821 temporary[i2]=0;
1822 break;
1823 }
1824 temporary[i2]=buffer[i];
1825 }
1826 if(i2==0){
1827 i--;
1828 continue;
1829 }
1830 if(buffer[i]==':'||buffer[i]=='='){
1831 for(i++,i2=0;;i++,i2++){
1832 if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
1833 temp2[i2]=0;
1834 break;
1835 }
1836 temp2[i2]=buffer[i];
1837 }
1838 }
1839 else{
1840 temp2[0]=0;
1841 i2=0;
1842 }
1843
1844
1845 //////////////
1846 //ウィンドウ
1847 if(lstrcmpi(temporary,"WINDOW")==0&&i3==0){
1848 ProjectInfo.NumberOfWindows++;
1849 ProjectInfo.pWindowInfo=(WINDOW_INFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,ProjectInfo.pWindowInfo,ProjectInfo.NumberOfWindows*sizeof(WINDOW_INFO));
1850 i4=ProjectInfo.NumberOfWindows-1;
1851 i3=1;
1852
1853 ProjectInfo.pWindowInfo[i4].name=(char *)HeapAlloc(hHeap,0,i2+1);
1854 lstrcpy(ProjectInfo.pWindowInfo[i4].name,temp2);
1855
1856 ProjectInfo.pWindowInfo[i4].NumberOfChildWindows=0;
1857 ProjectInfo.pWindowInfo[i4].pChildInfo=(CHILDINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
1858 }
1859 else if(lstrcmpi(temporary,"HANDLE")==0&&i3==1){
1860 ProjectInfo.pWindowInfo[i4].HandleName=(char *)HeapAlloc(hHeap,0,i2+1);
1861 lstrcpy(ProjectInfo.pWindowInfo[i4].HandleName,temp2);
1862 }
1863 else if(lstrcmpi(temporary,"POINT")==0&&i3==1){
1864 sscanf(temp2,"%d,%d",
1865 &ProjectInfo.pWindowInfo[i4].pos.x,
1866 &ProjectInfo.pWindowInfo[i4].pos.y);
1867 if(ProjectInfo.pWindowInfo[i4].pos.x==-1) ProjectInfo.pWindowInfo[i4].pos.x=CW_USEDEFAULT;
1868 if(ProjectInfo.pWindowInfo[i4].pos.y==-1) ProjectInfo.pWindowInfo[i4].pos.y=CW_USEDEFAULT;
1869 }
1870 else if(lstrcmpi(temporary,"SIZE")==0&&i3==1){
1871 sscanf(temp2,"%d,%d",
1872 &ProjectInfo.pWindowInfo[i4].size.cx,
1873 &ProjectInfo.pWindowInfo[i4].size.cy);
1874 }
1875 else if(lstrcmpi(temporary,"CAPTION")==0&&i3==1){
1876 if(temp2[0]=='\"'&&temp2[lstrlen(temp2)-1]=='\"'){
1877 temp2[lstrlen(temp2)-1]=0;
1878 ProjectInfo.pWindowInfo[i4].caption=(char *)HeapAlloc(hHeap,0,i2+1);
1879 lstrcpy(ProjectInfo.pWindowInfo[i4].caption,temp2+1);
1880 }
1881 }
1882 else if(lstrcmpi(temporary,"STYLE")==0&&i3==1) ProjectInfo.pWindowInfo[i4].style=GetValue(temp2);
1883 else if(lstrcmpi(temporary,"EXSTYLE")==0&&i3==1) ProjectInfo.pWindowInfo[i4].ExStyle=GetValue(temp2);
1884 else if(lstrcmpi(temporary,"MENUID")==0&&i3==1){
1885 ProjectInfo.pWindowInfo[i4].MenuID=(char *)HeapAlloc(hHeap,0,i2+1);
1886 lstrcpy(ProjectInfo.pWindowInfo[i4].MenuID,temp2);
1887 }
1888 else if(lstrcmpi(temporary,"ID")==0&&i3==1) ProjectInfo.pWindowInfo[i4].id=GetValue(temp2);
1889 else if(lstrcmpi(temporary,"BGCOLOR")==0&&i3==1){
1890 ProjectInfo.pWindowInfo[i4].bgColor=GetValue(temp2);
1891 if(ProjectInfo.dwVersion<=3){
1892 //プロジェクトバージョンが3以前のときは新値に変換する
1893 if(ProjectInfo.pWindowInfo[i4].bgColor==-1)
1894 ProjectInfo.pWindowInfo[i4].bgColor=-(int)RGB(255,255,255);
1895 }
1896 }
1897 else if(lstrcmpi(temporary,"FONT")==0&&i3==1){
1898 i5=GetOneParameter(temp2,0,temp3);
1899 ProjectInfo.pWindowInfo[i4].LogFont.lfHeight=GetValue(temp3);
1900
1901 i5=GetOneParameter(temp2,i5,temp3);
1902 ProjectInfo.pWindowInfo[i4].LogFont.lfWidth=GetValue(temp3);
1903
1904 i5=GetOneParameter(temp2,i5,temp3);
1905 ProjectInfo.pWindowInfo[i4].LogFont.lfEscapement=GetValue(temp3);
1906
1907 i5=GetOneParameter(temp2,i5,temp3);
1908 ProjectInfo.pWindowInfo[i4].LogFont.lfOrientation=GetValue(temp3);
1909
1910 i5=GetOneParameter(temp2,i5,temp3);
1911 ProjectInfo.pWindowInfo[i4].LogFont.lfWeight=GetValue(temp3);
1912
1913 i5=GetOneParameter(temp2,i5,temp3);
1914 ProjectInfo.pWindowInfo[i4].LogFont.lfItalic=(BYTE)GetValue(temp3);
1915
1916 i5=GetOneParameter(temp2,i5,temp3);
1917 ProjectInfo.pWindowInfo[i4].LogFont.lfUnderline=(BYTE)GetValue(temp3);
1918
1919 i5=GetOneParameter(temp2,i5,temp3);
1920 ProjectInfo.pWindowInfo[i4].LogFont.lfStrikeOut=(BYTE)GetValue(temp3);
1921
1922 i5=GetOneParameter(temp2,i5,temp3);
1923 ProjectInfo.pWindowInfo[i4].LogFont.lfCharSet=(BYTE)GetValue(temp3);
1924
1925 i5=GetOneParameter(temp2,i5,temp3);
1926 ProjectInfo.pWindowInfo[i4].LogFont.lfOutPrecision=(BYTE)GetValue(temp3);
1927
1928 i5=GetOneParameter(temp2,i5,temp3);
1929 ProjectInfo.pWindowInfo[i4].LogFont.lfClipPrecision=(BYTE)GetValue(temp3);
1930
1931 i5=GetOneParameter(temp2,i5,temp3);
1932 ProjectInfo.pWindowInfo[i4].LogFont.lfQuality=(BYTE)GetValue(temp3);
1933
1934 i5=GetOneParameter(temp2,i5,temp3);
1935 ProjectInfo.pWindowInfo[i4].LogFont.lfPitchAndFamily=(BYTE)GetValue(temp3);
1936
1937 i5=GetOneParameter(temp2,i5,temp3);
1938 RemoveStringQuotes(temp3);
1939 lstrcpy(ProjectInfo.pWindowInfo[i4].LogFont.lfFaceName,temp3);
1940 }
1941 else if(lstrcmpi(temporary,"ICONID")==0&&i3==1){
1942 ProjectInfo.pWindowInfo[i4].IconResName=(char *)HeapAlloc(hHeap,0,i2+1);
1943 lstrcpy(ProjectInfo.pWindowInfo[i4].IconResName,temp2);
1944 }
1945 else if(lstrcmpi(temporary,"CLASS")==0&&i3==1){
1946 if(temp2[0]=='\"'&&temp2[lstrlen(temp2)-1]=='\"'){
1947 temp2[lstrlen(temp2)-1]=0;
1948 ProjectInfo.pWindowInfo[i4].ClassName=(char *)HeapAlloc(hHeap,0,i2+1);
1949 lstrcpy(ProjectInfo.pWindowInfo[i4].ClassName,temp2+1);
1950 }
1951 }
1952 else if(lstrcmpi(temporary,"CALLBACK")==0&&i3==1){
1953 ProjectInfo.pWindowInfo[i4].CallBackName=(char *)HeapAlloc(hHeap,0,i2+1);
1954 lstrcpy(ProjectInfo.pWindowInfo[i4].CallBackName,temp2);
1955 }
1956
1957 //以前のバージョンとの互換用
1958 else if(lstrcmpi(temporary,"DLGTMP")==0&&i3==1) ProjectInfo.pWindowInfo[i4].type=GetValue(temp2);
1959
1960 else if(lstrcmpi(temporary,"TYPE")==0&&i3==1) ProjectInfo.pWindowInfo[i4].type=GetValue(temp2);
1961 else if(lstrcmpi(temporary,"FILEPATH")==0&&i3==1){
1962 ProjectInfo.pWindowInfo[i4].filepath=(char *)HeapAlloc(hHeap,0,i2+1);
1963 lstrcpy(ProjectInfo.pWindowInfo[i4].filepath,temp2);
1964 }
1965 else if(lstrcmpi(temporary,"ITEM")==0&&i3==1){
1966 ProjectInfo.pWindowInfo[i4].pChildInfo=(CHILDINFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,ProjectInfo.pWindowInfo[i4].pChildInfo,(ProjectInfo.pWindowInfo[i4].NumberOfChildWindows+1)*sizeof(CHILDINFO));
1967 pChildInfo=&ProjectInfo.pWindowInfo[i4].pChildInfo[ProjectInfo.pWindowInfo[i4].NumberOfChildWindows];
1968
1969 //ID
1970 i5=GetOneParameter(temp2,0,temp3);
1971 pChildInfo->IdName=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1);
1972 lstrcpy(pChildInfo->IdName,temp3);
1973
1974 //位置
1975 i5=GetOneParameter(temp2,i5,temp3);
1976 pChildInfo->pos.x=GetValue(temp3);
1977 i5=GetOneParameter(temp2,i5,temp3);
1978 pChildInfo->pos.y=GetValue(temp3);
1979 i5=GetOneParameter(temp2,i5,temp3);
1980 pChildInfo->size.cx=GetValue(temp3);
1981 i5=GetOneParameter(temp2,i5,temp3);
1982 pChildInfo->size.cy=GetValue(temp3);
1983
1984 //テキスト
1985 i5=GetOneParameter(temp2,i5,temp3);
1986 RemoveStringQuotes(temp3);
1987 RestoreCaptionSequence(temp3);
1988 pChildInfo->caption=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1);
1989 lstrcpy(pChildInfo->caption,temp3);
1990
1991 //スタイル
1992 i5=GetOneParameter(temp2,i5,temp3);
1993 pChildInfo->style=GetValue(temp3);
1994
1995 //拡張スタイル
1996 i5=GetOneParameter(temp2,i5,temp3);
1997 pChildInfo->ExStyle=GetValue(temp3);
1998
1999 //クラス
2000 i5=GetOneParameter(temp2,i5,temp3);
2001 pChildInfo->Control=GetValue(temp3);
2002
2003 if(pChildInfo->Control==CT_IMAGEBOX){
2004 //イメージ ボックスの場合
2005 i5=GetOneParameter(temp2,i5,temp3);
2006 pChildInfo->ImageCtrlInfo.type=GetValue(temp3);
2007 i5=GetOneParameter(temp2,i5,temp3);
2008 RemoveStringQuotes(temp3);
2009 pChildInfo->ImageCtrlInfo.path=(char *)HeapAlloc(hHeap,0,lstrlen(temp3)+1);
2010 lstrcpy(pChildInfo->ImageCtrlInfo.path,temp3);
2011 }
2012
2013 ProjectInfo.pWindowInfo[i4].NumberOfChildWindows++;
2014 }
2015
2016
2017 ////////////
2018 //メニュー
2019 else if(lstrcmpi(temporary,"MENU")==0&&i3==0){
2020 ProjectInfo.NumberOfMenu++;
2021 ProjectInfo.pMenuInfo=(MENU_INFO *)HeapReAlloc(hHeap,HEAP_ZERO_MEMORY,ProjectInfo.pMenuInfo,ProjectInfo.NumberOfMenu*sizeof(MENU_INFO));
2022 i4=ProjectInfo.NumberOfMenu-1;
2023
2024 //ID名
2025 ProjectInfo.pMenuInfo[i4].IdName=(char *)HeapAlloc(hHeap,0,lstrlen(temp2)+1);
2026 lstrcpy(ProjectInfo.pMenuInfo[i4].IdName,temp2);
2027 ProjectInfo.pMenuInfo[i4].pMenuInfo=GetMenuData(buffer,&i,&ProjectInfo.pMenuInfo[i4].NumberOfMenu);
2028 if(!ProjectInfo.pMenuInfo[i4].pMenuInfo){
2029 //"ウィンドウ定義ファイルが壊れています。\n\n%s"
2030 sprintf(temporary,STRING_ERROR_BROKEN_WNDFILE,path);
2031 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
2032
2033 HeapDefaultFree(temp2);
2034 HeapDefaultFree(buffer);
2035 return 0;
2036 }
2037 }
2038
2039
2040 else if(lstrcmpi(temporary,"END")==0&&i3) i3=0;
2041 else{
2042 //"ウィンドウ定義ファイルが壊れています。\n\n%s"
2043 sprintf(temporary,STRING_ERROR_BROKEN_WNDFILE,path);
2044 MessageBox(hOwner,temporary,APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
2045
2046 HeapDefaultFree(temp2);
2047 HeapDefaultFree(buffer);
2048 return 0;
2049 }
2050 i--;
2051 }
2052 }
2053
2054 HeapDefaultFree(temp2);
2055 HeapDefaultFree(buffer);
2056 return 1;
2057}
2058
2059struct NEW_WINDOW{
2060 char name[MAX_PATH];
2061 char HandleName[MAX_PATH];
2062 char CallBackName[MAX_PATH];
2063 BOOL type;
2064};
2065NEW_WINDOW NewWindow;
2066BOOL CALLBACK DlgProject_NewWindow(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
2067 char temporary[MAX_PATH],temp2[MAX_PATH];
2068 switch(message){
2069 case WM_INITDIALOG:
2070 SetPosCenter(hwnd);
2071 SendDlgItemMessage(hwnd,IDC_AUTOSET,BM_SETCHECK,BST_CHECKED,0);
2072 SendMessage(hwnd,WM_COMMAND,IDC_AUTOSET,0);
2073 SendDlgItemMessage(hwnd,IDC_MODALDLG,BM_SETCHECK,BST_CHECKED,0);
2074 break;
2075 case WM_COMMAND:
2076 switch(LOWORD(wParam)){
2077 case IDOK:
2078 GetDlgItemText(hwnd,IDC_WINDOWNAME,NewWindow.name,MAX_PATH);
2079 GetDlgItemText(hwnd,IDC_WINDOWHANDLE,NewWindow.HandleName,MAX_PATH);
2080 GetDlgItemText(hwnd,IDC_WINDOWPROC,NewWindow.CallBackName,MAX_PATH);
2081 if(SendDlgItemMessage(hwnd,IDC_DEFWINDOW,BM_GETCHECK,0,0))
2082 NewWindow.type=WNDTYPE_DEFAULT;
2083 else if(SendDlgItemMessage(hwnd,IDC_MODALDLG,BM_GETCHECK,0,0))
2084 NewWindow.type=WNDTYPE_MODALDLG;
2085 else if(SendDlgItemMessage(hwnd,IDC_MODELESSDLG,BM_GETCHECK,0,0))
2086 NewWindow.type=WNDTYPE_MODELESSDLG;
2087 EndDialog(hwnd,1);
2088 return 1;
2089 case IDCANCEL:
2090 EndDialog(hwnd,0);
2091 return 1;
2092 case IDC_WINDOWNAME:
2093 if(HIWORD(wParam)==EN_CHANGE) SendMessage(hwnd,WM_COMMAND,IDC_AUTOSET,0);
2094 return 1;
2095 case IDC_AUTOSET:
2096 if(SendDlgItemMessage(hwnd,IDC_AUTOSET,BM_GETCHECK,0,0)){
2097 SendDlgItemMessage(hwnd,IDC_WINDOWHANDLE,EM_SETREADONLY,1,0);
2098 SendDlgItemMessage(hwnd,IDC_WINDOWPROC,EM_SETREADONLY,1,0);
2099 GetDlgItemText(hwnd,IDC_WINDOWNAME,temporary,MAX_PATH);
2100 if(temporary[0]){
2101 sprintf(temp2,"h%s",temporary);
2102 SetDlgItemText(hwnd,IDC_WINDOWHANDLE,temp2);
2103 sprintf(temp2,"%sProc",temporary);
2104 SetDlgItemText(hwnd,IDC_WINDOWPROC,temp2);
2105 }
2106 else{
2107 SetDlgItemText(hwnd,IDC_WINDOWHANDLE,"");
2108 SetDlgItemText(hwnd,IDC_WINDOWPROC,"");
2109 }
2110 }
2111 else{
2112 SendDlgItemMessage(hwnd,IDC_WINDOWHANDLE,EM_SETREADONLY,0,0);
2113 SendDlgItemMessage(hwnd,IDC_WINDOWPROC,EM_SETREADONLY,0,0);
2114 }
2115 return 1;
2116 }
2117 break;
2118 }
2119 return 0;
2120}
2121void GetDefaultWindowFont(LOGFONT *LogFont){
2122 LogFont->lfHeight=-12;
2123 LogFont->lfWidth=0;
2124 LogFont->lfEscapement=0;
2125 LogFont->lfOrientation=0;
2126 LogFont->lfWeight=FW_REGULAR;
2127 LogFont->lfItalic=0;
2128 LogFont->lfUnderline=0;
2129 LogFont->lfStrikeOut=0;
2130 LogFont->lfCharSet=SHIFTJIS_CHARSET;
2131 LogFont->lfOutPrecision=OUT_STROKE_PRECIS;
2132 LogFont->lfClipPrecision=CLIP_STROKE_PRECIS;
2133 LogFont->lfQuality=DRAFT_QUALITY;
2134 LogFont->lfPitchAndFamily=FF_SWISS;
2135 lstrcpy(LogFont->lfFaceName,"MS Pゴシック");
2136}
2137void Project_Window_Insert(void){
2138 extern HANDLE hHeap;
2139 extern PROJECTINFO ProjectInfo;
2140 int i;
2141 char temporary[MAX_PATH],temp2[1024],*pTemp;
2142
2143 if(!DialogBox(hResInst,MAKEINTRESOURCE(IDD_PROJECT_NEWWINDOW),hOwner,DlgProject_NewWindow)) return;
2144
2145 //重複チェック
2146 sprintf(temporary,"%s.sbp",NewWindow.name);
2147 if(ProjectInfo.pobj_DBFileInfo->dupli_check(temporary)){
2148 sprintf(temp2,"\"%s\" ファイルは既にプロジェクト内に存在します。",temporary);
2149 MessageBox(hOwner,temp2,APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
2150 return;
2151 }
2152 for(i=0;i<ProjectInfo.NumberOfWindows;i++){
2153 if(lstrcmpi(NewWindow.name,ProjectInfo.pWindowInfo[i].name)==0){
2154 //"\"%s\" ウィンドウは既にプロジェクト内に存在します。"
2155 sprintf(temporary,STRING_DUPLICATIONERROR_WINDOW_IN_PROJECT,ProjectInfo.pWindowInfo[i].name);
2156 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
2157 return;
2158 }
2159 if(lstrcmpi(NewWindow.HandleName,ProjectInfo.pWindowInfo[i].HandleName)==0){
2160 //"\"%s\" ハンドルは既にプロジェクト内に存在します。"
2161 sprintf(temporary,STRING_DUPLICATIONERROR_HANDLE_IN_PROJECT,ProjectInfo.pWindowInfo[i].HandleName);
2162 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
2163 return;
2164 }
2165 if(lstrcmpi(NewWindow.CallBackName,ProjectInfo.pWindowInfo[i].CallBackName)==0){
2166 //"\"%s\" プロシージャは既にプロジェクト内に存在します。"
2167 sprintf(temporary,STRING_DUPLICATIONERROR_PROC_IN_PROJECT,ProjectInfo.pWindowInfo[i].CallBackName);
2168 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
2169 return;
2170 }
2171 }
2172
2173 //ProjectInfo.pWindowInfo構造体に追加
2174 ProjectInfo.pWindowInfo=(WINDOW_INFO *)HeapReAlloc(hHeap,0,ProjectInfo.pWindowInfo,(ProjectInfo.NumberOfWindows+1)*sizeof(WINDOW_INFO));
2175
2176
2177 ///////////////////////////////////////
2178 //ProjectInfo.pWindowInfo構造体を設定
2179
2180 //ウィンドウ名
2181 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].name=(char *)HeapAlloc(hHeap,0,lstrlen(NewWindow.name)+1);
2182 lstrcpy(ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].name,NewWindow.name);
2183
2184 //ハンドル名
2185 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].HandleName=(char *)HeapAlloc(hHeap,0,lstrlen(NewWindow.HandleName)+1);
2186 lstrcpy(ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].HandleName,NewWindow.HandleName);
2187
2188 //位置情報
2189 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].pos.x=-1;
2190 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].pos.y=-1;
2191 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].size.cx=480;
2192 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].size.cy=360;
2193
2194 //ウィンドウテキスト
2195 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].caption=(char *)HeapAlloc(hHeap,0,lstrlen(NewWindow.name)+1);
2196 lstrcpy(ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].caption,NewWindow.name);
2197
2198 //スタイル
2199 switch(NewWindow.type){
2200 case WNDTYPE_DEFAULT:
2201 //通常ウィンドウ
2202 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].style=WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX;
2203 break;
2204 case WNDTYPE_MODALDLG:
2205 case WNDTYPE_MODELESSDLG:
2206 //ダイアログ テンプレート(最大化、最小化ボタンをなくして、細枠にする)
2207 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].style=WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU;
2208 break;
2209 }
2210
2211 //拡張スタイル
2212 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].ExStyle=0;
2213
2214 //メニュー
2215 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].MenuID=0;
2216
2217 //ID
2218 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].id=0;
2219
2220 //背景色
2221 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].bgColor=COLOR_3DFACE;
2222
2223 //フォント
2224 GetDefaultWindowFont(&ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].LogFont);
2225
2226 //アイコン
2227 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].IconResName=0;
2228
2229 //クラス名
2230 lstrcpy(temporary,"NORMAL");
2231 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].ClassName=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
2232 lstrcpy(ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].ClassName,temporary);
2233
2234 //コールバック関数名
2235 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].CallBackName=(char *)HeapAlloc(hHeap,0,lstrlen(NewWindow.CallBackName)+1);
2236 lstrcpy(ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].CallBackName,NewWindow.CallBackName);
2237
2238 //タイプ識別
2239 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].type=NewWindow.type;
2240
2241 //子ウィンドウ情報
2242 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].NumberOfChildWindows=0;
2243 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].pChildInfo=(CHILDINFO *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
2244
2245
2246 //メッセージ処理ファイル名
2247 sprintf(temporary,"%s.ab",ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].name);
2248 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].filepath=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
2249 lstrcpy(ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].filepath,temporary);
2250
2251
2252 //////////////////////////
2253 // メッセージ処理ファイル
2254 //////////////////////////
2255
2256 //テンプレートを読み込む
2257#if defined(JPN)
2258 //日本語ファイル
2259 sprintf(temporary,"%sSubOperation\\new_window_template.sbp",pj_editor_Dir);
2260#else
2261 //英語ファイル
2262 sprintf(temporary,"%sSubOperation\\new_window_template_e.sbp",pj_editor_Dir);
2263#endif
2264 pTemp=ReadBuffer(temporary);
2265
2266 //#name#をプロジェクト名に置換
2267 pTemp=PermutationWndPgmTemplate(pTemp,
2268 ProjectInfo.name,
2269 NewWindow.name,
2270 NewWindow.HandleName,
2271 NewWindow.CallBackName);
2272
2273 sprintf(temporary,"%s%s.ab",ProjectInfo.dir,ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].name);
2274
2275 //書き込み
2276 WriteBuffer(temporary,pTemp,lstrlen(pTemp));
2277 Project_File_Insert(temporary);
2278
2279 HeapDefaultFree(pTemp);
2280
2281
2282 //////////////////////
2283 //ツリービューに追加
2284
2285 extern HWND hMaterialTreeView;
2286 TV_INSERTSTRUCT tv;
2287 tv.hInsertAfter=TVI_SORT;
2288 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
2289 tv.item.iImage=2;
2290 tv.item.iSelectedImage=2;
2291 tv.hParent=ProjectInfo.hWindowTreeItem;
2292 tv.item.pszText=ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].name;
2293
2294 ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].hTreeItem=TreeView_InsertItem(hMaterialTreeView,&tv);
2295
2296 TreeView_SelectItem(hMaterialTreeView,ProjectInfo.pWindowInfo[ProjectInfo.NumberOfWindows].hTreeItem);
2297
2298
2299 ProjectInfo.NumberOfWindows++;
2300 ProjectInfo.ModifyOfMaterial=1;
2301
2302 NewRadWindow(ProjectInfo.NumberOfWindows-1);
2303}
2304void Project_Window_Delete(int WndInfoNum){
2305 extern HANDLE hHeap;
2306 extern MDIINFO MdiInfo[MAX_WNDNUM];
2307 extern PROJECTINFO ProjectInfo;
2308 int i;
2309
2310 //ウィンドウが開かれている場合は閉じる
2311 for(i=0;i<MAX_WNDNUM;i++){
2312 if(MdiInfo[i].hwnd&&lstrcmpi(ProjectInfo.pWindowInfo[WndInfoNum].name,MdiInfo[i].path)==0){
2313 SendMessage(MdiInfo[i].hwnd,WM_CLOSE,0,0);
2314 break;
2315 }
2316 }
2317
2318 //ウィンドウ情報のメモリを解放
2319 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].name);
2320 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].filepath);
2321 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].HandleName);
2322 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].caption);
2323 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].ClassName);
2324 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].CallBackName);
2325
2326 //子ウィンドウのメモリを解放
2327 for(i=0;i<ProjectInfo.pWindowInfo[WndInfoNum].NumberOfChildWindows;i++){
2328 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[i].IdName);
2329 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo[i].caption);
2330 }
2331 HeapDefaultFree(ProjectInfo.pWindowInfo[WndInfoNum].pChildInfo);
2332
2333 //ツリービューから削除
2334 extern HWND hMaterialTreeView;
2335 TreeView_DeleteItem(hMaterialTreeView,ProjectInfo.pWindowInfo[WndInfoNum].hTreeItem);
2336
2337 //ProjectInfo.pWindowInfo構造体から削除
2338 ProjectInfo.NumberOfWindows--;
2339 for(i=WndInfoNum;i<ProjectInfo.NumberOfWindows;i++) ProjectInfo.pWindowInfo[i]=ProjectInfo.pWindowInfo[i+1];
2340 if(ProjectInfo.NumberOfWindows==0) ProjectInfo.pWindowInfo=(WINDOW_INFO *)HeapReAlloc(hHeap,0,ProjectInfo.pWindowInfo,1);
2341 else ProjectInfo.pWindowInfo=(WINDOW_INFO *)HeapReAlloc(hHeap,0,ProjectInfo.pWindowInfo,ProjectInfo.NumberOfWindows*sizeof(WINDOW_INFO));
2342
2343 ProjectInfo.ModifyOfMaterial=1;
2344}
Note: See TracBrowser for help on using the repository browser.