Exemple #1
0
BOOL CEditView::InitializeReplace()
	// helper to do find first if no selection
{
	ASSERT_VALID(this);

	_AFX_EDIT_STATE* pEditState = _afxEditState;

	// do find next if no selection
	int nStartChar, nEndChar;
	GetEditCtrl().GetSel(nStartChar, nEndChar);
	if (nStartChar == nEndChar)
	{
		if (!FindText(pEditState->strFind, pEditState->bNext,
			pEditState->bCase))
		{
			// text not found
			OnTextNotFound(pEditState->strFind);
		}
		return FALSE;
	}

	if (!SameAsSelected(pEditState->strFind, pEditState->bCase))
	{
		if (!FindText(pEditState->strFind, pEditState->bNext,
			pEditState->bCase))
		{
			// text not found
			OnTextNotFound(pEditState->strFind);
		}
		return FALSE;
	}

	ASSERT_VALID(this);
	return TRUE;
}
void CEditView::OnEditRepeat()
/****************************/
{
    if( !FindText( _afxEditState->strFind, _afxEditState->bNext,
                   _afxEditState->bCase ) ) {
        OnTextNotFound( _afxEditState->strFind );
    }
}
Exemple #3
0
void CEditView::OnFindNext(LPCTSTR lpszFind, BOOL bNext, BOOL bCase)
{
	ASSERT_VALID(this);
	_AFX_EDIT_STATE* pEditState = _afxEditState;
	pEditState->strFind = lpszFind;
	pEditState->bCase = bCase;
	pEditState->bNext = bNext;

	if (!FindText(pEditState->strFind, bNext, bCase))
		OnTextNotFound(pEditState->strFind);
	ASSERT_VALID(this);
}
Exemple #4
0
void CEditView::OnEditRepeat()
{
	ASSERT_VALID(this);
	_AFX_EDIT_STATE* pEditState = _afxEditState;
	if (!FindText(pEditState->strFind,
		pEditState->bNext,
		pEditState->bCase))
	{
		OnTextNotFound(pEditState->strFind);
	}
	ASSERT_VALID(this);
}
void CEditView::OnFindNext( LPCTSTR lpszFind, BOOL bNext, BOOL bCase )
/********************************************************************/
{
    _AFX_EDIT_STATE *pState = _afxEditState.GetData();
    ASSERT( pState != NULL );
    
    pState->strFind = lpszFind;
    pState->bNext = bNext;
    pState->bCase = bCase;
    
    if( !FindText( lpszFind, bNext, bCase ) ) {
        OnTextNotFound( lpszFind );
    }
}
void CEditView::OnReplaceAll( LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bCase )
/*******************************************************************************/
{
    _AFX_EDIT_STATE *pState = _afxEditState.GetData();
    ASSERT( pState != NULL );
    
    pState->strFind = lpszFind;
    pState->strReplace = lpszReplace;
    pState->bCase = bCase;
    
    if( !FindText( lpszFind, TRUE, bCase ) ) {
        OnTextNotFound( lpszFind );
    } else {
        ::SendMessage( m_hWnd, EM_REPLACESEL, TRUE, (LPARAM)lpszReplace );
        while( FindText( lpszFind, TRUE, bCase ) ) {
            ::SendMessage( m_hWnd, EM_REPLACESEL, TRUE, (LPARAM)lpszReplace );
        }
    }
}
void CMyRichEditView::OnReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, 
   BOOL bCase, BOOL bWord)
{
   CWaitCursor wait;
   // no selection or different than what we are looking for
   if (!FindText(lpszFind, bCase, bWord))
   {
      OnTextNotFound(lpszFind);
      return;
   }

   GetRichEditCtrl().HideSelection(TRUE, FALSE);
   m_nNumReplaced = 0;
   do
   {
      GetRichEditCtrl().ReplaceSel(lpszReplace);
      m_nNumReplaced++;  // Record the number of replacements

   } while (FindTextSimple(lpszFind));
   GetRichEditCtrl().HideSelection(FALSE, FALSE);
}
void CEditView::OnReplaceSel( LPCTSTR lpszFind, BOOL bNext, BOOL bCase,
                              LPCTSTR lpszReplace )
/*************************************************/
{
    _AFX_EDIT_STATE *pState = _afxEditState.GetData();
    ASSERT( pState != NULL );
    
    pState->strFind = lpszFind;
    pState->bNext = bNext;
    pState->bCase = bCase;
    pState->strReplace = lpszReplace;
    
    CString strSelection;
    GetSelectedText( strSelection );
    if( (bCase && strSelection.Compare( lpszFind ) != 0) ||
        (!bCase && strSelection.Compare( lpszFind ) != 0) ) {
        if( !FindText( lpszFind, bNext, bCase ) ) {
            OnTextNotFound( lpszFind );
            return;
        }
    }
    ::SendMessage( m_hWnd, EM_REPLACESEL, TRUE, (LPARAM)lpszReplace );
    FindText( lpszFind, bNext, bCase );
}