source: dev/BasicCompiler_Common/VarList.cpp@ 82

Last change on this file since 82 was 78, checked in by dai_9181, 18 years ago

CTypeDef → TypeDef
Houseクラスを追加。
オーバーロードレベルの種類を追加(レベル1に挿入)

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