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