void CFilesHashDlg::OnBnClickedFind() { // TODO: 在此添加控件通知处理程序代码 CFindDlg Find; Find.SetFindHash(_T("")); if(IDOK == Find.DoModal()) { m_strFindHash = Find.GetFindHash().Trim(); if(m_strFindHash.Compare(_T("")) != 0) { m_bFind = TRUE; // 进入搜索模式 m_btnClr.SetWindowText(MAINDLG_CLEAR_VERIFY); //m_editMain.SetWindowText(_T("")); m_editMain.SetWindowText(ResultFind(m_strFindFile, m_strFindHash)); //m_editMain.LineScroll(m_editMain.GetLineCount()); // 将文本框滚动到结尾 } } }
BOOL CHistDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if ( (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) && // If we hit a key and (pMsg->wParam == VK_F3) || ((pMsg->wParam == 0x46) && (GetKeyState(VK_CONTROL) & ~1) != 0) ) { dlgFind.m_EditText=&m_cstrhist; if (!bFindInUse) { dlgFind.Create(IDD_FIND_DIALOG); dlgFind.CenterWindow(); bFindInUse=TRUE; } dlgFind.BringWindowToTop(); dlgFind.ShowWindow(SW_SHOW); return TRUE; } return CDialog::PreTranslateMessage(pMsg); }
void CXMLTreeView::find() { CFindDlg findDlg; CString strStart; CString strEnd; BOOL isFind; if (findDlg.DoModal()==IDOK) { strStart = findDlg.m_strStart; strEnd = findDlg.m_strEnd; } CNodeManage *m_Manage = GetDocument()->m_pManage; //如果不为空的话 if (m_Manage) isFind = m_Manage->findNodes(strStart,strEnd); if (FALSE == isFind) MessageBox("Input Error,Not Found!"); else Invalidate(TRUE); }
bool CMainFrame::Find(CWaveProcess::FIND_SAMPLE_INFO& FindInfo, bool First) { if (m_View == NULL) return(FALSE); if (First) { // if initial find CFindDlg dlg; if (dlg.DoModal() != IDOK) // display find dialog return(FALSE); m_FindInfo.ChannelIdx = dlg.m_Channel; CWaveProcess::CSampleRange target = dlg.GetTargetRange(); m_FindInfo.TargetStart = target.Start; m_FindInfo.TargetEnd = target.End; m_FindInfo.StartFrame = m_View->GetIntNow(); // start searching from now m_FindInfo.Flags = 0; if (dlg.m_Wrap) m_FindInfo.Flags |= CWaveProcess::FIND_SAMPLE_INFO::WRAP; if (dlg.m_Match) m_FindInfo.Flags |= CWaveProcess::FIND_SAMPLE_INFO::INVERT; if (dlg.m_Dir) m_FindInfo.Flags |= CWaveProcess::FIND_SAMPLE_INFO::REVERSE; if (dlg.m_Unit == CWaveProcess::CConvert::DECIBELS) // if target in dB m_FindInfo.Flags |= CWaveProcess::FIND_SAMPLE_INFO::ABS_VAL; } else { // find next W64INT now = m_View->GetIntNow(); // if cursor still on previous matching frame if (now == m_FindInfo.MatchFrame) { if (m_FindInfo.Flags & CWaveProcess::FIND_SAMPLE_INFO::REVERSE) // if reverse m_FindInfo.StartFrame = now - 1; // start one sample before cursor else // forward m_FindInfo.StartFrame = now + 1; // start one sample after cursor } else // cursor was moved m_FindInfo.StartFrame = now; // start at cursor } if (!m_View->GetWave().FindSample(m_FindInfo)) // find matching sample return(FALSE); FindInfo = m_FindInfo; // return find info to caller return(TRUE); }
void CDebuggerView::OnDbFind() { CFindDlg dlg; dlg.DoModal(); ::SetFocus(m_editor.GetWindowHandle()); }
bool FindRoutine (const CObject * pObject, // passed back to callback routines CFindInfo & FindInfo, // details about find const InitiateSearch pInitiateSearch, // how to re-initiate a find const GetNextLine pGetNextLine) { CFindDlg dlg (FindInfo.m_strFindStringList); FindInfo.m_iStartColumn = -1; // return consistent column number // find what the heck the user wants to do if (!FindInfo.m_bAgain || FindInfo.m_strFindStringList.IsEmpty ()) { if (!FindInfo.m_strFindStringList.IsEmpty ()) dlg.m_strFindText = FindInfo.m_strFindStringList.GetHead (); dlg.m_bMatchCase = FindInfo.m_bMatchCase; dlg.m_bForwards = FindInfo.m_bForwards; dlg.m_strTitle = FindInfo.m_strTitle; dlg.m_bRegexp = FindInfo.m_bRegexp; if (dlg.DoModal () != IDOK) return false; FindInfo.m_bMatchCase = dlg.m_bMatchCase; FindInfo.m_bForwards = dlg.m_bForwards; FindInfo.m_bRegexp = dlg.m_bRegexp; // re-initiate the search - this will set up the POSITION parameter, if it wants to // we need to do it here to get the current line number for subsequent calculations (*pInitiateSearch) (pObject, FindInfo); // add find string to head of list, provided it is not empty, and not the same as before if (!dlg.m_strFindText.IsEmpty () && (FindInfo.m_strFindStringList.IsEmpty () || FindInfo.m_strFindStringList.GetHead () != dlg.m_strFindText)) FindInfo.m_strFindStringList.AddHead (dlg.m_strFindText); if (FindInfo.m_bForwards) FindInfo.m_nCurrentLine = 0; else FindInfo.m_nCurrentLine = FindInfo.m_nTotalLines - 1; FindInfo.m_bAgain = false; delete FindInfo.m_regexp; // get rid of earlier regular expression FindInfo.m_regexp = NULL; // compile regular expression if needed if (FindInfo.m_bRegexp ) FindInfo.m_regexp = new t_regexp (FindInfo.m_strFindStringList.GetHead (), (FindInfo.m_bMatchCase ? 0 : PCRE_CASELESS) | (FindInfo.m_bUTF8 ? PCRE_UTF8 : 0)); } // end of not repeating the last find else { // doing a "find again" - step past the line we were on if (FindInfo.m_bForwards) FindInfo.m_nCurrentLine++; else FindInfo.m_nCurrentLine--; // re-initiate the search - this will set up the POSITION parameter, if it wants to (*pInitiateSearch) (pObject, FindInfo); } // end of "find again" // if we have shuffled off the end of the buffer, say "not found" if (FindInfo.m_nCurrentLine < 0 || FindInfo.m_nCurrentLine >= FindInfo.m_nTotalLines) { // reset line pointer to a reasonable figure if (FindInfo.m_bForwards) FindInfo.m_nCurrentLine = 0; else FindInfo.m_nCurrentLine = FindInfo.m_nTotalLines - 1; return NotFound (FindInfo); } // re-initiate the search - this will set up the POSITION parameter, if it wants to // (*pInitiateSearch) (pObject, FindInfo); // loop until end of text, or text found CString strLine; CString strFindString = FindInfo.m_strFindStringList.GetHead (); CString strStatus = TFormat ("Finding: %s", (LPCTSTR) FindInfo.m_strFindStringList.GetHead ()); Frame.SetStatusMessageNow (strStatus); // find how many more lines we have to search long nToGo; if (FindInfo.m_bForwards) nToGo = FindInfo.m_nTotalLines - FindInfo.m_nCurrentLine; // from here to end else nToGo = FindInfo.m_nCurrentLine; // from here to start if (nToGo > 500) { FindInfo.m_pProgressDlg = new CProgressDlg; FindInfo.m_pProgressDlg->Create (); FindInfo.m_pProgressDlg->SetStatus (strStatus); FindInfo.m_pProgressDlg->SetRange (0, FindInfo.m_nTotalLines); FindInfo.m_pProgressDlg->SetWindowText (Translate ("Finding...")); } // end of having enough lines to warrant a progress bar // if case-insensitive search wanted, force "text to find" to lower case if (!FindInfo.m_bMatchCase) strFindString.MakeLower (); try { int iMilestone = 0; while (true) { // get the next line, return "not found" if end of text if ((*pGetNextLine) (pObject, FindInfo, strLine)) return NotFound (FindInfo); iMilestone++; // update progress control if (FindInfo.m_pProgressDlg && iMilestone > 31) // every 31 lines { iMilestone = 0; if (FindInfo.m_bForwards) FindInfo.m_pProgressDlg->SetPos (FindInfo.m_nCurrentLine); else FindInfo.m_pProgressDlg->SetPos (FindInfo.m_nTotalLines - FindInfo.m_nCurrentLine); if(FindInfo.m_pProgressDlg->CheckCancelButton()) { WrapUpFind (FindInfo); FindInfo.m_iStartColumn = -1; return false; } } // end of having a progress control // if text found on this line, then we have done it! if (FindInfo.m_bRegexp ) { if (FindInfo.m_regexp->Execute (strLine)) { // work out what column it must have been at FindInfo.m_regexp->GetWildcardOffsets (0, FindInfo.m_iStartColumn, FindInfo.m_iEndColumn); WrapUpFind (FindInfo); return true; // found it! } } // end of regular expression else { // not regular expression // if case-insensitive search wanted, force this line to lower case if (!FindInfo.m_bMatchCase) strLine.MakeLower (); if ((FindInfo.m_iStartColumn = strLine.Find (strFindString)) != -1) { // work out ending column FindInfo.m_iEndColumn = FindInfo.m_iStartColumn + FindInfo.m_strFindStringList.GetHead ().GetLength (); WrapUpFind (FindInfo); return true; // found it! } // end of found } // end of not regular expression // keep track of line count if (FindInfo.m_bForwards) FindInfo.m_nCurrentLine++; else FindInfo.m_nCurrentLine--; } // end of looping through each line } // end of try catch(CException* e) { e->ReportError (); e->Delete (); return NotFound (FindInfo); } } // end of FindRoutine