INT_PTR CALLBACK HighlightDlgProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { static BOOL fMask = FALSE; static HWND hwndHV; size_w offset, length; BOOKMARK bm = {0}; static TCHAR title[100]; static TCHAR text[200]; static int count; static HBOOKMARK hbm; switch (iMsg) { case WM_INITDIALOG: hwndHV = GetActiveHexView(GetParent(hwnd)); // GetOwner(hwnd);// SendDlgItemMessage(hwnd, IDC_NAME, EM_SETCUEBANNER, TRUE, (LPARAM)TEXT("Enter some descriptive text here")); SendDlgItemMessage(hwnd, IDC_ANNOTATION, EM_SETCUEBANNER, 0, (LPARAM)TEXT("Enter some descriptive text here")); //MakeColourCombo(GetDlgItem(hwnd, IDC_COMBO1), fgcollist, fgtextlist, 16); MakeColourCombo(GetDlgItem(hwnd, IDC_COMBO4), bgcollist, bgtextlist, 16); hbm = (HBOOKMARK)lParam; if(hbm == 0) { HexView_GetSelStart(hwndHV, &offset); HexView_GetSelSize(hwndHV, &length); wsprintf(title, TEXT("bookmark-%03d"), ++count); //lstrcpy(title, TEXT(""));//TEXT("Enter some descriptive text here")); lstrcpy(text, TEXT(""));//TEXT("Enter some descriptive text here")); } else { HBOOKMARK hbm = (HBOOKMARK)lParam; BOOKMARK bm; HexView_GetBookmark(hwndHV, hbm, &bm); offset = bm.offset; length = bm.length; lstrcpy(title, bm.pszTitle); lstrcpy(text, bm.pszText); // Set the selected color for (int i = 0; i < 16; i++) { if (bm.backcol == bgcollist[i]) { SendMessage(GetDlgItem(hwnd, IDC_COMBO4), CB_SETCURSEL, i, 0); break; } } } SetDlgItemBaseInt(hwnd, IDC_OFFSET, offset, 16, 1); SetDlgItemBaseInt(hwnd, IDC_LENGTH, length, 16, 1); SetDlgItemText(hwnd, IDC_NAME, title); SetDlgItemText(hwnd, IDC_ANNOTATION, text); //ClientToScreen(hwndParent, &pt); //GetCursorPos(&pt); //SetWindowPos(hwnd, 0, pt.x, pt.y, 0, 0, SWP_NOSIZE); CenterWindow(hwnd); return TRUE; case WM_CLOSE: EndDialog(hwnd, FALSE); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: GetDlgItemText(hwnd, IDC_ANNOTATION, text, 200); GetDlgItemText(hwnd, IDC_NAME, title, 100); bm.col = 0; bm.backcol = GetColourComboRGB(GetDlgItem(hwnd, IDC_COMBO4));//RGB(rand()+128, rand()+128, rand()+128);//0xffffff; bm.pszText = text; bm.pszTitle = title; bm.offset = GetDlgItemBaseInt(hwnd, IDC_OFFSET, 16); bm.length = GetDlgItemBaseInt(hwnd, IDC_LENGTH, 16); if(hbm == 0) { HexView_AddBookmark(hwndHV, &bm); } else { HexView_SetBookmark(hwndHV, hbm, &bm); } // DockWnd_UpdateContent(g_hwndMain, DWID_HIGHLIGHT); ///UpdateHighlights(hwndHV, hwndGridView); EndDialog(hwnd, TRUE); return 0; case IDCANCEL: EndDialog(hwnd, FALSE); return 0; default: return FALSE; } default: break; } return FALSE; }
INT_PTR CALLBACK ModifyDlgProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { static size_w len; HWND hwndHV = GetActiveHexView(g_hwndMain); static BOOL fHexLength = FALSE; static int nLastOperand = 0; static int nLastOperation = 0; static BOOL fBigEndian = FALSE; int basetype; static const int SearchTypeFromBaseType[] = { SEARCHTYPE_BYTE, SEARCHTYPE_WORD, SEARCHTYPE_DWORD, SEARCHTYPE_QWORD, SEARCHTYPE_BYTE, SEARCHTYPE_WORD, SEARCHTYPE_DWORD, SEARCHTYPE_QWORD, SEARCHTYPE_FLOAT, SEARCHTYPE_DOUBLE, }; switch (iMsg) { case WM_INITDIALOG: AddComboStringList(GetDlgItem(hwnd, IDC_MODIFY_DATATYPE), szTypeList, 0); AddComboStringList(GetDlgItem(hwnd, IDC_MODIFY_OPERATION), szOpList, nLastOperation); SetDlgItemBaseInt(hwnd, IDC_MODIFY_OPERAND, nLastOperand, fHexLength ? 16 : 10, FALSE); CheckDlgButton(hwnd, IDC_HEX, fHexLength ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_ENDIAN, fBigEndian ? BST_CHECKED : BST_UNCHECKED); //len = HexView_GetSelSize(hwndHV); //SetDlgItemBaseInt(hwnd, IDC_MODIFY_NUMBYTES, len, fHexLength ? 16 : 10, FALSE); CenterWindow(hwnd); return TRUE; case WM_CLOSE: EndDialog(hwnd, FALSE); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_MODIFY_OPERATION: case IDC_MODIFY_OPERAND: case IDC_MODIFY_NUMBYTES: nLastOperation = (int)SendDlgItemMessage(hwnd, IDC_MODIFY_OPERATION, CB_GETCURSEL, 0, 0); nLastOperand = (int)GetDlgItemBaseInt(hwnd, IDC_MODIFY_OPERAND, fHexLength ? 16 : 10); len = GetDlgItemBaseInt(hwnd, IDC_MODIFY_NUMBYTES, fHexLength ? 16 : 10); return TRUE; case IDC_ENDIAN: fBigEndian = IsDlgButtonChecked(hwnd, IDC_ENDIAN); return TRUE; case IDC_HEX: fHexLength = IsDlgButtonChecked(hwnd, IDC_HEX); /* len = HexView_GetSelSize(hwndHV); SetDlgItemBaseInt(hwnd, IDC_MODIFY_NUMBYTES, len, fHexLength ? 16 : 10, FALSE); */ SetDlgItemBaseInt(hwnd, IDC_MODIFY_OPERAND, nLastOperand, fHexLength ? 16 : 10, FALSE); SendDlgItemMessage(hwnd, IDC_MODIFY_OPERAND, EM_SETSEL, 0, -1); SetDlgItemFocus(hwnd, IDC_MODIFY_OPERAND); return TRUE; case IDOK: // get the basetype we are using basetype = (int)SendDlgItemMessage(hwnd, IDC_INSERT_DATATYPE, CB_GETCURSEL, 0, 0); basetype = SearchTypeFromBaseType[basetype]; // get the operand in raw-byte format, ensure it is always little-endian // as we must do these calculations using the native byte ordering format operandLen = sizeof(operandData); UpdateSearchData(GetDlgItem(hwnd, IDC_MODIFY_OPERAND), basetype, FALSE, operandData, &operandLen); HexView_GetSelSize(hwndHV, &len); ModifyHexViewData(hwndHV, nLastOperation, operandData, len, basetype, fBigEndian); EndDialog(hwnd, TRUE); return TRUE; case IDCANCEL: EndDialog(hwnd, FALSE); return TRUE; default: return FALSE; } case WM_HELP: return HandleContextHelp(hwnd, lParam, IDD_TRANSFORM); default: break; } return FALSE; }