www.pudn.com > agsm2-1.2_src.zip > FindDialog.cpp


// FindDialog.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "agsm2.h" 
#include "Agsm2Dlg.h" 
#include "FindDialog.h" 
#include "Helper.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CFindDialog dialog 
 
 
CFindDialog::CFindDialog(CWnd* pParent /*=NULL*/) 
	: CDialog(CFindDialog::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CFindDialog) 
	m_csFindWhat = _T(""); 
	m_RadioDir = 1; 
	m_csReplaceWith = _T(""); 
	m_bMatchCase = FALSE; 
	//}}AFX_DATA_INIT 
} 
 
 
void CFindDialog::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CFindDialog) 
	DDX_Text(pDX, IDC_EDIT_FINDWHAT, m_csFindWhat); 
	DDX_Radio(pDX, IDC_RADIO_UP, m_RadioDir); 
	DDX_Text(pDX, IDC_EDIT_REPLACE, m_csReplaceWith); 
	DDX_Check(pDX, IDC_CHECK_MATCHCASE, m_bMatchCase); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CFindDialog, CDialog) 
	//{{AFX_MSG_MAP(CFindDialog) 
	ON_BN_CLICKED(IDOK, OnButtonFindnext) 
	ON_BN_CLICKED(IDC_BUTTON_REPLACE, OnButtonReplace) 
	ON_BN_CLICKED(IDC_BUTTON_REPLACEALL, OnButtonReplaceall) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CFindDialog message handlers 
 
void CFindDialog::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	((CAgsm2Dlg *)this->GetParent())->m_pFindDialog = NULL; 
	DestroyWindow(); 
} 
 
void CFindDialog::OnButtonFindnext()  
{ 
	// TODO: Add your control notification handler code here 
	UpdateData(); 
	CScPropertyPage *activePage = 	(CScPropertyPage *)((CAgsm2Dlg *)this->GetParent())->m_ScPropSheet.GetActivePage(); 
	CScListCtrl *listCtrl = activePage->GetListCtrl(); 
	if(listCtrl == NULL) 
		return; 
	TRACE("m_radioDir=%d\n",m_RadioDir); 
	TRACE("m_bMatchCase=%d\n",m_bMatchCase); 
	TRACE("m_csFindWhat=%s\n",m_csFindWhat); 
	TRACE("m_csReplaceWith=%s\n",m_csReplaceWith); 
#if 0 
	LVFINDINFO info; 
	int nIndex; 
	info.flags = /*LVFI_PARTIAL|*/LVFI_STRING; 
	info.psz = _T("1"); 
 
	// Delete all of the items that begin with the string lpszmyString. 
	while ((nIndex=listCtrl->FindItem(&info)) != -1) 
	{ 
		listCtrl->DeleteItem(nIndex); 
	} 
#else 
	m_csReplaceWith = _T(""); 
	BOOL ret = listCtrl->Find(m_csFindWhat,m_csReplaceWith,m_bMatchCase,m_RadioDir); 
	if(!ret) 
	{ 
		CString str; 
		CString format((LPCSTR)IDS_STRING_NOT_FOUND); 
 
		str.Format(format,m_csFindWhat); 
		AfxMessageBox(str); 
	} 
 
#endif 
} 
 
void CFindDialog::OnButtonReplace()  
{ 
	// TODO: Add your control notification handler code here 
	UpdateData(); 
	CScPropertyPage *activePage = 	(CScPropertyPage *)((CAgsm2Dlg *)this->GetParent())->m_ScPropSheet.GetActivePage(); 
	CScListCtrl *listCtrl = activePage->GetListCtrl(); 
	if(listCtrl == NULL) 
		return; 
	BOOL ret = listCtrl->Find(m_csFindWhat,m_csReplaceWith,m_bMatchCase,m_RadioDir); 
	if(!ret) 
	{ 
		CString str; 
		CString format((LPCSTR)IDS_STRING_NOT_FOUND); 
		str.Format(format,m_csFindWhat); 
		AfxMessageBox(str); 
	} 
	 
} 
 
void CFindDialog::OnButtonReplaceall()  
{ 
	// TODO: Add your control notification handler code here 
	UpdateData(); 
	CScPropertyPage *activePage = 	(CScPropertyPage *)((CAgsm2Dlg *)this->GetParent())->m_ScPropSheet.GetActivePage(); 
	CScListCtrl *listCtrl = activePage->GetListCtrl(); 
	if(listCtrl == NULL) 
		return; 
	BOOL ret = listCtrl->Find(m_csFindWhat,m_csReplaceWith,m_bMatchCase,m_RadioDir,TRUE); 
	if(!ret) 
	{ 
		CString str; 
		CString format((LPCSTR)IDS_STRING_NOT_FOUND); 
		str.Format(format,m_csFindWhat); 
		AfxMessageBox(str); 
	} 
	 
} 
 
BOOL CFindDialog::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	//Helper::SetWindowOpacity(this,70); 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CFindDialog::PostNcDestroy()  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	 
	delete this; 
}