void SetFindTab(HWND hwndFindDlg, int idx, BOOL fMouseActivated) { int i; HWND hwndPanel; SEARCH_PANE_STATE *sps; TabCtrl_SetCurSel(GetDlgItem(hwndFindDlg, IDC_TAB1), idx); // find the current (new) pane and update is state hwndPanel = g_hwndFindPane[idx]; sps = (SEARCH_PANE_STATE *)GetWindowLongPtr(hwndPanel, GWLP_USERDATA); UpdateFindGui(hwndPanel, sps); // display! SetWindowPos(g_hwndFindPane[idx], HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW); // was the mouse used to activate this tab? if(fMouseActivated) { SetDlgItemFocus(hwndPanel, IDC_COMBO1); PostMessage(hwndPanel, WM_NEXTDLGCTL, IDC_COMBO1, TRUE); } // hide any other search-pane for(i = 0; i < MAX_FIND_PANES; i++) { if(i != idx) { DelStyle(g_hwndFindPane[i], WS_VISIBLE); //ShowWindow(g_hwndFindPane[i], SW_HIDE); } } // hide the replace/replaceall buttons if necessary EnableDlgItem(hwndFindDlg, IDC_REPLACE, (BOOL)(idx == 3)); EnableDlgItem(hwndFindDlg, IDC_REPLACEALL, (BOOL)(idx == 3)); SetDlgItemFocus(g_hwndFindPane[idx], IDC_COMBO1); PostMessage(g_hwndFindPane[idx], WM_NEXTDLGCTL, IDC_COMBO1, TRUE); PostMessage(g_hwndFindPane[idx], WM_COMMAND, MAKEWPARAM(IDC_COMBO1, CBN_EDITUPDATE), 0); }
BOOL Find(HWND hwnd, HWND hwndHV) { TCHAR szText[MAX_SEARCH_TEXT]; int i; SEARCH_PANE_STATE *sps = (SEARCH_PANE_STATE *)GetWindowLongPtr(hwnd, GWLP_USERDATA); GetDlgItemText(hwnd, IDC_COMBO1, szText, MAX_SEARCH_TEXT); for(i = 0; i < sps->nHistoryCount1; i++) { if(lstrcmp(sps->history1[i].szText, szText) == 0) break; } if(i == sps->nHistoryCount1 && i < HISTORY_MAX) { int idx; lstrcpyn(sps->history1[i].szText, szText, HISTORY_LEN); sps->history1[i].nDataTypeIdx = (int)SendDlgItemMessage(hwnd, IDC_COMBO_DATATYPE, CB_GETCURSEL, 0, 0); sps->nHistoryCount1++; idx = (int)SendDlgItemMessage(hwnd, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)szText); SendDlgItemMessage(hwnd, IDC_COMBO1, CB_SETITEMDATA, idx, sps->history1[i].nDataTypeIdx); } // get the search data! searchLen = sizeof(searchData); //Update(hwnd, sps, searchData, &searchLen); searchValid = UpdateSearchDataDlg(hwnd, IDC_COMBO1, g_fBigEndian, searchData, &searchLen); if(searchValid == FALSE) { HexErrorBox(TEXT("%s"), TEXT("Invalid search data - select Data Type")); SetDlgItemFocus(hwnd, IDC_COMBO1); return FALSE; } HexView_FindInit(hwndHV, searchData, searchLen); HexView_SetSearchPattern(hwndHV, searchData, searchLen); FindNext(); if(!g_fKeepVisible) DestroyWindow(hwnd); return TRUE; }
BOOL COpenView::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_SYSKEYDOWN) { if (::GetAsyncKeyState(VK_MENU)) { UINT id = 0; switch (pMsg->wParam) { case '1': id = IDC_PATH0_COMBO; goto LABEL_NUM_KEY; case '2': id = IDC_PATH1_COMBO; goto LABEL_NUM_KEY; case '3': id = IDC_PATH2_COMBO; LABEL_NUM_KEY: SetDlgItemFocus(id); return TRUE; case 's': case 'S': id = IDC_SELECT_UNPACKER; PostMessage(WM_COMMAND, id, 0); return TRUE; } } } return CFormView::PreTranslateMessage(pMsg); }
/** * @brief Initialize dialog. * @return Always TRUE. */ BOOL SaveClosingDlg::OnInitDialog() { CTrDialog::OnInitDialog(); SetDlgItemFocus(IDC_SAVECLOSING_SAVELEFT); if (!m_bAskForLeft) { // Left items disabled move focus to middle side items SetDlgItemFocus(IDC_SAVECLOSING_SAVEMIDDLE); EnableDlgItem(IDC_SAVECLOSING_LEFTFRAME, false); EnableDlgItem(IDC_SAVECLOSING_LEFTFILE, false); EnableDlgItem(IDC_SAVECLOSING_SAVELEFT, false); EnableDlgItem(IDC_SAVECLOSING_DISCARDLEFT, false); } if (!m_bAskForMiddle) { // Middle items disabled move focus to right side items if (!m_bAskForLeft) SetDlgItemFocus(IDC_SAVECLOSING_SAVERIGHT); EnableDlgItem(IDC_SAVECLOSING_MIDDLEFRAME, false); EnableDlgItem(IDC_SAVECLOSING_MIDDLEFILE, false); EnableDlgItem(IDC_SAVECLOSING_SAVEMIDDLE, false); EnableDlgItem(IDC_SAVECLOSING_DISCARDMIDDLE, false); } if (!m_bAskForRight) { EnableDlgItem(IDC_SAVECLOSING_RIGHTFRAME, false); EnableDlgItem(IDC_SAVECLOSING_RIGHTFILE, false); EnableDlgItem(IDC_SAVECLOSING_SAVERIGHT, false); EnableDlgItem(IDC_SAVECLOSING_DISCARDRIGHT, false); } if (m_bDisableCancel) { EnableDlgItem(IDCANCEL, false); } // setup handler for resizing this dialog m_constraint.InitializeCurrentSize(this); // configure how individual controls adjust when dialog resizes m_constraint.ConstrainItem(IDC_SAVECLOSING_LEFTFRAME, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_LEFTFILE, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_SAVELEFT, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_DISCARDLEFT, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_MIDDLEFRAME, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_MIDDLEFILE, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_SAVEMIDDLE, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_DISCARDMIDDLE, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_RIGHTFRAME, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_RIGHTFILE, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_SAVERIGHT, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_SAVECLOSING_DISCARDRIGHT, 0, 1, 0, 0); // grows right // IDC_SAVECLOSING_DISCARDALL doesn't move m_constraint.ConstrainItem(IDOK, 1, 0, 0, 0); // slides right m_constraint.ConstrainItem(IDCANCEL, 1, 0, 0, 0); // slides right m_constraint.DisallowHeightGrowth(); m_constraint.SubclassWnd(); // install subclassing m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("SaveClosingDlg"), false); // persist size via registry return FALSE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should 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; }