VC:CFindReplaceDialog(非模态对话框、IsWindow()、m_fr、GetFindString())
1、新建:
if(pdlg!=NULL&&::IsWindow(pdlg->m_hWnd))
pdlg->ShowWindow(SW_SHOW);
else
{
pdlg=new CFindReplaceDialog();
pdlg->m_fr.Flags=pdlg->m_fr.Flags|FR_MATCHCASE|FR_WHOLEWORD;
}
if(!::IsWindow(pdlg->m_hWnd))
{
pdlg->Create(FALSE,"字符串","改变字符串");
pdlg->ShowWindow(SW_SHOW);
}
2、消息映射:
1)
//{{AFX_MSG(CDialogDlg)
afx_msg long OnFindReplace(WPARAM wParam,LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
2)
BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
//{{AFX_MSG_MAP(CDialogDlg)
ON_REGISTERED_MESSAGE(WM_FINDREPLACE,OnFindReplace)
//}}AFX_MSG_MAP
//
END_MESSAGE_MAP()
3、输出信息
CString message="";
if(pdlg->FindNext())
{
message+="查找下一个、\n\r";
}
message+="查找内容:";
message+=pdlg->GetFindString();
message+="\n\r";
message+="替换内容:";
message+=pdlg->GetReplaceString();
message+="\n\r";
AfxMessageBox(message);
return 0;