void RefreshData(DEBUG_INFO *dbg_info, VARINFO *var) { while (var) { WatchValue(dbg_info, var->value, var, FALSE); RefreshData(dbg_info, var->subtype); var = var->link; } }
static void RefreshData(DEBUG_INFO *dbg_info, VARINFO *var, BOOL adding) { while (var) { char localbf[256]; if (!adding) strcpy(localbf, var->value); if ((var->lref || var->rref) && var->type < eReservedTop && var->type > eVoid) { VARINFO q = *var; q.pointer = q.rref = q.lref = 0; if (!ReadValue(var->address, &q.address, 4, var)) { sprintf(var->value, "REFERENCE: <UNKNOWN>"); } else { WatchValue(dbg_info, var->value, &q, FALSE); } } else { RefreshData(dbg_info, var->subtype, adding); WatchValue(dbg_info, var->value, var, FALSE); } if (!adding && strcmp(localbf, var->value)) { var->watchhead.col2Color = 0xff; } else { var->watchhead.col2Color = 0; } var = var->link; } }
LRESULT CALLBACK WatchWndProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { static int selected; static POINT menupos; static char buf[256]; RECT r, *pr; WINDOWPOS wp; HD_ITEM hie; HD_LAYOUT hdl; NMHDR *h; DRAWITEMSTRUCT *dr; HBITMAP hbmp; HDC hMemDC; TCHeader tch; TV_ITEM item; TV_INSERTSTRUCT t; static int sizingbottom; int offset; DEBUG_INFO *dbg; NM_TREEVIEW *nmt; VARINFO *var; HWND win; int level; int offset1; int doit; int i; CHARRANGE charrange; switch (iMessage) { case WM_SYSCOMMAND: if (wParam == SC_CLOSE) { PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; } break; case WM_NOTIFY: h = (NMHDR*)lParam; switch (h->code) { case TABN_SELECTED: { LSTABNOTIFY *p = (LSTABNOTIFY *)h; ShowWindow(hwndTree[selected], SW_HIDE); for (i=0; i < 4; i++) if (p->lParam == (LPARAM)hwndTree[i]) selected = i; ShowWindow(hwndTree[selected], SW_SHOW); break; } case NM_RCLICK: { HMENU menu = LoadMenuGeneric(hInstance, "WATCHMENU"); HMENU popup = GetSubMenu(menu, 0); InsertBitmapsInMenu(popup); GetCursorPos(&menupos); TrackPopupMenuEx(popup, TPM_BOTTOMALIGN | TPM_LEFTBUTTON, menupos.x, menupos.y, hwndFrame, NULL); DestroyMenu(menu); SetFocus(hwndTree[selected]); } return 0; case TVN_ITEMEXPANDING: nmt = h; if (nmt->action) { ExpandPointer((VARINFO*)nmt->itemNew.lParam, nmt->action, selected); } return 0; case TCN_EDITQUERY: nmt = h; item.mask = TVIF_PARAM; item.hItem = (HTREEITEM)nmt->itemNew.hItem; TreeView_GetItem(hwndTree[selected], &item); var = (VARINFO*)item.lParam; if (var->editable) { WatchValue(watchinfo_list[selected][var->watchindex].dbg_info, buf, var, TRUE); return buf; } return 0; case TCN_EDITDONE: nmt = h; item.mask = TVIF_PARAM; item.hItem = (HTREEITEM)nmt->itemNew.hItem; TreeView_GetItem(hwndTree[selected], &item); var = (VARINFO*)item.lParam; ChangeData(var, nmt->itemNew.pszText, selected); RefreshItems(selected); return 0; } break; case WM_CREATE: hwndWatch = hwnd; GetClientRect(hwnd, &r); valueBitmap = LoadImage(hInstance, "ID_VALUEBMP", IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); itemBitmap = LoadImage(hInstance, "ID_ITEMBMP", IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); tch.colText1 = "Item"; tch.colText2 = "Value"; tch.colBmp1 = itemBitmap; tch.colBmp2 = valueBitmap; hwndTabCtrl = CreateLsTabWindow(hwnd, TABS_BOTTOM | TABS_HOTTRACK | TABS_FLAT | WS_VISIBLE); tabNormalFont = CreateFontIndirect(&tabFontData); SendMessage(hwndTabCtrl, WM_SETFONT, (WPARAM)tabNormalFont, 0); r.bottom -= 25; for (i=3; i >0 ; i--) hwndTree[i] = CreateextTreeWindow(hwnd, WS_DLGFRAME | TCS_LINE, &r, &tch); hwndTree[0] = CreateextTreeWindow(hwnd, WS_DLGFRAME | TCS_LINE | WS_VISIBLE, &r, &tch); for (i=3; i >=0 ; i--) SendMessage(hwndTabCtrl, TABM_ADD, (WPARAM)nameTags[i], (LPARAM)hwndTree[i]); return 0; case WM_ADDWATCHINDIRECT: win = (HWND)wParam; doit = FALSE; SendMessage(win, EM_EXGETSEL, (WPARAM)0, (LPARAM) &charrange); if (charrange.cpMin == charrange.cpMax) { doit = SendMessage(win, WM_WORDUNDERPOINT, (WPARAM)&rightclickPos, (LPARAM)buf); if (!doit) { SendMessage(hwndFrame, IDM_ADDWATCH, 0, 0); break; } } else { if (charrange.cpMax - charrange.cpMin < sizeof(buf)) { SendMessage(win, EM_GETSELTEXT, 0, (LPARAM)buf); doit = TRUE ; } } if (doit) { var = EvalExpr(&dbg, activeScope, (char*) buf, TRUE); if (var) { AddItem(dbg, var, activeScope->address, selected); dmgrHideWindow(DID_WATCHWND, FALSE); break ; } } ExtendedMessageBox("Error", MB_SETFOREGROUND | MB_SYSTEMMODAL, "Symbol does not exist in this scope"); break; case WM_ADDWATCH: offset = wParam; if (!offset) { DeleteAllItems(selected); } else { var = EvalExpr(&dbg, activeScope, (char*) lParam, TRUE); if (var) { AddItem(dbg, var, activeScope->address, selected); dmgrHideWindow(DID_WATCHWND, FALSE); } } break; case WM_COMMAND: switch (wParam) { case ID_SETADDRESS: for (i=3; i >=0; i--) RefreshItems(i); InvalidateRect(hwndTree[selected], 0, 0); break; case IDM_DELETEWATCH: DeleteItem(&menupos, selected); break; case IDM_DELETEALLWATCH: DeleteAllItems(selected); break; } break; case WM_DESTROY: for (i=3; i >=0 ; i--) TreeView_DeleteAllItems(hwndTree[i]); for (i=3; i >=0 ; i--) DestroyWindow(hwndTree[i]); DeleteObject(valueBitmap); DeleteObject(itemBitmap); hwndWatch = 0; break; case WM_SIZE: r.left = 0; r.right = LOWORD(lParam); r.top = 0; r.bottom = HIWORD(lParam); MoveWindow(hwndTabCtrl, r.left, r.bottom - 24, r.right - r.left, 24, 1); for (i=3; i >=0 ; i--) MoveWindow(hwndTree[i], r.left, r.top, r.right - r.left, r.bottom - r.top - 25, 0); return 0; case WM_CLOSE: break; case WM_ACTIVATEME: SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0); break; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }
LRESULT CALLBACK WatchWndProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { WATCHDATA *ptr; static POINT menupos; static char buf[256]; RECT r, *pr; WINDOWPOS wp; HD_ITEM hie; HD_LAYOUT hdl; NMHDR *h; DRAWITEMSTRUCT *dr; HBITMAP hbmp; HDC hMemDC; TCHeader tch; TV_ITEM item; TV_INSERTSTRUCT t; static int sizingbottom; int offset; DEBUG_INFO *dbg; NM_TREEVIEW *nmt; VARINFO *var; HWND win; int level; int offset1; int doit; int i; CHARRANGE charrange; switch (iMessage) { case WM_SYSCOMMAND: if (wParam == SC_CLOSE) { PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; } break; case WM_NOTIFY: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); h = (NMHDR*)lParam; switch (h->code) { case NM_RCLICK: { if (ptr->DID != DID_LOCALSWND) { HMENU menu = LoadMenuGeneric(hInstance, "WATCHMENU"); HMENU popup = GetSubMenu(menu, 0); TV_HITTESTINFO t; HTREEITEM titem; GetCursorPos(&t.pt); ScreenToClient(ptr->hwndWatchTree, &t.pt); titem = TreeView_HitTest(ptr->hwndWatchTree, &t); if (!titem || TreeView_GetParent(ptr->hwndWatchTree, titem)) { EnableMenuItem(popup, IDM_DELETEWATCH, MF_GRAYED); } InsertBitmapsInMenu(popup); GetCursorPos(&menupos); TrackPopupMenuEx(popup, TPM_BOTTOMALIGN | TPM_LEFTBUTTON, menupos.x, menupos.y, hwndFrame, NULL); DestroyMenu(menu); lastWatch = ptr->DID; } SetFocus(ptr->hwndWatchTree); } return 0; case TVN_ITEMEXPANDING: nmt = (LPNMTREEVIEW)h; if (nmt->action) { ExpandPointer((VARINFO*)nmt->itemNew.lParam, nmt->action, ptr); } return 0; case TCN_EDITQUERY: nmt = (LPNMTREEVIEW)h; item.mask = TVIF_PARAM; item.hItem = (HTREEITEM)nmt->itemNew.hItem; TreeView_GetItem(ptr->hwndWatchTree, &item); var = (VARINFO*)item.lParam; if (var->editable) { WatchValue(ptr->watchinfo_list[var->watchindex].dbg_info, buf, var, TRUE); return buf; } return 0; case TCN_EDITDONE: nmt = (LPNMTREEVIEW)h; item.mask = TVIF_PARAM; item.hItem = (HTREEITEM)nmt->itemNew.hItem; TreeView_GetItem(ptr->hwndWatchTree, &item); var = (VARINFO*)item.lParam; ChangeData(var, nmt->itemNew.pszText, ptr); RefreshItems(ptr); return 0; } break; case WM_CREATE: ptr = (WATCHDATA *)calloc(sizeof(WATCHDATA),1); SetWindowLong(hwnd, 0, (long)ptr); GetClientRect(hwnd, &r); tch.colText1 = "Item"; tch.colText2 = "Value"; tch.colBmp1 = itemBitmap; tch.colBmp2 = valueBitmap; ptr->hwndWatchTree = CreateextTreeWindow(hwnd, WS_DLGFRAME | TCS_LINE | WS_VISIBLE, &r, &tch); return 0; case WM_ADDWATCHINDIRECT: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); win = (HWND)wParam; doit = FALSE; SendMessage(win, EM_EXGETSEL, (WPARAM)0, (LPARAM) &charrange); if (charrange.cpMin == charrange.cpMax) { doit = SendMessage(win, WM_WORDUNDERPOINT, (WPARAM)&rightclickPos, (LPARAM)buf); if (!doit) { PostMessage(hwndFrame, WM_COMMAND, IDM_ADDWATCH, 0); break; } } else { if (charrange.cpMax - charrange.cpMin < sizeof(buf) ||charrange.cpMin - charrange.cpMax < sizeof(buf)) { SendMessage(win, EM_GETSELTEXT, 0, (LPARAM)buf); doit = TRUE ; } } if (doit) { var = EvalExpr(&dbg, activeScope, (char*) buf, TRUE); if (var) { AddItem(dbg, var, activeScope->address, ptr); SelectWindow(ptr->DID); break ; } } ExtendedMessageBox("Error", MB_SETFOREGROUND | MB_SYSTEMMODAL, "Symbol does not exist in this scope"); break; case WM_ADDWATCH: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); offset = wParam; if (!offset) { DeleteAllItems(ptr); } else { var = EvalExpr(&dbg, activeScope, (char*) lParam, TRUE); if (var) { AddItem(dbg, var, activeScope->address, ptr); SelectWindow(ptr->DID); } } break; case WM_INITIALSTACK: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); ptr->refreshNeeded = TRUE; break; case WM_COMMAND: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); switch (wParam) { case ID_SETADDRESS: if (ptr->DID == DID_LOCALSWND) LoadLocals(ptr); if (ptr->refreshNeeded) ReloadVars(ptr); else RefreshItems(ptr); ptr->refreshNeeded = FALSE; InvalidateRect(ptr->hwndWatchTree, 0, 0); break; case IDM_DELETEWATCH: DeleteItem(&menupos, ptr); break; case IDM_DELETEALLWATCH: DeleteAllItems(ptr); break; } break; case WM_DESTROY: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); TreeView_DeleteAllItems(ptr->hwndWatchTree); DestroyWindow(ptr->hwndWatchTree); DeleteObject(valueBitmap); DeleteObject(itemBitmap); break; case WM_SIZE: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); r.left = 0; r.right = LOWORD(lParam); r.top = 0; r.bottom = HIWORD(lParam); MoveWindow(ptr->hwndWatchTree, r.left, r.top, r.right - r.left, r.bottom - r.top, 0); return 0; case WM_CLOSE: break; case WM_ACTIVATEME: ptr = (WATCHDATA *)GetWindowLong(hwnd, 0); if (ptr->DID != DID_LOCALSWND) lastWatch = ptr->DID; SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0); break; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }