SearchDlg.cpp
资源名称:(vc).rar [点击查看]
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:3k
源码类别:
Telnet服务器
开发平台:
Visual C++
- // SearchDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "anywhere.h"
- #include "SearchDlg.h"
- #include "thread1.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSearchDlg dialog
- CSearchDlg::CSearchDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSearchDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSearchDlg)
- filename = _T("");
- text="";
- //}}AFX_DATA_INIT
- }
- void CSearchDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSearchDlg)
- DDX_Control(pDX, IDC_FILEFIND, m_listbox);
- DDX_Control(pDX, IDCANCEL, m_btcancel);
- DDX_Control(pDX, IDOK, m_btok);
- DDX_Text(pDX, IDC_SEARCHFILE, filename);
- DDV_MaxChars(pDX, filename, 256);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSearchDlg, CDialog)
- //{{AFX_MSG_MAP(CSearchDlg)
- ON_MESSAGE(WM_SETACTIVE,OnSetActive)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSearchDlg message handlers
- void CSearchDlg::OnOK()
- {
- UpdateData(TRUE);
- if (filename.IsEmpty()) {
- MessageBox("您没有选定文件,无法搜索!","提示:");
- CDialog::OnCancel();
- }
- else {//CDialog::OnOK();
- //CWaitCursor wc;
- DWORD ThreadId;
- filename="FINDFILE"+filename;
- strcpy(linkrc.sbuf,filename);
- linkrc.m_hWnd=GetSafeHwnd();//将search对话框句柄付给线程
- hSend=CreateThread(NULL,0,SendThread,&linkrc,0,&ThreadId);
- SetWindowText("请稍候,正在向远程机器发出搜索命令");
- m_btok.EnableWindow(FALSE);
- m_btcancel.EnableWindow(FALSE);
- }
- }
- BOOL CSearchDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CSearchDlg::ListFileFind()
- {
- BOOL bFinished=FALSE;
- int pos;
- while (!bFinished) {
- if ((pos=text.Find("/"))!=-1)
- {
- //text1=text.Left(pos);//为名字+长度(目录无长度)
- m_listbox.AddString(text.Left(pos));//文件名字
- text=text.Right(text.GetLength()-pos-1);
- //m_remote.SetItemData(num,1);//为目录
- }
- else bFinished=true;
- }
- SetWindowText("远程文件搜索");
- }
- LRESULT CSearchDlg::OnSetActive(WPARAM wParam, LPARAM lParam)
- {
- if ((BOOL)wParam) {
- text=*(CString*)lParam;
- text=text.Right(text.GetLength()-8);//filename.GetLength());
- if (!text.IsEmpty()) {
- m_listbox.ResetContent();
- ListFileFind();
- m_btok.EnableWindow(TRUE);
- m_btcancel.EnableWindow(TRUE);
- return 1;
- }
- else {
- CString sNovalue;
- sNovalue.LoadString(IDS_NOVALUE_RETURN);
- m_listbox.AddString(sNovalue);
- m_btok.EnableWindow(TRUE);
- m_btcancel.EnableWindow(TRUE);
- return 1;
- }
- }
- else {
- CDialog::OnOK();
- return 0;}
- }