首先在主对话框注册消息
添加消息
class CMainFrame : public CFrameWnd
{
static const UINT WM_FINDREPLACE;//定义消息
CFindReplaceDlg* m_pFindDlg{};
protected:
afx_msg LRESULT OnFindreplace(WPARAM wParam, LPARAM lParam);
}
//消息映射表
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_REGISTERED_MESSAGE(WM_FINDREPLACE, OnFindreplace)
END_MESSAGE_MAP()
const UINT CMainFrame::WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);//注册
LRESULT CMainFrame::OnFindreplace(WPARAM wParam, LPARAM lParam)
{
if (!m_pFindDlg->GetSafeHwnd())
return -1;
if (m_pFindDlg->IsTerminating())
{//点击了cancel按钮,destroywindows由FRDlg内部执行
this->OnDestroy();
return 0;
}
if (m_pFindDlg->ReplaceAll())
//TODO...
if (m_pFindDlg->ReplaceCurrent())
//TODO...
if (m_pFindDlg->FindNext())
//TODO...
return 0;
}