2 jujiawu1024 jujiawu1024 于 2016.02.12 22:43 提问

CFindReplaceDialog如何在MFC对话框的程序中使用啊

看了几篇文章代码,都实现不了,有没有谁做过这个功能的介绍下CFindReplaceDialog的详细用法?

3个回答

caozhy
caozhy   Ds   Rxr 2016.02.12 22:52
已采纳
    p_FindReplaceDlg = new CFindReplaceDialog();
    p_FindReplaceDlg->Create( true, m_FindString, NULL, FR_DOWN, this );    //创建查找对话框
    p_FindReplaceDlg->ShowWindow( SW_SHOW );    //显示对话框
 //查找替换对话框回调函数(响应对话框按钮消息)
LONG CEditTestView::OnFindReplace(WPARAM wParam,LPARAM lParam)
{
    if( p_FindReplaceDlg->IsTerminating() ) //关闭对话框
    {
        p_FindReplaceDlg = NULL;
        return 0;
    }
    m_FindString = p_FindReplaceDlg->GetFindString();       //查找串
    m_ReplaceString = p_FindReplaceDlg->GetReplaceString(); //替换串
    if( p_FindReplaceDlg->FindNext() )      //查找下一个
        FindNext();
    if( p_FindReplaceDlg->ReplaceCurrent() )    //替换
    {
        m_EditBox.EditReplace( m_ReplaceString );
        FindNext();
    }
    if( p_FindReplaceDlg->ReplaceAll() )    //全部替换
    {
        m_EditBox.SetSel(0);
        while( FindNext() )
            m_EditBox.EditReplace( m_ReplaceString );
    }

    return 1;
}
caozhy
caozhy   Ds   Rxr 2016.02.12 22:53

图片说明

qq_33967441
qq_33967441   2016.02.13 11:11

p_FindReplaceDlg = new CFindReplaceDialog();
p_FindReplaceDlg->Create( true, m_FindString, NULL, FR_DOWN, this ); //创建查找对话框
p_FindReplaceDlg->ShowWindow( SW_SHOW ); //显示对话框
//查找替换对话框回调函数(响应对话框按钮消息)
LONG CEditTestView::OnFindReplace(WPARAM wParam,LPARAM lParam)
{
if( p_FindReplaceDlg->IsTerminating() ) //关闭对话框
{
p_FindReplaceDlg = NULL;
return 0;
}
m_FindString = p_FindReplaceDlg->GetFindString(); //查找串
m_ReplaceString = p_FindReplaceDlg->GetReplaceString(); //替换串
if( p_FindReplaceDlg->FindNext() ) //查找下一个
FindNext();
if( p_FindReplaceDlg->ReplaceCurrent() ) //替换
{
m_EditBox.EditReplace( m_ReplaceString );
FindNext();
}
if( p_FindReplaceDlg->ReplaceAll() ) //全部替换
{
m_EditBox.SetSel(0);
while( FindNext() )
m_EditBox.EditReplace( m_ReplaceString );
}

return 1;

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!