如何添加查找对话框 初学者请教各位 如何添加查找对话框 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个一个专门的类,属于非模式对话框。CFindReplaceDialog看MSDN吧,一时说不清。不过提醒你,注意两件事情:注册消息和实现! class CMyFrameWnd : public CFrameWnd { protected: afx_msg LONG OnFindReplace(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() }; static UINT WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING); //注册消息 BEGIN_MESSAGE_MAP( CMyFrameWnd, CFrameWnd ) //Normal message map entries here. ON_REGISTERED_MESSAGE( WM_FINDREPLACE, OnFindReplace ) END_MESSAGE_MAP对话框的生成:void CRichEditView::InitFindReplaceDlg() { if( NULL == m_pFRDlg ) { m_pFRDlg = new CMyFindReplaceDlg(); // Must be created on the heap m_pFRDlg->Create( TRUE, "", "", FR_DOWN, this ); m_pFRDlg->m_fr.lStructSize = sizeof(FINDREPLACE); m_pFRDlg->m_fr.hwndOwner = this->m_hWnd; m_pFRDlg->m_fr.lpstrFindWhat = m_pFRDlg->GetFindWhatStr(); m_pFRDlg->m_fr.lpstrReplaceWith = m_pFRDlg->GetReplaceWithStr(); m_pFRDlg->m_fr.wFindWhatLen = m_pFRDlg->GetFindWhatStrLen(); m_pFRDlg->m_fr.wReplaceWithLen = m_pFRDlg->GetReplaceWithStrLen(); }}上面都是例子,要自己研究。 CFindReplaceDialog *dia=new CFindReplaceDialog; dia->Create(true,"Program"); 下面是我做过的,//Find通用对话框的消息响应函数LRESULT CHexView::OnFindHexMessage(WPARAM wParam, LPARAM lParam){ CFindReplaceDialog* pDlg = CFindReplaceDialog::GetNotifier(lParam); ASSERT(pDlg != NULL); if (pDlg->IsTerminating()) { pDlg = NULL; this->bHexFirstSearchTime = TRUE; } else if ( pDlg->FindNext() ) { if(!FindText(pDlg->GetFindString(),TRUE,FALSE)) //调用FindText()进行查找 { //当没有找到的时候 this->bHexFirstSearchTime = TRUE; OnTextNotFound(pDlg->GetFindString()); MessageBox("FIND Have reached the END,Cann't find it!"); } } return 0;}主要是两个地方:pDlg->FindNext() 和FindText函数如果FindText不能满足你的要求,你还必须重载CEditView的这个FindText函数,实现你的功能。就说这么多。 怎么找不到这个窗口(FINDWINDOW) 别人工程,一编译都是问题啊。 请问关于ado数据库操作的问题 请教:ado在win98的错误 关于windows目录权限,有谁知道这个函数怎么写吗 刚学ADO,编译错误,引入库了,还需要包含什么头文件啊 新手求教 一个MSDN的问题! 关于m_edit.SetWindowText的问题 为什么用detours不可以截获全局messagebox? 在内存dc之间复制位图的问题,代码见内: 关于双方都在防火墙后面的问题。
看MSDN吧,一时说不清。不过提醒你,注意两件事情:
注册消息和实现! class CMyFrameWnd : public CFrameWnd
{
protected:
afx_msg LONG OnFindReplace(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP()
};
static UINT WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);
//注册消息
BEGIN_MESSAGE_MAP( CMyFrameWnd, CFrameWnd )
//Normal message map entries here.
ON_REGISTERED_MESSAGE( WM_FINDREPLACE, OnFindReplace )
END_MESSAGE_MAP
对话框的生成:
void CRichEditView::InitFindReplaceDlg()
{
if( NULL == m_pFRDlg )
{
m_pFRDlg = new CMyFindReplaceDlg(); // Must be created on the heap m_pFRDlg->Create( TRUE, "", "", FR_DOWN, this ); m_pFRDlg->m_fr.lStructSize = sizeof(FINDREPLACE);
m_pFRDlg->m_fr.hwndOwner = this->m_hWnd;
m_pFRDlg->m_fr.lpstrFindWhat = m_pFRDlg->GetFindWhatStr();
m_pFRDlg->m_fr.lpstrReplaceWith = m_pFRDlg->GetReplaceWithStr();
m_pFRDlg->m_fr.wFindWhatLen = m_pFRDlg->GetFindWhatStrLen();
m_pFRDlg->m_fr.wReplaceWithLen = m_pFRDlg->GetReplaceWithStrLen();
}
}
上面都是例子,要自己研究。
dia->Create(true,"Program");
LRESULT CHexView::OnFindHexMessage(WPARAM wParam, LPARAM lParam)
{
CFindReplaceDialog* pDlg = CFindReplaceDialog::GetNotifier(lParam);
ASSERT(pDlg != NULL);
if (pDlg->IsTerminating())
{
pDlg = NULL;
this->bHexFirstSearchTime = TRUE;
}
else if ( pDlg->FindNext() )
{
if(!FindText(pDlg->GetFindString(),TRUE,FALSE)) //调用FindText()进行查找
{ //当没有找到的时候
this->bHexFirstSearchTime = TRUE;
OnTextNotFound(pDlg->GetFindString());
MessageBox("FIND Have reached the END,Cann't find it!");
}
}
return 0;
}主要是两个地方:
pDlg->FindNext()
和FindText函数如果FindText不能满足你的要求,你还必须重载CEditView的这个FindText函数,实现你的功能。就说这么多。