void RegisterWatcher::CreateChildren(HWND hWnd){ int ypos=0; int height=0, width=0; for(int i=REGWATCHER_AX; i<=REGWATCHER_IP; i++){ SingleRegWatcher* w=m_regWatchers[i]=new SingleRegWatcher(i); w->Create(hWnd); w->SetName(m_regNames[i]); SetWindowXY(w->GetHWND(), 0, ypos); height=w->WindowHeight(); width=w->WindowWidth(); ypos+=height; } SetWindowSize(hWnd, width, ypos+height); }
void ShiftWindow(HWND hwnd, HWND hwndHV) { POINT pt; RECT rect; // get the hexview's caret position in screen-coordinates HexView_GetCurCoord(hwndHV, &pt); ClientToScreen(hwndHV, &pt); GetWindowRect(hwnd, &rect); // see if the specified window overlaps the point if(PtInRect(&rect, pt)) { // which direction do we shift the window - it must be: // the least distance (up/down/left/right), that also // keeps the window contained within the same display int dx = 0, dy = 0; // get current monitor's display MONITORINFO mi = { sizeof(mi) }; GetMonitorInfo(MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST), &mi); /* if(pt.x - rect.left < rect.right-pt.x && rect.right + (pt.x - rect.left) +32 < mi.rcWork.right) dx = pt.x - rect.left + 32; else dx = pt.x - rect.right - 32;*/ if(pt.y - rect.top < rect.bottom - pt.y && rect.bottom + (pt.y - rect.top) + 32 < mi.rcWork.bottom) dy = pt.y - rect.top + 32; else dy = pt.y - rect.bottom - 32; //if(pt.y - rect.top < rect.right-pt.x) // ; SetWindowXY(hwnd, rect.left + dx, rect.top + dy, NULL); } }
INT_PTR CALLBACK SearchDlg(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { NMHDR *nmhdr; static BOOL fMouseDown = FALSE; static POINT ptLastPos; static BOOL fFirstTime = TRUE; HWND hwndCombo; HWND hwndHV = g_hwndHexView; switch(msg) { case WM_INITDIALOG: AddSearchTabs(hwnd); // text (UTF8/UTF16/UTF32) hwndCombo = GetDlgItem(g_hwndFindPane[1], IDC_COMBO_DATATYPE); AddSearchTypes(hwndCombo, SEARCHTYPE_ASCII, SEARCHTYPE_UTF32, 0); //AddComboStrings(g_hwndFindPane[1], IDC_COMBO_DATATYPE, szTextNames); // numbers (byte/word/dword/float/double) hwndCombo = GetDlgItem(g_hwndFindPane[2], IDC_COMBO_DATATYPE); AddSearchTypes(hwndCombo, SEARCHTYPE_BYTE, SEARCHTYPE_DOUBLE, 0); //AddComboStrings(g_hwndFindPane[2], IDC_COMBO_DATATYPE, szNumberNames); // replace (everything) hwndCombo = GetDlgItem(g_hwndFindPane[3], IDC_COMBO_DATATYPE); AddSearchTypes(hwndCombo, SEARCHTYPE_HEX, SEARCHTYPE_HEX, 0); AddSearchTypes(hwndCombo, SEARCHTYPE_ASCII, SEARCHTYPE_UTF32, 0); AddSearchTypes(hwndCombo, SEARCHTYPE_BYTE, SEARCHTYPE_DOUBLE, 0); //AddComboStrings(g_hwndFindPane[3], IDC_COMBO3, szHexNames); //AddComboStrings(g_hwndFindPane[3], IDC_COMBO3, szTextNames); //AddComboStrings(g_hwndFindPane[3], IDC_COMBO3, szNumberNames); if(fFirstTime) { CenterWindow(hwnd); fFirstTime = FALSE; } else { SetWindowXY(hwnd, ptLastPos.x, ptLastPos.y, NULL); } return FALSE; //case WM_SETFOC case WM_NOTIFY: nmhdr = (NMHDR *)lParam; if(nmhdr->code == TCN_SELCHANGE) { nCurrentFindTab = TabCtrl_GetCurSel(nmhdr->hwndFrom); SetFindTab(hwnd, nCurrentFindTab, fMouseDown); return TRUE; } else if(nmhdr->code == TCN_SELCHANGING) { fMouseDown = (GetKeyState(VK_LBUTTON) & 0x80000000) ? TRUE : FALSE; } else if(nmhdr->code == NM_RELEASEDCAPTURE) { fMouseDown = FALSE; } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: DestroyWindow(hwnd); return TRUE; case IDC_REPLACE: Replace(GetCurFindTab(hwnd), hwndHV); return TRUE; case IDC_REPLACEALL: return TRUE; case IDOK: Find(GetCurFindTab(hwnd), hwndHV); return TRUE; } return TRUE; case WM_MOVE: { RECT rect; GetWindowRect(hwnd, &rect); ptLastPos.x = rect.left;//(short)LOWORD(lParam); ptLastPos.y = rect.top;//(short)HIWORD(lParam); } return TRUE; case WM_CLOSE: DestroyWindow(hwnd); return TRUE; case WM_DESTROY: g_hwndSearch = 0; return TRUE; } return FALSE; }