www.pudn.com > SouMP3.rar > XingYunXingDlg.cpp


// XingYunXingDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "XingYunXing.h" 
#include "XingYunXingDlg.h" 
#include "TokenEx.h" 
#define OP_FILENAME    0x01 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
void WINAPI DrawWireRects(LPRECT lprcFrom, LPRECT lprcTo, UINT nMilliSecSpeed) 
{ 
    const int nNumSteps = 10; 
 
	GdiFlush(); 
    Sleep(550);  // Let the desktop window sort itself out 
 
	// if hwnd is null - "you have the CON". 
	HDC hDC = ::GetDC(NULL); 
 
	// Pen size, urmmm not too thick 
    HPEN hPen = ::CreatePen(PS_SOLID, 2, RGB(0,0,0)); 
 
	int nMode = ::SetROP2(hDC, R2_NOT); 
	HPEN hOldPen = (HPEN) ::SelectObject(hDC, hPen); 
 
	for (int i = 0; i < nNumSteps; i++) 
	{ 
        double dFraction = (double) i / (double) nNumSteps; 
 
        RECT transition; 
        transition.left   = lprcFrom->left + (int)((lprcTo->left - lprcFrom->left) * dFraction); 
        transition.right  = lprcFrom->right + (int)((lprcTo->right - lprcFrom->right) * dFraction); 
        transition.top    = lprcFrom->top + (int)((lprcTo->top - lprcFrom->top) * dFraction); 
        transition.bottom = lprcFrom->bottom + (int)((lprcTo->bottom - lprcFrom->bottom) * dFraction); 
 
		POINT pt[5]; 
		pt[0] = CPoint(transition.left, transition.top); 
		pt[1] = CPoint(transition.right,transition.top); 
		pt[2] = CPoint(transition.right,transition.bottom); 
		pt[3] = CPoint(transition.left, transition.bottom); 
		pt[4] = CPoint(transition.left, transition.top); 
 
		// We use Polyline because we can determine our own pen size 
		// Draw Sides 
		::Polyline(hDC,pt,5); 
 
		GdiFlush(); 
 
		Sleep(nMilliSecSpeed); 
 
		// UnDraw Sides 
		::Polyline(hDC,pt,5); 
 
		GdiFlush(); 
	} 
 
	::SetROP2(hDC, nMode); 
	::SelectObject(hDC, hOldPen); 
 
	::ReleaseDC(NULL,hDC); 
} 
BOOL bReturnKey=FALSE; 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
    CRect m_rectFrom; 
//    BOOL  m_bWireFrame; 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	public: 
	//virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); 
	//virtual BOOL DestroyWindow(); 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
		afx_msg void OnDestroy(); 
	virtual BOOL OnInitDialog(); 
	//}}AFX_MSG 
 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
    //m_bWireFrame = FALSE; 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
HWND hList=NULL; 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
	ON_WM_DESTROY() 
	ON_WM_CREATE() 
	//}}AFX_MSG_MAP 
 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CXingYunXingDlg dialog 
LPBYTE CString_To_LPBYTE(CString str) 
{ 
	//LPBYTE lpb=new BYTE[str.GetLength()+1];  
	/*LPBYTE lpb=new BYTE[str.GetLength()+1]; 
	for(int i=0; iLoadIcon(IDR_MAINFRAME); 
} 
 
void CXingYunXingDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CXingYunXingDlg) 
	DDX_Control(pDX, IDC_TIME, m_ctrT); 
	DDX_Control(pDX, IDC_FINDALLNAME, m_ctrFindAll); 
	DDX_Control(pDX, IDC_CHECK3, m_ctrSetAll); 
	DDX_Control(pDX, IDC_RADIO2, m_ctrFen); 
	DDX_Control(pDX, IDC_SAVEPATH, m_ctrSavePath); 
	DDX_Control(pDX, IDC_SEARCHPATH, m_ctrFindPath); 
	DDX_Control(pDX, IDC_LIST1, m_list1); 
	DDX_Text(pDX, IDC_FINDALLNAME, m_findall); 
	DDX_Check(pDX, IDC_SAVEAS, m_bSaveas); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CXingYunXingDlg, CDialog) 
	//{{AFX_MSG_MAP(CXingYunXingDlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_BN_CLICKED(IDC_CHANGE1, OnChange1) 
	ON_BN_CLICKED(IDC_CHANGE2, OnChange2) 
	ON_BN_CLICKED(IDC_GO, OnGo) 
	ON_BN_CLICKED(IDC_ABOUT, OnAbout) 
	ON_BN_CLICKED(IDC_SEALL, OnSeall) 
	ON_BN_CLICKED(IDC_SAVEGET, OnSaveget) 
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2) 
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3) 
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1) 
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1) 
	ON_BN_CLICKED(IDC_CLEAR, OnClear) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1) 
	// ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndlabeleditList1) 
	// ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_LIST1, OnBeginlabeleditList1) 
	//}}AFX_MSG_MAP 
    ON_BN_CLICKED(IDC_DEL, OnDel) 
    ON_BN_CLICKED(IDC_PLAY, OnPlay) 
	ON_BN_CLICKED(IDC_COP, OnCop) 
    ON_BN_CLICKED(IDC_DELC, OnDelc) 
	ON_BN_CLICKED(IDC_RENAME, OnReName) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CXingYunXingDlg message handlers 
 
BOOL CXingYunXingDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
    m_ctrFen.SetCheck(TRUE); 
	m_ctrSetAll.SetCheck(TRUE);  
      
	  
	 m_btnOpen.SubclassDlgItem(IDC_CHANGE1,this);/////IDC_CHANGE1 
	 m_btnOpen.SetIcon(IDI_OPENFILE); 
	 m_btnOpen.DrawTransparent(TRUE); 
	  
	 m_btnDelIn.SubclassDlgItem(IDC_BUTTON1,this);///// 
	 m_btnDelIn.SetIcon(IDI_CANCEL); 
	 m_btnDelIn.DrawTransparent(TRUE); 
 
	 m_btnSel.SubclassDlgItem(IDC_SEALL,this);///// 
	 m_btnSel.SetIcon(IDI_SEL); 
	 m_btnSel.DrawTransparent(TRUE); 
 
	  m_btnCopy.SubclassDlgItem(IDC_SAVEGET,this);///// 
	 m_btnCopy.SetIcon(IDI_COPY); 
	 m_btnCopy.DrawTransparent(TRUE); 
 
	 m_btnDelFin.SubclassDlgItem(IDC_CLEAR,this);///// 
	 m_btnDelFin.SetIcon(IDI_CANCEL); 
	 m_btnDelFin.DrawTransparent(TRUE); 
 
	 m_btnAbout.SubclassDlgItem(IDC_ABOUT,this);///// 
	 m_btnAbout.SetIcon(IDI_ABOUT, (int)BTNST_AUTO_GRAY); 
	 m_btnAbout.DrawBorder(FALSE); 
	 m_btnAbout.DrawTransparent(TRUE); 
	 
	 m_btnSave.SubclassDlgItem(IDC_CHANGE2,this);/////IDC_CHANGE2 
	 m_btnSave.SetIcon(IDI_OPENFILE); 
	 m_btnSave.DrawTransparent(TRUE); 
 
	 m_btnGo.SubclassDlgItem(IDC_GO,this);/////IDC_GO 
	 m_btnGo.SetIcon(IDI_FIND); 
	 m_btnGo.DrawTransparent(TRUE); 
 
	 m_btnCancel.SubclassDlgItem(IDCANCEL,this);/////IDC_GO 
	 m_btnCancel.SetIcon(IDI_RUN,(int)BTNST_AUTO_GRAY); 
	 m_btnCancel.DrawTransparent(TRUE); 
 
	  
	 m_list1.DeleteAllItems (); 
	 m_list1.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_TRACKSELECT|LVS_EX_FLATSB|LVS_EX_UNDERLINEHOT|LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES); 
	 m_list1.InsertColumn(0,_T("文件名"),LVCFMT_IMAGE|LVCFMT_LEFT,180,180); 
	 m_list1.InsertColumn(1,_T("扩展名"),LVCFMT_LEFT,50); 
	 m_list1.InsertColumn(2,_T("大小"),LVCFMT_LEFT,60); 
	 m_list1.InsertColumn(3,_T("路径"),LVCFMT_LEFT,160); 
	  
	 m_list1.InsertColumn(4,_T("类型"),LVCFMT_LEFT,60); 
	 
	 //m_list1.SetHoverTime(500); 
	 m_list1.SetRedraw(); 
 
	 CString strSearchMP3Path1=GetRegString("SearchMP3Path1"); 
	 if(strSearchMP3Path1.IsEmpty ())  
	 {  
		 SetRegString("SearchMP3Path1","c:\\");  
		 m_ctrFindPath.SetWindowText ("c:\\"); 
	 }  
	 else 
	 { 
		 m_ctrFindPath.SetWindowText (strSearchMP3Path1); 
	 } 
	 CString strSaveMP3Path=GetRegString("SaveMP3Path"); 
	 if (strSaveMP3Path.IsEmpty ()) 
	 { 
		 //newPath=OutTo(); 
		 SetRegString("SaveMP3Path",_T("C:\\Documents and Settings\\Administrator\\桌面")); 
		 m_ctrSavePath.SetWindowText (_T("C:\\Documents and Settings\\Administrator\\桌面")); 
	 } 
	 else 
	 { 
		 m_ctrSavePath.SetWindowText (strSaveMP3Path); 
	 } 
     //UpdateData(TRUE); 
 
 
// 	 ListView_SetExtendedListViewStyle(::GetDlgItem(m_hWnd,IDC_LIST1),LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);  
	 ::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDITITEM),SW_HIDE); 
 
	 return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CXingYunXingDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CXingYunXingDlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CXingYunXingDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
void CXingYunXingDlg::OnChange1()  
{ 
	CString s1=GetFolderPath("SearchMP3Path1"); 
	m_ctrFindPath.SetWindowText(s1); 
	UpdateData(false); 
	 
} 
 
void CXingYunXingDlg::OnChange2()  
{ 
	CString s2=GetFolderPath("SaveMP3Path"); 
	m_ctrSavePath.SetWindowText(s2); 
	UpdateData(false); 
	 
} 
 
 
 
void CXingYunXingDlg::OnGo()  
{ 
	m_btnGo.EnableWindow (false); 
	//m_ctrGo.EnableWindow (false); 
	if (UpdateData(TRUE))  
	{ 
		//CEdit e; 
		//e.GetWindowText (); 
		CString csRef2=m_findall;// = m_edit4; 
	    m_ctrFindPath.GetWindowText (m_strPath); 
 
		//CString strK="  "; 
		//m_edit1.GetWindowText (m_strPath);/////路径1 
        //m_edit3.GetWindowText (strTo);/////目标路径 
		CTokenEx tok;    
		do { 
			CString csRet; 
			csRet = tok.GetString(csRef2, strFen, FALSE); 
			 
			//CString stmp2=".mp3"; 
			//m_strFindName=(csRet+stmp2);/////不是直接的文件名 
			/////除非已有扩展名mp3或wma-------从EDIT4得csRet+扩展名 
			 
            m_strFindName=csRet; 
			BOOL bDone=FALSE; 
			//Find(m_strPath);/////查找工作///// 
			if(m_strFindName!="") 
			{ 
				bDone=FindFull(m_strPath); 
                //while(bDone=FALSE)Sleep(300); 
			} 
			 
			 
						 
			/*if(!strFrom.IsEmpty()) 
			{ 
				//MessageBox(strFrom,NULL,MB_OK); 
				////////复制MP3格式文件!!! 
			} 
			else 
			{ 
				CString stmp2=".wma"; 
				m_strFindName=(csRet+stmp2); 
				FindFull(m_strPath); 
				if(!strFrom.IsEmpty()) 
				{ 
					//MessageBox(strFrom,NULL,MB_OK); 
					CopyA(strFrom,strTo);/////复制WMA格式文件!!! 
				} 
				else 
				{ 
					//strFindNot=strFindNot+csRet+strK; 
					 
					//MessageBox(_T("找不到mp3和wma格式的文件!!"),_T("幸韵星"),MB_OK); 
					/////没有这个文件!!! 
				} 
				 
			}*/ 
			strFrom="";  
			m_strFindName=""; 
		}  
		while (!csRef2.IsEmpty()); 
 
        m_btnGo.EnableWindow (TRUE); 
		//UpdateData(TRUE); 
		//m_ctrGo.EnableWindow (TRUE); 
		//MessageBox("累死了,终于做完我的工作了!!","幸韵星",MB_OK); 
		/*CPopDialog* pP=new CPopDialog; 
		//	ASSERT_VALID (pP) Destroy (); 
		BOOL bResult = pP->Create (IDD_POP); 
		ASSERT (bResult); 
		pP->ShowWindow (SW_SHOW);*/ 
	 
	} 
	// TODO: Add your control notification handler code here 
	 
} 
 
 
 
/////查询注册表所设置的路径值 
CString CXingYunXingDlg::GetRegString(CString strPath) 
{ 
	HKEY hKEY; 
	LPCTSTR data_Set="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"; 
    long ret0=(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_READ, &hKEY));  
	if(ret0!=ERROR_SUCCESS)///////如果无法打开hKEY,则终止程序的执行  
	{ 
        return ""; 
	}  
	//查询有关的数据 (用户姓名 owner_Get)。  
	LPBYTE owner_Get=new BYTE[80]; 
	DWORD type_1=REG_SZ;  
	DWORD cbData_1=80;  
	//hKEY为刚才RegOpenKeyEx()函数所打开的键的句柄,″RegisteredOwner″。 表示要查 询的键值名,type_1表示查询数据的类型,owner_Get保存所。 查询的数据,cbData_1表示预设置的数据长度。  
	long ret1=::RegQueryValueEx(hKEY, strPath, NULL,&type_1, owner_Get,&cbData_1); 
	if(ret1!=ERROR_SUCCESS)///////如果无法打开hKEY,则终止程序的执行  
	{ 
		::RegCloseKey(hKEY);  
		return ""; 
	}  
	else 
	{ 
		CString strGet=owner_Get; 
		delete[] owner_Get; 
		::RegCloseKey(hKEY); 
		return strGet; 
	} 
	delete owner_Get; 
} 
/////////////////////////////////////////////////////// 
 
/////设置注册表项值:传入路径值、名称 
BOOL CXingYunXingDlg::SetRegString(CString strSet, CString strPath) 
{ 
	HKEY hKEY;  
	LPCTSTR data_Set="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"; //打开与路径 data_Set 相关的hKEY,KEY_WRITE表示以写的方式打开。  
    ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_Set, 0, KEY_WRITE, &hKEY); 
    LPBYTE owner_Set=CString_To_LPBYTE(strPath);  
	DWORD type_1=REG_SZ;  
	DWORD cbData_1=strPath.GetLength()+1;//与RegQureyValueEx()类似,hKEY表示已打开的键的句柄,″RegisteredOwner″ 表示要访问的键值名,owner_Set表示新的键值,type_1和cbData_1表示新值的数据类型和数据长度  
    long ret1=::RegSetValueEx(hKEY,strSet, NULL,type_1, owner_Set, cbData_1); 
    if(ret1!=ERROR_SUCCESS)  
	{  
		::RegCloseKey(hKEY); 
        return FALSE;  
	}  
	::RegCloseKey(hKEY); 
	return TRUE;	 
} 
////////////////////////////////////////////////////////////////// 
 
//////传入查询注册表路径,打开文件夹选择对话,选择后在注册表中设置路径///// 
CString CXingYunXingDlg::GetFolderPath(CString SelectFolder) 
{ 
	BROWSEINFO bi; 
	char dispname[MAX_PATH],path[MAX_PATH]; 
	ITEMIDLIST *pidl; 
	bi.hwndOwner=m_hWnd; 
	bi.pidlRoot=0; 
	bi.pszDisplayName=dispname; 
	bi.lpszTitle="请选择查找目录:"; 
	bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_EDITBOX|BIF_DONTGOBELOWDOMAIN ; 
	bi.lpfn=0; 
	bi.lParam=0; 
	bi.iImage=0; 
	CString strSetTmp; 
    pidl=SHBrowseForFolder(&bi); 
	if(pidl) 
	{ 
		SHGetPathFromIDList(pidl,path); 
		 
        strSetTmp=CString(path); 
        SetRegString(SelectFolder,strSetTmp); 
		return strSetTmp; 
	} 
	else 
	{ 
		strSetTmp=GetRegString(SelectFolder);       
		return strSetTmp; 
	} 
} 
/////////////////////////////////////////////////////// 
 
 
 
/////复制文件,来源路径,目标路径 
void CXingYunXingDlg::CopyA(CString strFrom, CString strTo) 
{ 
	int nOk; 
	char szPath[MAX_PATH]; 
	memset(szPath,0,MAX_PATH); 
	CString strPath=strFrom+""; 
	strcpy(szPath,strPath); 
	char szDst[MAX_PATH]; 
	memset(szDst,0,MAX_PATH); 
	CString strDst=strTo+""; 
	strcpy(szDst,strDst); 
	char  strTitle[MAX_PATH]=" mp3 File copying"; 
	//进度题头 
     
//if((m_Option&OP_FILENAME)&&(fname.Find(m_strFileName,pos+1)==-1))return false; 
 
 
	SHFILEOPSTRUCT FileOp; 
	FileOp.hwnd=m_hWnd; 
	FileOp.wFunc=FO_COPY; 
	//执行文件拷贝////////////////////////////////// 
	FileOp.pFrom=szPath; 
	FileOp.pTo=strDst;//////////////////////////////////strDst 
	FileOp.fFlags=FOF_ALLOWUNDO;//|FOF_SILENT;//不显示进度对话框 
	FileOp.hNameMappings=NULL; 
	FileOp.lpszProgressTitle=strTitle; 
	nOk=SHFileOperation(&FileOp); 
	if(nOk) 
		TRACE("There is an error: %d\n",nOk);////////////////////////////////// 
	else 
		TRACE("SHFileOperation finished successfully\n"); 
	if(FileOp.fAnyOperationsAborted) 
		TRACE("Operation was aborted!\n"); 
} 
/////////////////////////////////////////////////////// 
 
 
 
///////////以下为查找文件函数,设好要搜索文件名m_strFindName, 
///////////传入路径参数CSTRING pszPath,返回结果为找到的路径 
//DEL CString CXingYunXingDlg::Find(CString pszPath)//LPCTSTR pszPath) 
//DEL { 
//DEL 	CString strPath(pszPath); 
//DEL 	CString strtmp2; 
//DEL 	if(strPath[strPath.GetLength() - 1] != _T('\\')) 
//DEL 		strPath += _T('\\'); 
//DEL 	strPath += m_strFindName; 
//DEL     BOOL m_bStop=FALSE; 
//DEL 	CFileFind finder; 
//DEL 	BOOL bWorking = finder.FindFile(strPath); 
//DEL 	if (bWorking==1) 
//DEL 	{ 
//DEL 		bWorking = finder.FindNextFile();   
//DEL 		strtmp2=finder.GetFilePath (); 
//DEL 		m_bStop=TRUE; 
//DEL 		strFrom=strtmp2; 
//DEL    	    return strFrom; 
//DEL 	} 
//DEL 	MSG msg; 
//DEL 	while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) //post all messages 
//DEL 	{ 
//DEL 		TranslateMessage(&msg); 
//DEL 		DispatchMessage(&msg); 
//DEL 	} 
//DEL 	if(m_bStop) return ""; 
//DEL 	if(!m_bStop) 
//DEL 	{ 
//DEL 		m_bStop=FALSE; 
//DEL 		strPath=pszPath; 
//DEL 		if(strPath[strPath.GetLength() - 1] != _T('\\')) 
//DEL 			strPath += _T('\\'); 
//DEL 		strPath += "*.*"; 
//DEL 		finder.Close(); 
//DEL 		bWorking = finder.FindFile(strPath); 
//DEL 		while (bWorking) 
//DEL 		{ 
//DEL 			bWorking = finder.FindNextFile(); 
//DEL 			if( finder.IsDots())continue; 
//DEL 			if( finder.IsDirectory() ) 
//DEL 			{ 
//DEL 				CString s1; 
//DEL 				s1=finder.GetFilePath(); 
//DEL 				Find(s1); 
//DEL 			} 
//DEL 			MSG msg; 
//DEL 			while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) //post all messages 
//DEL 			{ 
//DEL 				TranslateMessage(&msg); 
//DEL 				DispatchMessage(&msg); 
//DEL 			} 
//DEL 			if(m_bStop) return ""; 
//DEL 		}		 
//DEL 	} 
//DEL     return strFrom; 
//DEL } 
////////////////////////////////////////////////////////////// 
 
 
 
/*int CAboutDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
		if (CDialog::OnCreate(lpCreateStruct) == -1) 
	    	return -1; 
 
	if (!m_rectFrom.IsRectEmpty()) 
	{ 
		CRect rectTo(lpCreateStruct->x,lpCreateStruct->y,  
			lpCreateStruct->x + lpCreateStruct->cx, 
			lpCreateStruct->y + lpCreateStruct->cy); 
 
        if (m_bWireFrame) 
            DrawWireRects(m_rectFrom, rectTo, 20); 
        else 
		    DrawAnimatedRects(m_hWnd, IDANI_CAPTION, m_rectFrom, rectTo); 
	} 
 
	return 0; 
 
	// TODO: Add your specialized code here and/or call the base class 
	 
	return CDialog::Create(IDD, pParentWnd); 
}*/ 
 
void CAboutDlg::OnDestroy()  
{ 
	CDialog::OnDestroy(); 
	/*if (!m_rectFrom.IsRectEmpty()) 
	{ 
		CRect rect; 
		GetWindowRect(rect); 
 
        if (m_bWireFrame) 
        { 
            rect.DeflateRect(2,2); 
            DrawWireRects(rect, m_rectFrom, 20); 
        } 
        else 
    		DrawAnimatedRects(m_hWnd,IDANI_CAPTION, rect, m_rectFrom); 
	} 
	*/ 
 
} 
 
void CXingYunXingDlg::OnAbout()  
{ 
    //UpdateData(); 
    //CAboutDlg about; 
	::AfxMessageBox ("hh",MB_USERDEFINE);//CAboutDlg about; 
	//m_ctlAbout.GetWindowRect(about.m_rectFrom); 
    //about.m_bWireFrame = m_bWireFrame; 
	//about.DoModal(); 
	 
} 
 
BOOL CAboutDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog();	 
	ShowWindow(SW_HIDE);  
	CRect dlgRect;  
	GetClientRect(&dlgRect);  
	CPoint centerPoint;  
	centerPoint.x=dlgRect.Width()/2;  
	centerPoint.y=dlgRect.Height()/2;  
	//得到对话框的中点坐标  
	CRgn testrgn;  
	this->ShowWindow(SW_HIDE);  
	int m=GetSystemMetrics(SM_CYSIZEFRAME); 
	 
	//以下代码实现对话框的动态弹出  
	//for (int i=10;i1024) 
	{    
		flen/=1024; 
		if(flen<1024){Unit="KB";} 
		else{flen/=1024;Unit="MB";} 
	} 
	CString Size; 
	Size.Format("%1.2f",flen); 
     
	int pos=pathname.ReverseFind('\\'); 
	 
	SHFILEINFO sfi; 
	if (::SHGetFileInfo (pathname, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO),SHGFI_USEFILEATTRIBUTES | SHGFI_DISPLAYNAME | SHGFI_TYPENAME |SHGFI_ICON|SHGFI_SMALLICON )) 
	{	 
		//m_imglist.Add(sfi.hIcon); 
		m_list1.InsertItem(count-1,sfi.szDisplayName,count-1); 
 
     	m_list1.SetItemText(count-1,3,pathname.Mid(0,pos)); 
    	m_list1.SetItemText(count-1,2,(Size+Unit)); 
		m_list1.SetItemText(count-1,4,sfi.szTypeName); 
        m_list1.SetItemText(count-1,1,PathStr.Right (4)); 
	} 
	m_list1.Update(count-1); 
} 
 
 
 
void CXingYunXingDlg::OnRadio2()  
{ 
    strFen="/"; 
	 
} 
 
void CXingYunXingDlg::OnRadio3()  
{ 
	strFen=","; 
	 
} 
 
void CXingYunXingDlg::OnRadio1()  
{ 
    strFen=" ";	 
} 
 
void CXingYunXingDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
    NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 
	int iIt=pNMListView->iItem; 
	if(iIt != -1) 
	{ 
		bSel=!bSel; 
		 
		m_list1. SetCheck(iIt,bSel);  
	//	PostMessage(GetSaftHand(), 
 
	} 
	 
	 
	*pResult = 0; 
} 
 
 
 
 
void CXingYunXingDlg::OnClear()  
{ 
	m_list1.DeleteAllItems (); 
	m_list1.SetRedraw(TRUE);	 
} 
 
void CXingYunXingDlg::OnButton1()  
{ 
     m_ctrFindAll.SetWindowText(""); 
	 UpdateData(TRUE); 
} 
CString CXingYunXingDlg::OutTo()/////////////////// 
{/////////////////////////////////////////////////// 
	SYSTEMTIME sysTime;///////////////////////////// 
	GetLocalTime(&sysTime);///////////////////////// 
	m_strTime.Format("%d月%d日%d时%d分",//////////// 
		sysTime.wMonth,sysTime.wDay,sysTime.wHour,// 
		sysTime.wMinute);/////////////////////////// 
	UpdateData(FALSE);////////////////////////////// 
	return m_strTime;/////////////////////////////// 
//////////////////////////////////////////////////// 
} 
 
 
 
 
 
 
 
 
 
 
void CXingYunXingDlg::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	temp = (LPNMITEMACTIVATE) pNMHDR; 
	nItem = temp->iItem;//实为第几行nIndex; 
    //get the column number 
    nSubItem = temp->iSubItem; 
	hF=temp->hdr.hwndFrom; 
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 
           if(pNMListView->iItem != -1) 
           { 
                DWORD dwPos = GetMessagePos(); 
                CPoint point( LOWORD(dwPos), HIWORD(dwPos) ); 
     
                CMenu menu; 
                VERIFY( menu.LoadMenu( IDR_R ) ); 
                CMenu* popup = menu.GetSubMenu(0); 
                ASSERT( popup != NULL ); 
                popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this ); 
           } 
		    
 
		    
 
	 
	*pResult = 0; 
} 
void CXingYunXingDlg::OnDel()  
{ 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
	int nIndex = m_list1.GetNextSelectedItem(pos); 
	 
	if(nIndex==-1) 
	{ 
		return; 
	} 
 
	CString sG=m_list1.GetItemText(nIndex,3); 
	   sG+="\\"; 
	   sG+=m_list1.GetItemText(nIndex,0); 
       sG+=m_list1.GetItemText(nIndex,1); 
	   DeleteFile(sG); 
	   m_list1.DeleteItem(nIndex); 
	    
 
} 
 
 
void CXingYunXingDlg::OnPlay()  
{ 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
	int nIndex = m_list1.GetNextSelectedItem(pos); 
	 
	if(nIndex==-1) 
	{ 
		return; 
	} 
	CString sG=m_list1.GetItemText(nIndex,3); 
	   sG+="\\"; 
	   sG+=m_list1.GetItemText(nIndex,0); 
       sG+=m_list1.GetItemText(nIndex,1); 
	   ShellExecute(this->m_hWnd,"open",sG,"","",SW_SHOW); 
} 
void CXingYunXingDlg::OnCop()  
{ 
	CString sS; 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
	int nIndex = m_list1.GetNextSelectedItem(pos); 
	 
	if(nIndex==-1) 
	{ 
		return; 
	} 
	CString sG=m_list1.GetItemText(nIndex,3); 
	sG+="\\"; 
	sG+=m_list1.GetItemText(nIndex,0); 
    sG+=m_list1.GetItemText(nIndex,1); 
	    
	UpdateData(TRUE); 
	if(m_bSaveas) 
	{ 
		sS="C:\\Documents and Settings\\Administrator\\桌面\\"; 
		sS+=OutTo(); 
 
		MakeDirectory(sS); 
		m_ctrT.SetWindowText(sS); 
	} 
	else 
	{ 
       m_ctrSavePath.GetWindowText (sS); 
 
	} 
	CopyA(sG,sS); 
 
} 
 
void CXingYunXingDlg::OnReName()  
{ 
	bReturnKey=TRUE; 
 
 
 
	HWND hWnd1 =  ::GetDlgItem (m_hWnd,IDC_LIST1); 
// 	hList=::GetDlgItem(m_hWnd ,IDC_LIST1); 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
	int nIndex = m_list1.GetNextSelectedItem(pos); 
	// 	m_list1.SetFocus();    
	// 	m_list1.EditLabel(nIndex); 
	nItem=nIndex; 
	if(nIndex==-1) 
	{ 
		return; 
	} 
 
    RECT rect; 
    //get the row number 
    //nItem = temp->iItem;//实为第几行nIndex; 
    //get the column number 
    //nSubItem = temp->iSubItem;//要为0; 
    /* 
    if(nSubItem == 0 || nSubItem == -1 || nItem == -1) 
            return ;*/ 
     
    //Retrieve the text of the selected subItem  
    //from the list 
    CString str = GetItemText(hWnd1,nItem,nSubItem); 
	 
    RECT rect1,rect2; 
    // this macro is used to retrieve the Rectanle  
    // of the selected SubItem 
    ListView_GetSubItemRect(hWnd1,nItem, 
        nSubItem,LVIR_BOUNDS,&rect); 
    //Get the Rectange of the listControl 
    ::GetWindowRect(hF,&rect1); 
    //Get the Rectange of the Dialog 
    ::GetWindowRect(m_hWnd,&rect2); 
	 
    int x=rect1.left-rect2.left; 
    int y=rect1.top-rect2.top; 
     
    //if(nItem != -1)  
		::SetWindowPos(::GetDlgItem(m_hWnd,IDC_EDITITEM), 
        HWND_TOP,rect.left+x+17,rect.top+y-25,  
        160, 
        rect.bottom-rect.top +2,NULL); 
	 
    ::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDITITEM),SW_SHOW); 
    ::SetFocus(::GetDlgItem(m_hWnd,IDC_EDITITEM)); 
    //Draw a Rectangle around the SubItem 
/* 
        ::Rectangle(::GetDC(hF), 
            rect.left,rect.top-1,rect.right-rect.left - 3,rect.bottom-rect.top -1); 
        */ 
    //Set the listItem text in the EditBox 
	::SetWindowText(::GetDlgItem(m_hWnd,IDC_EDITITEM),str); 
 
	 
 
	 
 
	// ::SendMessage(hList,LVN_BEGINLABELEDIT,0,0); 
	CString sY=m_list1.GetItemText(nIndex,3); 
	   sY+="\\"; 
	   sY+=m_list1.GetItemText(nIndex,0); 
       sY+=m_list1.GetItemText(nIndex,1); 
	   CString sL; 
 
	    
 
	// MoveFile(sY,sL); 
 
} 
void CXingYunXingDlg::OnDelc()  
{ 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
	int nIndex = m_list1.GetNextSelectedItem(pos); 
	 
	if(nIndex==-1) 
	{ 
		return; 
	} 
	CString sG; 
	UpdateData(TRUE); 
	if(m_bSaveas) 
	{ 
		m_ctrT.GetWindowText(sG); 
        //DeleteDirectory(sG); 
	} 
	else 
	{ 
	   m_ctrSavePath.GetWindowText(sG);	   
	} 
	  sG+="\\"; 
	  sG+=m_list1.GetItemText(nIndex,0); 
	  sG+=m_list1.GetItemText(nIndex,1); 
      DeleteFile(sG); 
} 
 
 
//////////////////////以下为创建文件夹函数///////////////////// 
/////////////////////////////////////////////////////////////// 
BOOL CXingYunXingDlg::MakeDirectory(CString newPath)/////////////////////////////// 
{////////////////////////////////////////////////////////////// 
		HANDLE		fFile;		// File Handle/////////////////////////////// 
	WIN32_FIND_DATA	fileinfo;	// File Information Structure/////////////////////////////// 
	CStringArray	m_arr;		// CString Array to hold Directory Structures 
	BOOL tt;			// BOOL used to test if Create Directory was successful 
	int x1 = 0;			// Counter/////////////////////////////// 
	CString tem = "";		// Temporary CString Object/////////////////////////////// 
	fFile = FindFirstFile(newPath,&fileinfo);/////////////////////////////// 
	// if the file exists and it is a directory/////////////////////////////// 
	if(fileinfo.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)/////////////////////////////// 
	{////////////////////////////////////////////////////////////// 
		//  Directory Exists close file and return/////////////////////////////// 
		FindClose(fFile);/////////////////////////////// 
		return FALSE;/////////////////////////////// 
	}////////////////////////////////////////////////////////////// 
	m_arr.RemoveAll();/////////////////////////////// 
	for(x1 = 0; x1 < newPath.GetLength(); x1++ )		// Parse the supplied CString Directory String 
	{//////////////////////////////////////////////////////////////									 
		if(newPath.GetAt(x1) != '\\')		// if the Charachter is not a \  
			tem += newPath.GetAt(x1);		// add the character to the Temp String 
		else////////////////////////////////////////////////////////////// 
		{////////////////////////////////////////////////////////////// 
			m_arr.Add(tem);			// if the Character is a \ /////////////////////////////// 
			tem += "\\";			// Now add the \ to the temp string/////////////////////////////// 
		}////////////////////////////////////////////////////////////// 
		if(x1 == newPath.GetLength()-1)		// If we reached the end of the String/////////////////////////////// 
			m_arr.Add(tem);////////////////////////////////////////////////////////////// 
	}////////////////////////////////////////////////////////////// 
	// Close the file////////////////////////////////////////////////////////////// 
	FindClose(fFile);////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////////////////////////////////// 
	// Now lets cycle through the String Array and create each directory in turn 
	for(x1 = 1; x1 < m_arr.GetSize(); x1++)/////////////////////////////// 
	{////////////////////////////////////////////////////////////// 
		tem = m_arr.GetAt(x1);/////////////////////////////// 
		tt = CreateDirectory(tem,NULL);/////////////////////////////// 
////////////////////////////////////////////////////////////// 
		// If the Directory exists it will return a false 
		if(tt)////////////////////////////////////////////////////////////// 
			SetFileAttributes(tem,FILE_ATTRIBUTE_NORMAL);/////////////////////////////// 
		// If we were successful we set the attributes to normal 
	}////////////////////////////////////////////////////////////// 
	//  Now lets see if the directory was successfully created/////////////////////////////// 
	fFile = FindFirstFile(newPath,&fileinfo);/////////////////////////////// 
	m_arr.RemoveAll();/////////////////////////////// 
	if(fileinfo.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)/////////////////////////////// 
	{////////////////////////////////////////////////////////////// 
		//  Directory Exists close file and return/////////////////////////////// 
		FindClose(fFile);/////////////////////////////// 
		return TRUE;/////////////////////////////// 
	}/////////////////////////////// 
	else/////////////////////////////// 
	{////////////////////////////////////////////////////////////// 
		// For Some reason the Function Failed  Return FALSE 
		FindClose(fFile);/////////////////////////////// 
		return FALSE;/////////////////////////////// 
	}////////////////////////////////////////////////////////////// 
}////////////////////////////////////////////////////////////// 
//////////////////////////////////////////////////////////////////////////////////////// 
///////////////////////删除文件夹////////////////////////////////// 
/*BOOL CXingYunXingDlg::DeleteDirectory(char *DirName)///////////////// 
{////////////////////////////////// 
	CFileFind tempFind;///////////////// 
    char tempFileFind[200];///////////////// 
    sprintf(tempFileFind,"%s\\*.*",DirName);///////////////// 
    BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);///////////////// 
    while(IsFinded)///////////////// 
   {////////////////////////////////// 
       IsFinded=(BOOL)tempFind.FindNextFile();///////////////// 
       if(!tempFind.IsDots())///////////////// 
       {////////////////////////////////// 
             char foundFileName[200];///////////////// 
             strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));///////////////// 
             if(tempFind.IsDirectory())///////////////// 
             {///////////////// 
                   char tempDir[200];///////////////// 
                   sprintf(tempDir,"%s\\%s",DirName,foundFileName);///////////////// 
                   DeleteDirectory(tempDir);///////////////// 
              }///////////////// 
              else///////////////// 
             {///////////////// 
                   char tempFileName[200];///////////////// 
                   sprintf(tempFileName,"%s\\%s",DirName,foundFileName);///////////////// 
                   DeleteFile(tempFileName);///////////////// 
              }////////////////////////////////// 
         }////////////////////////////////// 
   }/////////////////////////////////////////////////// 
   tempFind.Close();///////////////// 
   if(!::RemoveDirectory (DirName))///////////////// 
  {////////////////////////////////// 
       MessageBox("删除目录失败!","警告信息",MB_OK);///////////////// 
       return FALSE;////////////////////////////////// 
   }////////////////////////////////// 
   return TRUE;////////////////////////////////// 
} 
*/ 
 
 
 
 
 
 
/* 
void CXingYunXingDlg::OnEndlabeleditList1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; 
	// TODO: Add your control notification handler code here 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
	int nIndex = m_list1.GetNextSelectedItem(pos); 
    strRename=pDispInfo->item.iItem; 
	strRename+="\\"; 
	strRename+=m_list1.GetItemText(nIndex,0); 
    strRename+=m_list1.GetItemText(nIndex,1); 
	    
 
	MoveFile(strOldName,strRename); 
	*pResult = 0; 
} 
 
void CXingYunXingDlg::OnBeginlabeleditList1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; 
	// TODO: Add your control notification handler code here 
	//LV_DISPINFO* pLVDI = (LV_DISPINFO*)pNMHDR; 
	POSITION pos = m_list1.GetFirstSelectedItemPosition();  
    int nIndex = m_list1.GetNextSelectedItem(pos); 
	if(pDispInfo->item.iItem==0)//判断是否取消该操作 
	 
	{ 
			 
		m_list1.SetItemText(pDispInfo->item.iItem,0,pDispInfo->item.pszText); 
		*pResult = 1; 
	} 
	else 
	{ 
		strOldName=m_list1.GetItemText(nIndex,3); 
		strOldName+="\\"; 
		strOldName+=m_list1.GetItemText(nIndex,0); 
		strOldName+=m_list1.GetItemText(nIndex,1);	 
		*pResult = 0; 
	} 
 
	// *pResult = 0; 
}*/ 
 
 
BOOL CXingYunXingDlg::PreTranslateMessage(MSG* pMsg)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
		if( pMsg->message==WM_KEYDOWN&&pMsg->wParam ==VK_RETURN) 
		{ 
			if(bReturnKey)  
			{ 
				hList=::GetDlgItem(m_hWnd ,IDC_LIST1); 
			    if(hList) 
				{ 
					OnEditItem(); 
		        return TRUE; 
				} 
			} 
		}	 
	 return CDialog::PreTranslateMessage(pMsg); 
} 
 
void CXingYunXingDlg::OnEditItem() 
{ 
	bReturnKey=FALSE; 
	CWnd* pwndCtrl = GetFocus(); 
    // get the control ID which is  
    // presently having the focus 
    int ctrl_ID = pwndCtrl->GetDlgCtrlID(); 
    CString str; 
         //get the text from the EditBox 
        GetDlgItemText(IDC_EDITITEM,str);	 
        //set the value in the listContorl with the 
        //specified Item & SubItem values 
        SetCell(::GetDlgItem (m_hWnd,IDC_LIST1), 
            str,nItem,nSubItem);		 
        ::SendDlgItemMessage(m_hWnd,IDC_EDITITEM, 
            WM_KILLFOCUS,0,0); 
        ::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDITITEM), 
            SW_HIDE); 
		POSITION pos = m_list1.GetFirstSelectedItemPosition();  
		int nIndex = m_list1.GetNextSelectedItem(pos); 
		 
		if(nItem==-1) 
		{ 
			return; 
		} 
		m_list1.SetItemText(nItem,0,str); 
		CString s1,s2,s3,s4,s5; 
		CString sG; 
		sG+=m_list1.GetItemText(nIndex,3); 
		 
		s5=m_list1.GetItemText(nIndex,0); 
		sG+="\\"; 
		str=sG+str; 
		sG=sG+s5; 
 
		sG+=m_list1.GetItemText(nIndex,1); 
		str+=m_list1.GetItemText(nIndex,1); 
		 
 
		s1=m_list1.GetItemText(nIndex,1); 
		s2=m_list1.GetItemText(nIndex,2); 
		s3=m_list1.GetItemText(nIndex,3); 
		s4=m_list1.GetItemText(nIndex,4); 
         
								 
 
								 
		m_list1.SetItemText(nItem,1,s1); 
		m_list1.SetItemText(nItem,2,s2); 
		m_list1.SetItemText(nItem,3,s3); 
		m_list1.SetItemText(nItem,4,s4); 
		 
	// 	::SendMessage(m_hWnd,WM_PAINT,0,0); 
 	m_list1.DeleteItem (nIndex); 
	if(str="")  
	{ 
		m_list1.SetItemText(nItem,0,s5); 
		return; 
	} 
        MoveFile(sG,str); 
 
 
 
		 
} 
CString CXingYunXingDlg::GetItemText(HWND hWnd, int nItem, int nSubItem) const 
{ 
	LVITEM lvi; 
	memset(&lvi, 0, sizeof(LVITEM)); 
	lvi.iSubItem = nSubItem; 
	CString str; 
	int nLen = 128; 
	int nRes; 
	do 
	{ 
		nLen *= 2; 
		lvi.cchTextMax = nLen; 
		lvi.pszText = str.GetBufferSetLength(nLen); 
		nRes  = (int)::SendMessage(hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, 
			(LPARAM)&lvi); 
	} while (nRes == nLen-1); 
	str.ReleaseBuffer(); 
	return str; 
} 
void CXingYunXingDlg::SetCell(HWND hWnd1, CString value, int nRow, int nCol) 
{ 
	TCHAR     szString [256]; 
	wsprintf(szString,value ,0); 
	 
	//Fill the LVITEM structure with the values given as parameters. 
	LVITEM lvItem; 
	lvItem.mask = LVIF_TEXT; 
	lvItem.iItem = nRow; 
	lvItem.pszText = szString; 
	lvItem.iSubItem = nCol; 
	if(nCol >0) 
		//set the value of listItem 
		::SendMessage(hWnd1,LVM_SETITEM, (WPARAM)0,(WPARAM)&lvItem); 
	else 
		//Insert the value into List 
		ListView_InsertItem(hWnd1,&lvItem); 
	 
}