source: dev/BasicCompiler32/VarList.cpp@ 47

Last change on this file since 47 was 36, checked in by dai_9181, 18 years ago

Boolean型に対応。

File size: 38.0 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2
3//デバッグ用
4#include "../BasicCompiler_Common/debug.h"
5
6//変数リストのツリーハンドル
7HWND hVarTree_Global,hVarTree_Local,hVarTree_This;
8
9int VarList_Array(HWND hVarTree,HTREEITEM hParent,DWORD offset,int type,int *SubScripts,LONG_PTR lpIndex);
10void VarList_Member(HWND hVarTree,HTREEITEM hParent,DWORD pTopOffset,CClass *pobj_c,BOOL bPtr);
11void VarList_Insert(HWND hVarTree,TV_INSERTSTRUCT *lptv,char *VarName,int type,DWORD offset,LONG_PTR lpIndex){
12 extern HANDLE hDebugProcess;
13 int i2;
14 char temporary[255],temp2[255];
15 DWORD dwData,dwAccessByte;
16 double dbl;
17 float flt;
18 WORD wData;
19 BYTE byteData;
20 HTREEITEM hParent;
21
22 if(type==DEF_OBJECT){
23 sprintf(lptv->item.pszText,"%s %s(&H%X)",VarName,STRING_OBJECT,offset);
24 lptv->item.iImage=1;
25 lptv->item.iSelectedImage=1;
26 hParent=TreeView_InsertItem(hVarTree,lptv);
27
28 VarList_Member(hVarTree,hParent,offset,(CClass *)lpIndex,0);
29 return;
30 }
31 if(type==DEF_PTR_OBJECT){
32 i2=ReadProcessMemory(hDebugProcess,(void *)offset,&dwData,sizeof(DWORD),&dwAccessByte);
33
34 sprintf(lptv->item.pszText,"%s %s(&H%X)",VarName,STRING_POINTEROFOBJECT,dwData);
35 lptv->item.iImage=4;
36 lptv->item.iSelectedImage=4;
37 hParent=TreeView_InsertItem(hVarTree,lptv);
38
39 if(i2) VarList_Member(hVarTree,hParent,dwData,(CClass *)lpIndex,1);
40 return;
41 }
42 else{
43 if(type==DEF_PTR_BYTE){
44 if(ReadProcessMemory(hDebugProcess,(void *)offset,&dwData,sizeof(DWORD),&dwAccessByte)){
45 for(i2=0;;i2++){
46 if(!ReadProcessMemory(hDebugProcess,(void *)(dwData+i2),&temporary[i2],1,&dwAccessByte)){
47 i2=-1;
48 break;
49 }
50 if(temporary[i2]=='\0') break;
51 if(i2==64){
52 lstrcpy(temporary+i2,"...");
53 break;
54 }
55 }
56 if(i2==-1) sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,dwData,dwData);
57 else sprintf(lptv->item.pszText,"%s %d(&H%X) \"%s\"",VarName,dwData,dwData,temporary);
58 }
59 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
60 }
61 else if(type==DEF_DOUBLE){
62 if(ReadProcessMemory(hDebugProcess,(void *)offset,&dbl,sizeof(double),&dwAccessByte)){
63 sprintf(lptv->item.pszText,"%s %.15g",VarName,dbl);
64 }
65 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
66 }
67 else if(type==DEF_SINGLE){
68 if(ReadProcessMemory(hDebugProcess,(void *)offset,&flt,sizeof(float),&dwAccessByte)){
69 sprintf(lptv->item.pszText,"%s %.6g",VarName,flt);
70 }
71 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
72 }
73 else if(type==DEF_INT64){
74 _int64 i64data;
75 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&dwAccessByte)){
76 _i64toa(i64data,temporary,10);
77 _i64toa(i64data,temp2,16);
78 CharUpper(temp2);
79 sprintf(lptv->item.pszText,"%s %s(&H%s)",VarName,temporary,temp2);
80 }
81 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
82 }
83 else if(type==DEF_QWORD){
84 _int64 i64data;
85 if(ReadProcessMemory(hDebugProcess,(void *)offset,&i64data,sizeof(_int64),&dwAccessByte)){
86 _ui64toa(i64data,temporary,10);
87 _ui64toa(i64data,temp2,16);
88 CharUpper(temp2);
89 sprintf(lptv->item.pszText,"%s %s(&H%s)",VarName,temporary,temp2);
90 }
91 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
92 }
93 else if(type==DEF_LONG){
94 if(ReadProcessMemory(hDebugProcess,(void *)offset,&dwData,sizeof(DWORD),&dwAccessByte)){
95 sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,dwData,dwData);
96 }
97 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
98 }
99 else if(type==DEF_DWORD||IsPtrType(type)){
100 if(ReadProcessMemory(hDebugProcess,(void *)offset,&dwData,sizeof(DWORD),&dwAccessByte)){
101 sprintf(lptv->item.pszText,"%s %u(&H%X)",VarName,dwData,dwData);
102 }
103 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
104 }
105 else if(type==DEF_INTEGER){
106 if(ReadProcessMemory(hDebugProcess,(void *)offset,&wData,sizeof(WORD),&dwAccessByte)){
107 sprintf(lptv->item.pszText,"%s %d(&H%X)",VarName,(short)wData,(short)wData);
108 }
109 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
110 }
111 else if(type==DEF_WORD){
112 if(ReadProcessMemory(hDebugProcess,(void *)offset,&wData,sizeof(WORD),&dwAccessByte)){
113 sprintf(lptv->item.pszText,"%s %u(&H%X)",VarName,wData,wData);
114 }
115 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
116 }
117 else if(type==DEF_CHAR){
118 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&dwAccessByte)){
119 temporary[0]=byteData;
120 temporary[1]=0;
121 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,(char)byteData,byteData,temporary);
122 }
123 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
124 }
125 else if(type==DEF_BYTE){
126 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&dwAccessByte)){
127 temporary[0]=byteData;
128 temporary[1]=0;
129 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,byteData,byteData,temporary);
130 }
131 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
132 }
133 else if(type==DEF_BOOLEAN){
134 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&dwAccessByte)){
135 if( byteData ) lstrcpy( temporary, "True" );
136 else lstrcpy( temporary, "False" );
137 sprintf(lptv->item.pszText,"%s %s",VarName,temporary);
138 }
139 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS);
140 }
141 lptv->item.iImage=2;
142 lptv->item.iSelectedImage=2;
143 }
144 TreeView_InsertItem(hVarTree,lptv);
145}
146void VarList_Member(HWND hVarTree,HTREEITEM hParent,DWORD pTopOffset,CClass *pobj_c,BOOL bPtr){
147 int i,i2;
148 char VarData[VN_SIZE],VarName[VN_SIZE];
149 TV_INSERTSTRUCT tv;
150
151 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
152 tv.hInsertAfter=TVI_LAST;
153 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
154 tv.hParent=hParent;
155 tv.item.pszText=VarData;
156
157 for(i=0;i<pobj_c->iMemberNum;i++){
158 if(bPtr){
159 lstrcpy(VarName,"->");
160 lstrcat(VarName,pobj_c->ppobj_Member[i]->name);
161 }
162 else{
163 lstrcpy(VarName,".");
164 lstrcat(VarName,pobj_c->ppobj_Member[i]->name);
165 }
166
167 LONG_PTR offset;
168 offset=GetSizeOfClassMember(pobj_c,pobj_c->ppobj_Member[i]->name,&i2);
169
170 if(pobj_c->ppobj_Member[i]->SubScripts[0]!=-1){
171 //構造体内の配列
172 sprintf(VarData,"%s %s(&H%X)",VarName,STRING_ARRAY,pTopOffset+offset);
173 tv.item.iImage=0;
174 tv.item.iSelectedImage=0;
175 hParent=TreeView_InsertItem(hVarTree,&tv);
176
177 VarList_Array(hVarTree,hParent,
178 pTopOffset+offset,
179 pobj_c->ppobj_Member[i]->TypeInfo.type,
180 pobj_c->ppobj_Member[i]->SubScripts,
181 pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex);
182 }
183 else{
184 //メンバ変数
185 VarList_Insert(hVarTree,
186 &tv,
187 VarName,
188 pobj_c->ppobj_Member[i]->TypeInfo.type,
189 pTopOffset+offset,
190 pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex);
191 }
192 }
193}
194int VarList_Array(HWND hVarTree,HTREEITEM hParent,DWORD offset,int type,int *SubScripts,LONG_PTR lpIndex){
195 int i,i2,i3,ElementNum,MemCounter,UseCount[255],TypeSize;
196 char temporary[VN_SIZE],temp2[DIGIT_SIZE];
197
198 TV_INSERTSTRUCT tv;
199 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
200 tv.hInsertAfter=TVI_LAST;
201 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
202 tv.hParent=hParent;
203 tv.item.pszText=temporary;
204
205 TypeSize=GetTypeSize(type,lpIndex);
206
207 for(i=0;i<255;i++){
208 if(SubScripts[i]==-1) break;
209 UseCount[i]=0;
210 }
211 UseCount[i]=-2;
212 MemCounter=0;
213 while(1){
214 UseCount[i]++;
215 for(ElementNum=0;SubScripts[i-ElementNum]<UseCount[i-ElementNum];ElementNum++){
216 UseCount[i-ElementNum]=0;
217 if(i-ElementNum-1<0) return MemCounter;
218 UseCount[i-ElementNum-1]++;
219 }
220
221 if(MemCounter<50){
222 temporary[0]='[';
223 temporary[1]=0;
224 for(i2=0;i2<i;i2++){
225 sprintf(temp2,"%d",UseCount[i2]);
226 lstrcat(temporary,temp2);
227 lstrcat(temporary,",");
228 }
229 i3=lstrlen(temporary);
230 temporary[i3-1]=']';
231 temporary[i3]=0;
232
233 VarList_Insert(hVarTree,&tv,temporary,type,offset+MemCounter*TypeSize,lpIndex);
234 }
235
236 MemCounter++;
237 if(MemCounter==50){
238 lstrcpy(tv.item.pszText,"...");
239 TreeView_InsertItem(hVarTree,&tv);
240 }
241 }
242 return 0;
243}
244void RefreshGlobalVar(void){
245 extern DWORD ImageBase;
246 int i;
247 char temporary[VN_SIZE];
248 TV_INSERTSTRUCT tv;
249 HTREEITEM hParent;
250
251 TreeView_DeleteAllItems(hVarTree_Global);
252
253 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
254 tv.hInsertAfter=TVI_LAST;
255 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
256 tv.hParent=TVI_ROOT;
257 tv.item.pszText=temporary;
258
259 extern HANDLE hDebugProcess;
260 extern int MemPos_RWSection;
261 extern int MaxGlobalVarNum;
262 extern VARIABLE *GlobalVar;
263
264 for(i=0;i<MaxGlobalVarNum;i++){
265 VARIABLE *pVar=&GlobalVar[i];
266
267 //スコープ外の場合は無視
268 if(pVar->ScopeLevel!=0){
269 if(rva_to_real(pVar->ScopeStartAddress) <= pobj_dti->lplpObp[0] &&
270 pobj_dti->lplpObp[0] < rva_to_real(pVar->ScopeEndAddress)){
271 //範囲内
272 }
273 else{
274 //範囲外
275 continue;
276 }
277 }
278
279 if(!pobj_nv->bShow_DefaultSystem_Var){
280 if(memcmp(pVar->name,"_System_",8)==0||
281 memcmp(pVar->name,"_DebugSys_",10)==0||
282 memcmp(pVar->name,"_PromptSys_",11)==0) continue;
283 }
284 if(!pobj_nv->bShow_Rad_Var){
285 if(memcmp(pVar->name,"_RadSys_",8)==0) continue;
286 }
287 if(!pobj_nv->bShow_GUID_Var){
288 if(memcmp(pVar->name,"GUID_",5)==0||
289 memcmp(pVar->name,"IID_",4)==0||
290 memcmp(pVar->name,"CLSID_",6)==0) continue;
291 }
292
293 //静的メンバ
294 if(strstr(pVar->name,".")) continue;
295
296 if(pVar->bArray){
297 sprintf(temporary,"%s %s(&H%X)",
298 pVar->name,
299 STRING_ARRAY,
300 ImageBase+MemPos_RWSection+pVar->offset);
301 tv.item.iImage=0;
302 tv.item.iSelectedImage=0;
303 hParent=TreeView_InsertItem(hVarTree_Global,&tv);
304
305 VarList_Array(hVarTree_Global,hParent,
306 ImageBase+MemPos_RWSection+pVar->offset,
307 pVar->type,
308 pVar->SubScripts,
309 pVar->u.index);
310 }
311 else{
312 VarList_Insert(hVarTree_Global,
313 &tv,
314 pVar->name,
315 pVar->type,
316 ImageBase+MemPos_RWSection+pVar->offset,
317 pVar->u.index);
318 }
319 }
320}
321void RefreshLocalVar(void){
322 int i,i2,i3,sw;
323 char temporary[VN_SIZE];
324 TV_INSERTSTRUCT tv;
325 HTREEITEM hParent;
326 ULONG_PTR lpData;
327 LONG_PTR offset;
328 ULONG_PTR lpAccBytes;
329
330 TreeView_DeleteAllItems(hVarTree_Local);
331
332 memset(&tv,0,sizeof(TV_INSERTSTRUCT));
333 tv.hInsertAfter=TVI_LAST;
334 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
335 tv.hParent=TVI_ROOT;
336 tv.item.pszText=temporary;
337
338 extern HANDLE hDebugProcess;
339 extern HWND hDebugWnd;
340 i2=SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
341 i2=pobj_dti->iProcLevel-i2;
342
343 if(pobj_dti->lplpSpBase[i2]==0) return;
344
345 extern SUBINFO **ppSubHash;
346 SUBINFO *psi;
347 for(i3=0,sw=0;i3<MAX_HASH;i3++){
348 psi=ppSubHash[i3];
349 while(psi){
350 if(rva_to_real(psi->CompileAddress) <= pobj_dti->lplpObp[i2] &&
351 pobj_dti->lplpObp[i2] < rva_to_real(psi->EndOpAddr)){
352 sw=1;
353 break;
354 }
355
356 psi=psi->pNextData;
357 }
358 if(sw) break;
359 }
360 if(!psi) return;
361
362 for(i=0;i<psi->VarNum;i++){
363 VARIABLE *pVar=&psi->pVar[i];
364
365 //スコープ外の場合は無視
366 if(pVar->ScopeLevel!=0){
367 if(rva_to_real(pVar->ScopeStartAddress) <= pobj_dti->lplpObp[i2] &&
368 pobj_dti->lplpObp[i2] < rva_to_real(pVar->ScopeEndAddress)){
369 //範囲内
370 }
371 else{
372 //範囲外
373 continue;
374 }
375 }
376
377 if(pVar->bArray){
378 sprintf(temporary,"%s %s(&H%X)",
379 pVar->name,
380 STRING_ARRAY,
381 pobj_dti->lplpSpBase[i2]+pVar->offset);
382 tv.item.iImage=0;
383 tv.item.iSelectedImage=0;
384 hParent=TreeView_InsertItem(hVarTree_Local,&tv);
385
386 VarList_Array(hVarTree_Local,hParent,
387 pobj_dti->lplpSpBase[i2]+pVar->offset,
388 pVar->type,
389 pVar->SubScripts,
390 pVar->u.index);
391 }
392 else{
393 offset=pobj_dti->lplpSpBase[i2]+pVar->offset;
394 if(pVar->fRef){
395 ReadProcessMemory(hDebugProcess,(void *)offset,&lpData,sizeof(ULONG_PTR),&lpAccBytes);
396 offset=lpData;
397 }
398 VarList_Insert(hVarTree_Local,&tv,
399 pVar->name,
400 pVar->type,
401 offset,
402 pVar->u.index);
403 }
404 }
405
406
407
408 /////////////////////////////
409 // Thisオブジェクトのリスト
410 /////////////////////////////
411
412 TreeView_DeleteAllItems(hVarTree_This);
413 if(!psi->pobj_ParentClass) return;
414
415 //Thisポインタを取得
416 LONG_PTR pThis;
417 for(i=0;i<psi->VarNum;i++){
418 if(lstrcmp(psi->pVar[i].name,"_System_LocalThis")==0) break;
419 }
420 if(i==psi->VarNum) return;
421 lpData=pobj_dti->lplpSpBase[i2]+psi->pVar[i].offset;
422 ReadProcessMemory(hDebugProcess,(void *)lpData,&pThis,sizeof(LONG_PTR),&lpAccBytes);
423
424 for(i=0;i<psi->pobj_ParentClass->iMemberNum;i++){
425 offset=GetSizeOfClassMember(psi->pobj_ParentClass,psi->pobj_ParentClass->ppobj_Member[i]->name,&i2);
426
427 if(psi->pobj_ParentClass->ppobj_Member[i]->SubScripts[0]!=-1){
428 //配列
429 sprintf(temporary,"%s %s(&H%X)",
430 psi->pobj_ParentClass->ppobj_Member[i]->name,
431 STRING_ARRAY,
432 offset);
433 tv.item.iImage=0;
434 tv.item.iSelectedImage=0;
435 hParent=TreeView_InsertItem(hVarTree_This,&tv);
436
437 VarList_Array(hVarTree_This,hParent,
438 pThis+offset,
439 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.type,
440 psi->pobj_ParentClass->ppobj_Member[i]->SubScripts,
441 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.u.lpIndex);
442 }
443 else{
444 VarList_Insert(hVarTree_This,&tv,
445 psi->pobj_ParentClass->ppobj_Member[i]->name,
446 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.type,
447 pThis+offset,
448 psi->pobj_ParentClass->ppobj_Member[i]->TypeInfo.u.lpIndex);
449 }
450 }
451}
452void RefreshGlobalVar_with_WindowLock(void){
453 extern HWND hDebugWnd;
454
455 //処理時間を短くするため、一時的に非表示にする
456 LockWindowUpdate(hDebugWnd);
457 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
458
459 //リフレッシュ
460 RefreshGlobalVar();
461
462 LockWindowUpdate(NULL);
463 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
464}
465void RefreshLocalVar_with_WindowLock(void){
466 extern HWND hDebugWnd;
467
468 //処理時間を短くするため、一時的に非表示にする
469 LockWindowUpdate(hDebugWnd);
470 ShowWindow(GetParent(hVarTree_Local),SW_HIDE);
471
472 //リフレッシュ
473 RefreshLocalVar();
474
475 LockWindowUpdate(NULL);
476 ShowWindow(GetParent(hVarTree_Local),SW_SHOW);
477}
478
479void SetCalcToWatchList(HWND hListView,int iItem,char *buffer){
480 int i;
481 char temporary[255],temp2[255];
482
483 //エスケープシーケンスをセット
484 SetEscapeSequenceFormat(buffer);
485
486 //ブランクを除去
487 KillStringSpaces(buffer);
488
489 //カッコを相互チェック
490 if(!CheckParenthesis2(buffer)){
491 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
492 return;
493 }
494
495 double dbl;
496 _int64 i64data;
497 i=StaticCalculation(true, buffer,0,&i64data,0,1);
498 if(IsRealNumberType(i)){
499 memcpy(&dbl,&i64data,sizeof(double));
500 }
501
502 if(i==0){
503 ListView_SetItemText(hListView,iItem,1,"式の解析に失敗");
504 }
505 else if(i==-1){
506 ListView_SetItemText(hListView,iItem,1,STRING_CANNOTACCESS);
507 }
508 else{
509 if(IsRealNumberType(i))
510 sprintf(temporary,"%.15g (&H%08X)",dbl,(int)dbl);
511 else if(Is64Type(i)){
512 _i64toa(i64data,temporary,10);
513 _i64toa(i64data,temp2,16);
514 CharUpper(temp2);
515 sprintf(temporary+lstrlen(temporary)," (&H%s)",temp2);
516 }
517 else sprintf(temporary,"%d (&H%08X)",(long)i64data,(long)i64data);
518
519 ListView_SetItemText(hListView,iItem,1,temporary);
520 }
521}
522void RefreshWatchList(void){
523 extern HWND hDebugWnd;
524 HWND hListView;
525 int i,i2;
526 char temporary[VN_SIZE];
527
528 hListView=GetDlgItem(hDebugWnd,IDC_WATCHLIST);
529 i2=ListView_GetItemCount(hListView);
530 for(i=0;i<i2-1;i++){
531 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
532
533 //演算結果を表示
534 SetCalcToWatchList(hListView,i,temporary);
535 }
536}
537
538BOOL SetDebugProcCombo(HWND hProcCombo){
539 int i2,i3;
540 char temporary[255];
541
542 extern DWORD ImageBase;
543 extern int MemPos_CodeSection;
544
545 //行番号情報
546 extern int MaxLineInfoNum;
547 extern LINEINFO *pLineInfo;
548 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
549 for(i2=0;i2<MaxLineInfoNum-1;i2++){
550 if((pLineInfo[i2].TopObp+ImageBase+MemPos_CodeSection)<=pobj_dti->lplpObp[i3]&&
551 pobj_dti->lplpObp[i3]<=(pLineInfo[i2+1].TopObp+ImageBase+MemPos_CodeSection)) break;
552 }
553 if(i2==MaxLineInfoNum) pobj_dti->lpdwCp[i3]=-1;
554 else{
555 pobj_dti->lpdwCp[i3]=pLineInfo[i2].TopCp;
556 }
557 }
558 for(i3=0;i3<(int)pobj_dti->iProcLevel+1;i3++){
559 if(pobj_dti->lpdwCp[i3]==-1){
560 pobj_dti->iProcLevel--;
561 for(i2=i3;i2<(int)pobj_dti->iProcLevel+1;i2++){
562 pobj_dti->lplpObp[i2]=pobj_dti->lplpObp[i2+1];
563 pobj_dti->lplpSpBase[i2]=pobj_dti->lplpSpBase[i2+1];
564 pobj_dti->lpdwCp[i2]=pobj_dti->lpdwCp[i2+1];
565 }
566 i3--;
567 continue;
568 }
569 }
570
571 if(!GetLineNum(pobj_dti->lpdwCp[pobj_dti->iProcLevel],&i2,temporary)){
572 extern HWND hMainDlg;
573 //"デバッグ情報の取得に失敗"
574 MessageBox(hMainDlg,STRING_DEBUG_FAILED,"ActiveBasic error",MB_OK);
575 return 0;
576 }
577 ShowErrorLine(i2,temporary);
578
579 //プロシージャ コンボボックス
580 extern SUBINFO **ppSubHash;
581 SUBINFO *psi;
582 int sw;
583 SendMessage(hProcCombo,CB_RESETCONTENT,0,0);
584 for(i2=pobj_dti->iProcLevel;i2>=0;i2--){
585 for(i3=0,sw=0;i3<MAX_HASH;i3++){
586 psi=ppSubHash[i3];
587 while(psi){
588 if(rva_to_real(psi->CompileAddress) <= pobj_dti->lplpObp[i2] &&
589 pobj_dti->lplpObp[i2] < rva_to_real(psi->EndOpAddr)){
590 lstrcpy(temporary,psi->name);
591 sw=1;
592 break;
593 }
594 psi=psi->pNextData;
595 }
596 if(sw) break;
597 }
598 if(!psi){
599 if(i2==0){
600 lstrcpy(temporary,"Global");
601 pobj_dti->lplpSpBase[i2]=0;
602 }
603 else lstrcpy(temporary,"error");
604 }
605 SendMessage(hProcCombo,CB_ADDSTRING,0,(long)temporary);
606 }
607 SendMessage(hProcCombo,CB_SETCURSEL,0,0);
608
609 return pobj_dti->iProcLevel;
610}
611
612//IDC_THREADCOMBOプロシージャ
613LRESULT CALLBACK ThreadComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
614 extern WNDPROC OldThreadComboProc;
615 int i2;
616 DWORD dwThreadID;
617 char temporary[255];
618
619 switch(message){
620 case WM_COMMAND:
621 if(HIWORD(wParam)==CBN_SELCHANGE){
622 SendMessage(hwnd,CB_GETLBTEXT,SendMessage(hwnd,CB_GETCURSEL,0,0),(long)temporary);
623 sscanf(temporary+2,"%X",&dwThreadID);
624
625 i2=0;
626 while(_DebugSys_dwThreadID[i2]!=dwThreadID) i2++;
627
628 //次回のステップ実行対象を指定
629 extern int NextStepThreadNum;
630 NextStepThreadNum=i2;
631
632 //スレッド情報をリフレッシュ
633 pobj_dti->Reflesh(i2);
634
635 SetDebugProcCombo(GetDlgItem(GetParent(hwnd),IDC_PROCCOMBO));
636
637 SendDlgItemMessage(GetParent(hwnd),IDC_PROCCOMBO,WM_COMMAND,MAKELONG(0,CBN_SELCHANGE),0);
638 }
639 break;
640 }
641 return CallWindowProc(OldThreadComboProc,hwnd,message,wParam,lParam);
642}
643//IDC_PROCCOMBOプロシージャ
644LRESULT CALLBACK ProcComboProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
645 extern WNDPROC OldProcComboProc;
646 int i2,i3;
647 char temporary[MAX_PATH];
648
649 switch(message){
650 case WM_COMMAND:
651 if(HIWORD(wParam)==CBN_SELCHANGE){
652 i2=SendMessage(hwnd,CB_GETCURSEL,0,0);
653 GetLineNum(pobj_dti->lpdwCp[pobj_dti->iProcLevel-i2],&i3,temporary);
654 ShowErrorLine(i3,temporary);
655
656 RefreshLocalVar_with_WindowLock();
657 }
658 break;
659 }
660 return CallWindowProc(OldProcComboProc,hwnd,message,wParam,lParam);
661}
662void InitVarList(DWORD dwThreadId){
663 extern HWND hDebugWnd;
664 int i2,i3,i5;
665 char temporary[255];
666
667
668 //スレッド
669 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_RESETCONTENT,0,0);
670 extern DWORD _DebugSys_dwThreadID[256];
671 for(i2=0;i2<256;i2++){
672 if(_DebugSys_dwThreadID[i2]){
673 sprintf(temporary,"&H%08X",_DebugSys_dwThreadID[i2]);
674 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_ADDSTRING,0,(LPARAM)temporary);
675 if(_DebugSys_dwThreadID[i2]==dwThreadId){
676 extern int NextStepThreadNum;
677 NextStepThreadNum=i2;
678 }
679 }
680 }
681 sprintf(temporary,"&H%08X",dwThreadId);
682 i5=(int)SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_FINDSTRING,0,(LPARAM)temporary);
683 SendDlgItemMessage(hDebugWnd,IDC_THREADCOMBO,CB_SETCURSEL,i5,0);
684
685 i2=SetDebugProcCombo(GetDlgItem(hDebugWnd,IDC_PROCCOMBO));
686
687
688 ///////////////////////////////////////////////
689 // 実行中のプロシージャのローカル変数をセット
690 ///////////////////////////////////////////////
691
692 extern VARIABLE *LocalVar;
693 extern int MaxLocalVarNum;
694 int sw;
695
696 MaxLocalVarNum=0;
697 pobj_CompilingClass=0;
698
699 i2=SendDlgItemMessage(hDebugWnd,IDC_PROCCOMBO,CB_GETCURSEL,0,0);
700 i2=pobj_dti->iProcLevel-i2;
701
702 if(pobj_dti->lplpSpBase[i2]){
703 extern SUBINFO **ppSubHash;
704 SUBINFO *psi;
705 for(i3=0,sw=0;i3<MAX_HASH;i3++){
706 psi=ppSubHash[i3];
707 while(psi){
708 if(rva_to_real(psi->CompileAddress) <= pobj_dti->lplpObp[i2] &&
709 pobj_dti->lplpObp[i2] < rva_to_real(psi->EndOpAddr)){
710 sw=1;
711 break;
712 }
713
714 psi=psi->pNextData;
715 }
716 if(sw) break;
717 }
718
719
720 if(psi){
721 LocalVar=psi->pVar;
722 MaxLocalVarNum=psi->VarNum;
723
724 pobj_CompilingClass=psi->pobj_ParentClass;
725 }
726 }
727
728
729 ////////////////////////
730 // 変数リストを再表示
731 ////////////////////////
732
733 //処理時間を短くするため、一時的に非表示にする
734 LockWindowUpdate(hDebugWnd);
735 ShowWindow(GetParent(hVarTree_Global),SW_HIDE);
736 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_HIDE);
737
738 //リフレッシュ
739 RefreshLocalVar();
740 RefreshGlobalVar();
741 RefreshWatchList();
742
743 LockWindowUpdate(NULL);
744 ShowWindow(GetParent(hVarTree_Global),SW_SHOW);
745 ShowWindow(GetDlgItem(hDebugWnd,IDC_WATCHLIST),SW_SHOW);
746}
747
748
749
750
751//////////////////////////////////////
752// エディタに埋め込み表示のデバッガ
753//////////////////////////////////////
754
755BOOL CALLBACK DebuggerButtonsProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
756 extern HINSTANCE hInst;
757 extern DWORD dwStepRun;
758
759 //デバッガ用ツールバー
760#define BMPNUM_DEBUGGERTOOLBAR 3
761#define BTNNUM_DEBUGGERTOOLBAR 4
762 TBBUTTON DebuggerToolBar[]={
763 {0,IDC_DEBUG_START,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
764 {0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0},
765 {1,IDC_DEBUG_STEPOVER,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
766 {2,IDC_DEBUG_STEPIN,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0},
767 };
768 TOOLTIPTEXT *pTipText;
769
770 static HIMAGELIST hImageList,hImageList_Disabled;
771
772 switch(message){
773 case WM_INITDIALOG:
774 //ツールバーを生成
775 extern HWND hDebuggerToolbar;
776 hDebuggerToolbar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS|WS_CLIPSIBLINGS,
777 NULL,
778 0,0,0,
779 DebuggerToolBar,
780 BTNNUM_DEBUGGERTOOLBAR, /*アイテムの個数*/
781 0,0,16,15,sizeof(TBBUTTON));
782
783 hImageList = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR),
784 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
785 SendMessage(hDebuggerToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList);
786 hImageList_Disabled = ImageList_LoadImage(hInst, MAKEINTRESOURCE(IDR_DEBUGGERTOOLBAR_DISABLED),
787 16, 0, RGB(192,192,192),IMAGE_BITMAP, LR_CREATEDIBSECTION);
788 SendMessage(hDebuggerToolbar, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)hImageList_Disabled);
789
790 break;
791 case WM_COMMAND:
792 switch(LOWORD(wParam)){
793 case IDC_DEBUG_START:
794 DestroyWindow(GetParent(hwnd));
795 return 1;
796 case IDC_DEBUG_STEPIN:
797 Debugger_StepIn();
798 return 1;
799 case IDC_DEBUG_STEPOVER:
800 Debugger_StepOver();
801 return 1;
802 }
803 break;
804 case WM_NOTIFY:
805 pTipText=(TOOLTIPTEXT *)lParam;
806 if(pTipText->hdr.code==TTN_NEEDTEXT){
807 //ツールチップを表示
808 switch(pTipText->hdr.idFrom){
809 case IDC_DEBUG_START:
810 pTipText->lpszText="実行";
811 break;
812 case IDC_DEBUG_STEPOVER:
813 pTipText->lpszText="ステップ アウト";
814 break;
815 case IDC_DEBUG_STEPIN:
816 pTipText->lpszText="ステップ イン";
817 break;
818 }
819 }
820 break;
821 case WM_SIZE:
822 MoveWindow(hDebuggerToolbar,0,0,LOWORD(lParam),HIWORD(lParam),1);
823 return 1;
824
825 case WM_DESTROY:
826 ImageList_Destroy(hImageList);
827 ImageList_Destroy(hImageList_Disabled);
828 return 1;
829 }
830 return 0;
831}
832
833WNDPROC OldTabProc;
834LRESULT CALLBACK TabProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
835 extern HINSTANCE hInst;
836
837 static HMENU hDummyMenu,hMenu=0;
838
839 switch(message){
840 case WM_CONTEXTMENU:
841 if(hMenu==0){
842 hDummyMenu=LoadMenu(hInst,MAKEINTRESOURCE(IDR_DEBUGGER_VARLIST_MENU));
843 hMenu=GetSubMenu(hDummyMenu,0);
844 }
845
846 MENUITEMINFO mi;
847 mi.cbSize=sizeof(MENUITEMINFO);
848 mi.fMask=MIIM_STATE;
849 mi.fState=MFS_CHECKED;
850
851 if(pobj_nv->bShow_DefaultSystem_Var)
852 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
853 if(pobj_nv->bShow_Rad_Var)
854 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
855 if(pobj_nv->bShow_GUID_Var)
856 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
857
858 TrackPopupMenu(hMenu,TPM_LEFTALIGN,LOWORD(lParam),HIWORD(lParam),0,hwnd,0);
859
860 break;
861 case WM_COMMAND:
862 mi.cbSize=sizeof(MENUITEMINFO);
863 mi.fMask=MIIM_STATE;
864 switch(LOWORD(wParam)){
865 case IDM_SHOW_DEFAULTSYSTEM_VAR:
866 if(pobj_nv->bShow_DefaultSystem_Var){
867 pobj_nv->bShow_DefaultSystem_Var=0;
868 mi.fState=MFS_UNCHECKED;
869 }
870 else{
871 pobj_nv->bShow_DefaultSystem_Var=1;
872 mi.fState=MFS_CHECKED;
873 }
874 SetMenuItemInfo(hMenu,IDM_SHOW_DEFAULTSYSTEM_VAR,0,&mi);
875 RefreshGlobalVar_with_WindowLock();
876 break;
877 case IDM_SHOW_RAD_VAR:
878 if(pobj_nv->bShow_Rad_Var){
879 pobj_nv->bShow_Rad_Var=0;
880 mi.fState=MFS_UNCHECKED;
881 }
882 else{
883 pobj_nv->bShow_Rad_Var=1;
884 mi.fState=MFS_CHECKED;
885 }
886 SetMenuItemInfo(hMenu,IDM_SHOW_RAD_VAR,0,&mi);
887 RefreshGlobalVar_with_WindowLock();
888 break;
889 case IDM_SHOW_GUID_VAR:
890 if(pobj_nv->bShow_GUID_Var){
891 pobj_nv->bShow_GUID_Var=0;
892 mi.fState=MFS_UNCHECKED;
893 }
894 else{
895 pobj_nv->bShow_GUID_Var=1;
896 mi.fState=MFS_CHECKED;
897 }
898 SetMenuItemInfo(hMenu,IDM_SHOW_GUID_VAR,0,&mi);
899 RefreshGlobalVar_with_WindowLock();
900 break;
901 }
902 break;
903 case WM_DESTROY:
904 DestroyMenu(hMenu);
905 hMenu=0;
906 break;
907 }
908 return CallWindowProc(OldTabProc,hwnd,message,wParam,lParam);
909}
910
911BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
912 extern HANDLE hHeap;
913 extern HINSTANCE hInst;
914 extern DWORD dwStepRun;
915 extern double width_ratio_VarList;
916 RECT rect;
917 int i,i2,i3;
918 char temporary[VN_SIZE];
919 LV_DISPINFO *lvinfo;
920 LVITEM ListView_Item;
921
922 static POINT pos_VarList;
923 static POINT pos_WatchList;
924
925 switch(message){
926 case WM_INITDIALOG:
927 extern HWND hDebugWnd;
928 hDebugWnd=hwnd;
929
930 //変数リストの初期位置を取得
931 GetWindowRect(GetDlgItem(hwnd,IDC_VARPOS),&rect);
932 pos_VarList.x=rect.left;
933 pos_VarList.y=rect.top;
934 ScreenToClient(hwnd,&pos_VarList);
935
936 //ウォッチリストの初期位置を取得
937 pos_WatchList.x=pos_VarList.x+(rect.right-rect.left)+LEVER_THICK;
938 pos_WatchList.y=0;
939
940 //ツールバーのベースウィンドウを生成
941 static HWND hBase_ToolBar;
942 hBase_ToolBar=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUGGER_TOOLBARBASE),hwnd,DebuggerButtonsProc);
943 MoveWindow(hBase_ToolBar,50,0,20*BTNNUM_DEBUGGERTOOLBAR,22,1);
944
945 extern WNDPROC OldThreadComboProc;
946 OldThreadComboProc=(WNDPROC)GetWindowLong(GetDlgItem(hwnd,IDC_THREADCOMBO),GWL_WNDPROC);
947 SetWindowLong(GetDlgItem(hwnd,IDC_THREADCOMBO),GWL_WNDPROC,(long)ThreadComboProc);
948
949 extern WNDPROC OldProcComboProc;
950 OldProcComboProc=(WNDPROC)GetWindowLong(GetDlgItem(hwnd,IDC_PROCCOMBO),GWL_WNDPROC);
951 SetWindowLong(GetDlgItem(hwnd,IDC_PROCCOMBO),GWL_WNDPROC,(long)ProcComboProc);
952
953
954 ///////////////////////////
955 // タブコントロールを生成
956 ///////////////////////////
957
958 static HWND hTab;
959 HFONT hFont;
960 hFont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
961 hTab=CreateWindow(WC_TABCONTROL,NULL,
962 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
963 0,0,0,0,hwnd,0,hInst,0);
964 SendMessage(hTab,WM_SETFONT,(long)hFont,0);
965 OldTabProc=(WNDPROC)GetWindowLong(hTab,GWL_WNDPROC);
966 SetWindowLong(hTab,GWL_WNDPROC,(long)TabProc);
967
968 //タブを設定
969 TC_ITEM tcItem;
970 tcItem.mask=TCIF_TEXT;
971 tcItem.pszText="グローバル";
972 SendMessage(hTab,TCM_INSERTITEM,0,(LPARAM)&tcItem);
973 tcItem.mask=TCIF_TEXT;
974 tcItem.pszText="ローカル";
975 SendMessage(hTab,TCM_INSERTITEM,1,(LPARAM)&tcItem);
976 tcItem.mask=TCIF_TEXT;
977 tcItem.pszText="This";
978 SendMessage(hTab,TCM_INSERTITEM,2,(LPARAM)&tcItem);
979
980 //グローバル変数リストのツリーを作成
981 hVarTree_Global=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
982 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
983 0,0,0,0,
984 hTab,0,hInst,0);
985
986 //ローカル変数リストのツリーを作成
987 hVarTree_Local=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
988 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
989 0,0,0,0,
990 hTab,0,hInst,0);
991
992 //This変数リストのツリーを作成
993 hVarTree_This=CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"",
994 WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_SHOWSELALWAYS,
995 0,0,0,0,
996 hTab,0,hInst,0);
997
998 ShowWindow(hVarTree_Global,SW_SHOW);
999
1000
1001 //イメージリスト読み込み、設定
1002 static HIMAGELIST hVariOrderImageList;
1003 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1004 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1005 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1006 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1007 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1008 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1009 TreeView_SetImageList(hVarTree_Global,hVariOrderImageList,TVSIL_NORMAL);
1010 TreeView_SetImageList(hVarTree_Local,hVariOrderImageList,TVSIL_NORMAL);
1011 TreeView_SetImageList(hVarTree_This,hVariOrderImageList,TVSIL_NORMAL);
1012
1013
1014 /////////////////////////
1015 // ウォッチリスト
1016 /////////////////////////
1017
1018 //コラムの設定
1019 static HWND hListView;
1020 LV_COLUMN ListView_Column;
1021 DWORD dwStyle;
1022
1023 hListView=GetDlgItem(hwnd,IDC_WATCHLIST);
1024 GetClientRect(hListView,&rect);
1025 dwStyle=ListView_GetExtendedListViewStyle(hListView);
1026 dwStyle|=LVS_EX_FULLROWSELECT;
1027 ListView_SetExtendedListViewStyle(hListView,dwStyle);
1028
1029 ListView_Column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1030 ListView_Column.fmt=LVCFMT_LEFT;
1031
1032 extern int width_WatchColumn_Expression;
1033 ListView_Column.cx=width_WatchColumn_Expression;
1034 ListView_Column.pszText="ウォッチ式";
1035 ListView_Column.iSubItem=0;
1036 ListView_InsertColumn(hListView,0,&ListView_Column);
1037
1038 extern int width_WatchColumn_Value;
1039 ListView_Column.cx=width_WatchColumn_Value;
1040 ListView_Column.pszText="値";
1041 ListView_Column.iSubItem=1;
1042 ListView_InsertColumn(hListView,1,&ListView_Column);
1043
1044 //アイテムの設定
1045 ListView_Item.mask=LVIF_TEXT;
1046 ListView_Item.iSubItem=0;
1047 for(i=0;i<pobj_nv->WatchNum;i++){
1048 ListView_Item.pszText=pobj_nv->ppWatchStr[i];
1049 ListView_Item.iItem=i;
1050 ListView_InsertItem(hListView,&ListView_Item);
1051 }
1052 ListView_Item.pszText="...";
1053 ListView_Item.iItem=i;
1054 ListView_InsertItem(hListView,&ListView_Item);
1055
1056
1057 ///////////////////////
1058 // 変数リストの初期化
1059 ///////////////////////
1060 InitVarList((DWORD)lParam);
1061
1062 break;
1063 case WM_NOTIFY:
1064 NMHDR *hdr;
1065 hdr=(NMHDR *)lParam;
1066 if(hdr->hwndFrom==hTab&&hdr->code==TCN_SELCHANGE){
1067 i=TabCtrl_GetCurSel(hTab);
1068
1069 if(i==0){
1070 //グローバル変数を表示
1071 ShowWindow(hVarTree_Global,SW_SHOW);
1072 ShowWindow(hVarTree_Local,SW_HIDE);
1073 ShowWindow(hVarTree_This,SW_HIDE);
1074 }
1075 else if(i==1){
1076 //ローカル変数を表示
1077 ShowWindow(hVarTree_Global,SW_HIDE);
1078 ShowWindow(hVarTree_Local,SW_SHOW);
1079 ShowWindow(hVarTree_This,SW_HIDE);
1080 }
1081 else if(i==2){
1082 //This変数を表示
1083 ShowWindow(hVarTree_Global,SW_HIDE);
1084 ShowWindow(hVarTree_Local,SW_HIDE);
1085 ShowWindow(hVarTree_This,SW_SHOW);
1086 }
1087 }
1088
1089 if(hdr->hwndFrom==hListView){
1090 lvinfo=(LV_DISPINFO *)hdr;
1091 if(hdr->code==NM_DBLCLK){
1092 i2=ListView_GetItemCount(hListView);
1093 for(i=0;i<i2;i++){
1094 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)) break;
1095 }
1096 if(i==i2) break;
1097
1098 ListView_EditLabel(hListView,i);
1099 }
1100
1101 static HWND hEdit;
1102 if(hdr->code==LVN_BEGINLABELEDIT){
1103 hEdit=ListView_GetEditControl(hListView);
1104
1105 GetWindowText(hEdit,temporary,VN_SIZE);
1106 if(lstrcmp(temporary,"...")==0) SetWindowText(hEdit,"");
1107 }
1108 if(hdr->code==LVN_ENDLABELEDIT){
1109 GetWindowText(hEdit,temporary,VN_SIZE);
1110 if(temporary[0]=='\0'){
1111 if(ListView_GetItemCount(hListView)-1==lvinfo->item.iItem) break;
1112
1113 //空白入力の場合はそのアイテムを削除する
1114 ListView_DeleteItem(hListView,lvinfo->item.iItem);
1115 break;
1116 }
1117 ListView_SetItemText(hListView,lvinfo->item.iItem,0,temporary);
1118
1119 //演算結果を表示
1120 SetCalcToWatchList(hListView,lvinfo->item.iItem,temporary);
1121
1122 if(lvinfo->item.iItem==ListView_GetItemCount(hListView)-1){
1123 //リストアイテムを追加
1124 ListView_Item.mask=LVIF_TEXT;
1125 ListView_Item.pszText="...";
1126 ListView_Item.iItem=lvinfo->item.iItem+1;
1127 ListView_Item.iSubItem=0;
1128 ListView_InsertItem(hListView,&ListView_Item);
1129 }
1130 }
1131
1132 if(hdr->code==LVN_KEYDOWN){
1133 LV_KEYDOWN *plvKeydown;
1134 plvKeydown=(LV_KEYDOWN *)hdr;
1135 if(plvKeydown->wVKey==VK_DELETE){
1136 i2=ListView_GetItemCount(hListView);
1137 for(i=i2-2;i>=0;i--){
1138 if(ListView_GetItemState(hListView,i,LVIS_SELECTED)){
1139 ListView_DeleteItem(hListView,i);
1140 i3=i;
1141 }
1142 }
1143
1144 ListView_SetItemState(hListView,i3,LVIS_SELECTED,LVIS_SELECTED);
1145 }
1146 }
1147 }
1148 break;
1149
1150 case WM_SIZE:
1151 //変数リストの位置
1152 int width_VarList;
1153 width_VarList=
1154 (int)((double)(LOWORD(lParam)-pos_VarList.x)*width_ratio_VarList);
1155
1156 MoveWindow(hTab,
1157 pos_VarList.x,
1158 pos_VarList.y,
1159 width_VarList,
1160 HIWORD(lParam)-pos_VarList.y,
1161 1);
1162
1163 GetClientRect(hTab,&rect);
1164 TabCtrl_AdjustRect(hTab,FALSE,&rect);
1165 rect.left-=2;
1166 rect.right++;
1167 rect.bottom++;
1168
1169 MoveWindow(hVarTree_Global,
1170 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1171 MoveWindow(hVarTree_Local,
1172 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1173 MoveWindow(hVarTree_This,
1174 rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,1);
1175
1176 pos_WatchList.x=pos_VarList.x+width_VarList+LEVER_THICK;
1177 pos_WatchList.y=0;
1178
1179 //ウォッチリストの位置
1180 MoveWindow(GetDlgItem(hwnd,IDC_WATCHLIST),
1181 pos_WatchList.x,
1182 pos_WatchList.y,
1183 LOWORD(lParam)-pos_WatchList.x,
1184 HIWORD(lParam)-pos_WatchList.y,
1185 1);
1186
1187 return 1;
1188
1189 case WM_VARLIST_CLOSE:
1190 DestroyWindow(hwnd);
1191 return 1;
1192 case WM_DESTROY:
1193 ImageList_Destroy(hVariOrderImageList);
1194
1195
1196 //////////////////////////////////////////////////////////////
1197 // ウォッチリストの以前の内容を破棄し、新しい内容に書き換える
1198 //////////////////////////////////////////////////////////////
1199
1200 for(i=0;i<pobj_nv->WatchNum;i++){
1201 HeapDefaultFree(pobj_nv->ppWatchStr[i]);
1202 }
1203 HeapDefaultFree(pobj_nv->ppWatchStr);
1204
1205 pobj_nv->WatchNum=ListView_GetItemCount(hListView)-1;
1206 pobj_nv->ppWatchStr=(char **)HeapAlloc(hHeap,0,pobj_nv->WatchNum*sizeof(char *)+1);
1207 for(i=0;i<pobj_nv->WatchNum;i++){
1208 ListView_GetItemText(hListView,i,0,temporary,VN_SIZE);
1209 pobj_nv->ppWatchStr[i]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
1210 lstrcpy(pobj_nv->ppWatchStr[i],temporary);
1211 }
1212
1213
1214 //////////////////////////////
1215 // デバッグダイアログを破棄
1216 //////////////////////////////
1217
1218 hDebugWnd=0;
1219
1220 extern BOOL bClipCompileView;
1221 if(bClipCompileView){
1222 extern HWND hOwnerEditor;
1223 SendMessage(hOwnerEditor,WM_DESTROYDEBUGGERVIEW,0,0);
1224 }
1225
1226 return 1;
1227
1228
1229
1230 ///////////////////////
1231 // デバッグコマンド
1232 ///////////////////////
1233
1234 case WM_DEBUG_CONTINUE:
1235 DestroyWindow(hwnd);
1236 return 1;
1237 case WM_STEP_IN:
1238 Debugger_StepIn();
1239 return 1;
1240 case WM_STEP_OVER:
1241 Debugger_StepOver();
1242 return 1;
1243 case WM_STEP_CURSOR:
1244 Debugger_StepCursor();
1245 return 1;
1246 }
1247 return 0;
1248}
1249
1250
1251
1252
1253//////////////////////////////////
1254// ポップアップ表示の変数リスト
1255//////////////////////////////////
1256
1257BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1258 extern HANDLE hHeap;
1259 extern HINSTANCE hInst;
1260 extern DWORD dwStepRun;
1261 RECT rect;
1262 POINT pos;
1263 SIZE size;
1264
1265 switch(message){
1266 case WM_INITDIALOG:
1267 extern HWND hDebugWnd;
1268 hDebugWnd=hwnd;
1269
1270 pos.x=pobj_nv->VarDlgRect.left;
1271 pos.y=pobj_nv->VarDlgRect.top;
1272 size.cx=pobj_nv->VarDlgRect.right-pobj_nv->VarDlgRect.left;
1273 size.cy=pobj_nv->VarDlgRect.bottom-pobj_nv->VarDlgRect.top;
1274 MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
1275
1276 extern WNDPROC OldThreadComboProc;
1277 OldThreadComboProc=(WNDPROC)GetWindowLong(GetDlgItem(hwnd,IDC_THREADCOMBO),GWL_WNDPROC);
1278 SetWindowLong(GetDlgItem(hwnd,IDC_THREADCOMBO),GWL_WNDPROC,(long)ThreadComboProc);
1279
1280 extern WNDPROC OldProcComboProc;
1281 OldProcComboProc=(WNDPROC)GetWindowLong(GetDlgItem(hwnd,IDC_PROCCOMBO),GWL_WNDPROC);
1282 SetWindowLong(GetDlgItem(hwnd,IDC_PROCCOMBO),GWL_WNDPROC,(long)ProcComboProc);
1283
1284 //イメージリスト読み込み、設定
1285 static HIMAGELIST hVariOrderImageList;
1286 hVariOrderImageList=ImageList_Create(16,16,ILC_COLOR4|ILC_MASK,4,0);
1287 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARARRAY)));
1288 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTRUCT)));
1289 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARDATA)));
1290 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARSTR)));
1291 ImageList_AddIcon(hVariOrderImageList,LoadIcon(hInst,MAKEINTRESOURCE(IDI_VARPTRSTRUCT)));
1292 TreeView_SetImageList(GetDlgItem(hwnd,IDC_VARTREE),hVariOrderImageList,TVSIL_NORMAL);
1293
1294 InitVarList((DWORD)lParam);
1295 break;
1296 case WM_COMMAND:
1297 switch(LOWORD(wParam)){
1298 case IDCANCEL:
1299 DestroyWindow(hwnd);
1300 return 1;
1301 case IDC_STEPIN:
1302 Debugger_StepIn();
1303 return 1;
1304 case IDC_STEPOVER:
1305 Debugger_StepOver();
1306 return 1;
1307 }
1308 break;
1309 case WM_SIZE:
1310 GetWindowRect(GetDlgItem(hwnd,IDC_VARTREE),&rect);
1311 pos.x=rect.left;
1312 pos.y=rect.top;
1313 ScreenToClient(hwnd,&pos);
1314 MoveWindow(GetDlgItem(hwnd,IDC_VARTREE),0,pos.y,LOWORD(lParam),HIWORD(lParam)-pos.y,TRUE);
1315 SetWindowPos(GetDlgItem(hwnd,IDCANCEL),0,LOWORD(lParam)-91,9,0,0,SWP_NOSIZE);
1316 return 1;
1317 case WM_VARLIST_CLOSE:
1318 DestroyWindow(hwnd);
1319 return 1;
1320 case WM_DESTROY:
1321 ImageList_Destroy(hVariOrderImageList);
1322
1323 GetWindowRect(hwnd,&pobj_nv->VarDlgRect);
1324
1325 hDebugWnd=0;
1326
1327 return 1;
1328 }
1329 return 0;
1330}
Note: See TracBrowser for help on using the repository browser.