source: dev/VarList.cpp@ 1

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