Пример #1
0
void wxsNewWindowDlg::OnHeaderChanged(wxCommandEvent& event)
{
    if ( m_BlockText ) return;
    m_BlockText = true;
    m_SourceDirectory = GetPathPart(m_Header->GetValue());
    wxString Base = GetNoExt(m_Header->GetValue());
    if ( m_SourceNotTouched )
    {
        m_Source->SetValue(Base+_T(".cpp"));
    }
    if ( m_XrcNotTouched )
    {
        m_Xrc->SetValue(Base+_T(".h"));
    }
    m_HeaderNotTouched = false;
    m_BlockText = false;
}
Пример #2
0
// StripPath():
//  Strips the path off of a file.  This can do one of two things:
//  - if levels == DT_STRIP_ALL, then only the file part will be
//    returned.  This is effectively the same as GetFilePart
//  - if levels != DT_STRIP_ALL, then that number of directoires
//    is removed from the path, going from right to left,
//    effectively going backward that many directories.  The last
//    item on the line is considered to be a directory, even if
//    it really is a file.  Stripping can result in an empty output
//    buffer, since it will also remove the root directory (:) if
//    found.
char * DirStrings::StripPath( char *output, int levels ) {
  if( levels == DT_STRIP_ALL )
    return GetPathPart( output );
  
  for( int j = strlen( output )-1; (j >= 0) && (levels > 0); j-- ) {
    if( (output[j] == '\\') || (output[j] == '/' ) ) {  // Look for a / or \ and remove it
      output[j] = '\0';
      levels--;
    }

    if( output[j] == ':' ) {                            // Found a :; clear out the whole path
      output[0] = '\0';
      levels = 0;
    }
  }

  if( levels > 0 )
    output[0] = '\0';

  return output;
}
Пример #3
0
BOOL AppMainApp::InitInstance()
{
	pMainDialogWindowCrypt = NULL;
	pMainDialogWindow=NULL;
	if (!InitATL()){
		return FALSE;
	}
	{// На первый запуск...
		char sz1[128]={0};
		char sz2[128]="1";
		CString sAddCal;
		GetCommandLineParameter("addcal",sAddCal);
		if(sAddCal!=""){
			strcpy(sz1,sAddCal);
			SetRegSetting("", "FR_addCalendar", sz1);
			return FALSE;
		}
		CString sAddClo;
		GetCommandLineParameter("addclo",sAddClo);
		if(sAddClo!=""){
			strcpy(sz2,sAddClo);
			SetRegSetting("", "FR_addClock", sz2);
			return FALSE;
		}
		GetRegSetting("", "FR_addClock", sz1, sizeof(sz1));
		bAddOnStartClo=atol(sz1);
		GetRegSetting("", "FR_addCalendar", sz2, sizeof(sz2));
		bAddOnStartCal=atol(sz2);
	}
	{//setup_file
		// Регистрируем файл
		char szWkmRegistered[32]={0};
		GetRegSetting("", "wpc_setupRegistered", szWkmRegistered, sizeof(szWkmRegistered));
		if(szWkmRegistered[0]==0){
			strcpy(szWkmRegistered,"yes");
			SetRegSetting("", "wpc_setupRegistered", szWkmRegistered);
			RegisterExtension("wpc_setup","WireChanger setup file","-setup_file=");
		}
		CString sSetupFile;
		GetCommandLineParameter("setup_file",sSetupFile);
		if(sSetupFile!=""){
			if(isFileExist(sSetupFile)){
				CString sContent,sKeyPart;
				ReadFile(sSetupFile,sContent);
				CString sXML=CDataXMLSaver::GetInstringPart("<SETUP>","</SETUP>",sContent);
				if(sXML==""){
					sKeyPart=sContent;
				}
				// Делаем что сказано...
				if(sKeyPart!=""){
					SaveFile(GetUserFolder()+LICENSE_KEY_FILE,sKeyPart);
					AfxMessageBox(_l("Registration info installed successfully\nRestart WireChanger to see changes"));
				}
			}else{
				AfxMessageBox(Format("Reading setup file error: '%s' not found!",sSetupFile));
			}
			return FALSE;
		}
	}
	CString sExe;
	GetCommandLineParameter("add",sExe,0);
	if(sExe!=""){_XLOG_
		CString sNewFile=CString(GetApplicationDir())+WP_TEMPLATE+"\\"+GetPathPart(sExe,0,0,1,1);
		BOOL b=CopyFile(sExe,sNewFile,TRUE);
		if(!b){
			AfxMessageBox(_l("Error")+": "+_l("Widget already exist"));
		}
		return FALSE;
	}
    // Глобальные настройки
    CString sDats;
    ReadFile(CString(GetApplicationDir())+"inits.txt",sDats);
    AppName()=PROGNAME;
    AddDefsWallps()=1;
	AddDefsInteract()=1;
	if(sDats.GetLength()){
		CString sAppName=CDataXMLSaver::GetInstringPart("app:[","]",sDats);
		if(sAppName.GetLength()!=0){
			AppName()=sAppName;
		}
		AddDefsWallps()=atol(CDataXMLSaver::GetInstringPart("defs:[","]",sDats));
		AddDefsInteract()=atol(CDataXMLSaver::GetInstringPart("intr:[","]",sDats));
	}
    //===========
	CString sConsoleMode;
	GetCommandLineParameter("console",sConsoleMode);
	CString sIniFileInfo;
	ReadFile(CString(GetApplicationDir())+"install.ini",sIniFileInfo);
	if(sIniFileInfo!=""){
		sIniFileInfo+="\r\n";
	}
	if(sConsoleMode=="yes"){
		CString sConsoleSave,sConsoleRest;
		GetCommandLineParameter("wpsave",sConsoleSave);
		GetCommandLineParameter("wprestore",sConsoleRest);
		if(sConsoleSave=="yes"){
			if(sIniFileInfo.Find("[Main]")==-1){
				sIniFileInfo+="[Main]\r\n";
			}
			
			CString sAID,sDte;
			GetCommandLineParameter("affid",sAID);
			GetCommandLineParameter("date",sDte);
			if(sIniFileInfo.Find("AffId=")==-1){
				sIniFileInfo+=CString("AffId=")+sAID+"\r\n";
			}
			if(sIniFileInfo.Find("Date=")==-1){
				sIniFileInfo+=CString("Date=")+sDte+"\r\n";
			}
			if(sIniFileInfo.Find("CPD-W")==-1){
				CRegKey key;
				key.Open(HKEY_CURRENT_USER, "Control Panel\\Desktop");
				if(key!=NULL){
					char szTemp[MAX_PATH]="";
					DWORD lSize,dwType=0;
					lSize = MAX_PATH;
					if(RegQueryValueEx(key.m_hKey,"Wallpaper",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
						sIniFileInfo+="CPD-W=<";
						sIniFileInfo+=szTemp;
						sIniFileInfo+=">\r\n";
					}
					lSize = MAX_PATH;
					if(RegQueryValueEx(key.m_hKey,"WallpaperStyle",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
						sIniFileInfo+="CPD-WS=<";
						sIniFileInfo+=szTemp;
						sIniFileInfo+=">\r\n";
					}
					lSize = MAX_PATH;
					if(RegQueryValueEx(key.m_hKey,"TileWallpaper",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
						sIniFileInfo+="CPD-WT=<";
						sIniFileInfo+=szTemp;
						sIniFileInfo+=">\r\n";
					}
					lSize = MAX_PATH;
					if(RegQueryValueEx(key.m_hKey,"SCRNSAVE.EXE",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
						sIniFileInfo+="CPD-SS=<";
						sIniFileInfo+=szTemp;
						sIniFileInfo+=">\r\n";
					}
				}
				{// На дефолтного
					CRegKey key;
					key.Open(HKEY_USERS, ".DEFAULT\\Control Panel\\Desktop");
					if(key!=NULL){
						char szTemp[MAX_PATH]="";
						DWORD lSize,dwType=0;
						lSize = MAX_PATH;
						if(RegQueryValueEx(key.m_hKey,"Wallpaper",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
							sIniFileInfo+="DCPD-W=<";
							sIniFileInfo+=szTemp;
							sIniFileInfo+=">\r\n";
						}
						lSize = MAX_PATH;
						if(RegQueryValueEx(key.m_hKey,"WallpaperStyle",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
							sIniFileInfo+="DCPD-WS=<";
							sIniFileInfo+=szTemp;
							sIniFileInfo+=">\r\n";
						}
						lSize = MAX_PATH;
						if(RegQueryValueEx(key.m_hKey,"TileWallpaper",NULL, &dwType,(LPBYTE)szTemp, &lSize)== ERROR_SUCCESS){
							sIniFileInfo+="DCPD-WT=<";
							sIniFileInfo+=szTemp;
							sIniFileInfo+=">\r\n";
						}
					}
				}
			}
			if(sIniFileInfo.Find("UserData")==-1 || sIniFileInfo.Find("ConfigFile")==-1){
				sIniFileInfo+="ConfigFile=";
				sIniFileInfo+=objSettings.sIniFile;
				sIniFileInfo+="\r\n";
				sIniFileInfo+="UserData=";
				sIniFileInfo+=GetPathPart(objSettings.sIniFile,1,1,0,0);
				sIniFileInfo+="\r\n";
			}
			SaveFile(CString(GetApplicationDir())+"install.ini",sIniFileInfo);
		}else if(sConsoleRest=="yes"){
			if(sIniFileInfo==""){
				return 0;
			}
			RestoreWP(sIniFileInfo,1);
		}
		return FALSE;
	}
	CString sWait;
	GetCommandLineParameter("wait",sWait);
	DWORD dwStartWait=GetTickCount();
	if(sWait=="yes"){
		while(CheckProgrammRunState(NULL, UNIQUE_TO_TRUSTEE, false) && GetTickCount()-dwStartWait<180000){
			Sleep(1000);
		}
	}
	// Для нормально работы клонов
	if(IsThisProgrammAlreadyRunning()){
		// || IsOtherProgrammAlreadyRunning("WireChanger")
		DWORD dwTarget=BSM_APPLICATIONS;
		BroadcastSystemMessage(BSF_FORCEIFHUNG | BSF_IGNORECURRENTTASK | BSF_POSTMESSAGE, &dwTarget, iWM_THIS, WPARAM(99), LPARAM(99));
		return FALSE;
	}
	// Столбим уникальное за компьютером...
	CheckProgrammRunState("WC3",UNIQUE_TO_COMPUTER,1,"");
	CString sRestore;
	GetCommandLineParameter("restore",sRestore);
	if(sRestore!="" && isFileExist(sRestore)){
		CString sIniPath=GetPathPart(objSettings.sIniFile,1,1,0,0);
		{//Первый проход
			CZipArchive zipFile;
			if(zipFile.Open(sRestore)){
				ZIP_FIND_DATA pFind;
				HANDLE hSearch=zipFile.FindFirstFile("*.*",&pFind);
				while(zipFile.FindNextFile(hSearch, &pFind)){
					CString sFileName=pFind.szFileName;
					if(sFileName!=""){
						CZipFile zI;
						if(zipFile.GetFile(pFind.nDirIndex,&zI)){
							DeleteFile(sIniPath+sFileName);
							zI.SafeSaveToDosk(sIniPath+sFileName,0);
						}
					}
				}
				zipFile.FindClose(hSearch);
				zipFile.Close();
			}
		}
	}
	AfxEnableControlContainer();
	AfxInitRichEdit();
#if WINVER<=0x0050
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
#endif
	OleInitialize(NULL);
	//
	CRYPT_START
	objSettings.sLikUser="";
	objSettings.sLikKey="";
	HANDLE hLicenseFile=::CreateFile(GetUserFolder()+LICENSE_KEY_FILE, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
	if (!hLicenseFile || hLicenseFile==INVALID_HANDLE_VALUE){
		// Из локального каталога!
		hLicenseFile=::CreateFile(CString(GetApplicationDir())+LICENSE_KEY_FILE, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
	}
	if (hLicenseFile && hLicenseFile!=INVALID_HANDLE_VALUE){
		DWORD dwRead=0;
		char szKey[2048]="";
		objSettings.sLikKey="";
		::ReadFile(hLicenseFile, szKey, sizeof(szKey), &dwRead, NULL);
		objSettings.sLikUser=CDataXMLSaver::GetInstringPart("user:[","]",szKey);
		objSettings.sLikKey=CDataXMLSaver::GetInstringPart("key:[","]",szKey);
		::CloseHandle(hLicenseFile);
	}
#ifdef LIC_HARDCODED_U
	objSettings.sLikUser=LIC_HARDCODED_U;
#endif
#ifdef LIC_HARDCODED_K
	objSettings.sLikKey=LIC_HARDCODED_K;
#endif
	//if(sIniFileInfo.Find("WireChangerEF")!=-1){
		/*
		WC5Elefun	CCC2-HJ3S-88A6-C4TP
		*/
		/*
		WC5IPv6	4HVF-9XF6-DGQ2-94U2	
		*/
		/*
		WK999IPv6	EJCM-VNR7-GZ8F
		*/
		/*Mapi2Pop3
		IPv6	GT8N-6747-AGDM
		*/
		/*
		// Здесь поддержан элефан
		USE_ELEFUN=1;
		objSettings.sLikUser="******";
		objSettings.sLikKey=Recrypt("\xd3\x4c\xc3\x24\x84\x53\x3e\x2a\x2c\x21\x9e\x24\x48\x34\xb5\xb4");//"CCC2-HJ3S-88A6-C4TP";// EXECryptor_DecryptStr()?
		*/
	//}
	UpdateTrialityStatus(objSettings.sLikUser,objSettings.sLikKey);
	if(objSettings.iLikStatus<0){
		CSettings* objAntiDebug=0;
		objAntiDebug->ApplySettings();
		return FALSE;
	}
	CRYPT_END
	objSettings.Load();
	if(sConsoleMode=="help"){
		ShowHelp("Overview");
		return 0;
	}
	{// грузим ddown
		CBitmap bpTmp;
		bpTmp.LoadBitmap(IDB_DDOWN_A);
		_bmp().AddBmpRaw("DDOWN",&bpTmp,GetBitmapSize(bpTmp));
	}
	{// грузим remd
		CBitmap bpTmp;
		bpTmp.LoadBitmap(IDB_REMIND_A);
		_bmp().AddBmpRaw("REMINDER",&bpTmp,GetBitmapSize(bpTmp));
	}
	theApp.MainImageList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 0, 2);
	// Основные иконки
	AddBitmapToIList(theApp.MainImageList,IDB_IMAGELIST);
	for(int i=0;i<theApp.MainImageList.GetImageCount();i++){
		HICON hIcon=theApp.MainImageList.ExtractIcon(i);
		_bmp().AddBmp(_IL(i),hIcon);
		ClearIcon(hIcon);
	}
	_bmp().AddBmpRaw(IDB_BM_LOGO,CSize(LOGO_W,LOGO_H));
	// Пытаемся к пустому окну захимичится
	rFakedRect.SetRect(-10,0,0,0);
	LPCTSTR szClass = AfxRegisterWndClass(NULL);
	m_pFakeWnd = new CWnd;
	m_pFakeWnd->CreateEx(0, szClass, ROOT_WND_NAME, 0, rFakedRect, NULL, 0);
	m_pFakeWnd->ShowWindow(SW_HIDE);
	m_pFakeWnd->EnableWindow(FALSE);
	m_pFakeWnd->SetIcon(::AfxGetApp()->LoadIcon(MAIN_ICON),TRUE);
	m_pFakeWnd->SetIcon(::AfxGetApp()->LoadIcon(MAIN_ICON),FALSE);
	HotkeysSkipDD()=1;
	// Если при запуске небыло найдено ini-файла, показываем опции...
	if(objSettings.bStartWithOptions){
		objSettings.bStartWithOptions=FALSE;
		if(IsStartupWithWindows()==FALSE){
			StartupApplicationWithWindows(TRUE);
		}
		// точней больше не показываем
		// objSettings.OpenOptionsDialog();
	}
	
	// Создаем
	pMainDialogWindow = new AppMainDlg();
	pMainDialogWindowCrypt = pMainDialogWindow;
	if(!pMainDialogWindow){
		return FALSE;
	}
	theApp.m_pMainWnd=pMainDialogWindow;// Сначала задаем главное окно, потом создаем его
	pMainDialogWindow->Create(AppMainDlg::IDD,m_pFakeWnd);
	// Все!
	return TRUE;
}
Пример #4
0
int CALLBACK OptionsDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if(uMsg==WM_INITDIALOG){
		iBegin=0;
		iBegin2=0;
		hDiag=hwndDlg;
		bAutoDelRight=0;
		if(GetKeyState(VK_CONTROL)<0){
			bReplaceMode=1;
		}
		::SetWindowText(GetDlgItem(hwndDlg,IDC_STATUS),CString(" ")+_l("Preparing for search"));
		::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGL_DEL),_l("Delete this image"));
		::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL),_l("Delete this image"));
		::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),_l("Auto"));
		::SetWindowText(GetDlgItem(hwndDlg,IDC_LI_ST),_l("No image, please wait"));
		::SetWindowText(GetDlgItem(hwndDlg,IDC_RI_ST),_l("No image, please wait"));
		if(bReplaceMode){
			::SetWindowText(GetDlgItem(hwndDlg,ID_NEXT),"Stop renamer");
		}else{
			::SetWindowText(GetDlgItem(hwndDlg,ID_NEXT),_l("Stop processing"));
		}
		::SetWindowText(hwndDlg,_l("Search for duplicated images"));
		::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),FALSE);
		::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGL_DEL),FALSE);
		::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGR_DEL),FALSE);
		SetTaskbarButton(hwndDlg);
		//::EnableWindow(GetDlgItem(hwndDlg,ID_NEXT),FALSE);
	}
	if(uMsg==WM_KEYDOWN){
		if(GetKeyState(VK_CONTROL)<0){
			if(wParam==VK_RETURN){
				uMsg=WM_COMMAND;
				wParam=IDOK;
			}
		}
	}
	if(bStopCheck==0){
		if(uMsg==WM_COMMAND && wParam==WM_USER){
			// Выбираем у кого разрешение ниже...
			CString sPath;
			if(dwPathInRightRes<dwPathInLeftRes){
				uMsg=WM_COMMAND;
				wParam=IDC_IMGR_DEL;
			}else{
				uMsg=WM_COMMAND;
				wParam=IDC_IMGL_DEL;
			}
		}
		if(uMsg==WM_COMMAND && wParam==IDC_IMGL_DEL){
			if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_IMGL_DEL))){
				if(sPathInLeft!=""){
					sListOfImagesToDelete.Add(sPathInLeft);
				}
			}
			sPathInLeft="";
			sPathInRight="";
			uMsg=WM_COMMAND;
			wParam=ID_NEXT;
		}
		if(uMsg==WM_COMMAND && wParam==IDC_IMGR_DEL){
			if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_IMGR_DEL))){
				if(sPathInRight!=""){
					sListOfImagesToDelete.Add(sPathInRight);
				}
			}
			sPathInLeft="";
			sPathInRight="";
			uMsg=WM_COMMAND;
			wParam=ID_NEXT;
		}
		if(uMsg==WM_COMMAND && wParam==IDC_IMGR_DEL_ALL){
			if(bAutoDelRight || AfxMessageBox(_l("Delete duplicated images automatically")+"?",MB_YESNO|MB_ICONQUESTION)==IDYES){
				bAutoDelRight=1-bAutoDelRight;
				if(bAutoDelRight){
					::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),_l("Stop"));
					PostMessage(hwndDlg,WM_COMMAND,WM_USER,0);
				}else{
					::SetWindowText(GetDlgItem(hwndDlg,IDC_IMGR_DEL_ALL),_l("Auto"));
				}
			}
		}
		if(uMsg==WM_COMMAND && wParam==ID_NEXT){
			if(iMode==0){
				bStopLoad=1;
			}else if(bStopCheck==0){
				iBegin2++;
				::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGL_DEL),FALSE);
				::EnableWindow(GetDlgItem(hwndDlg,IDC_IMGR_DEL),FALSE);
				::EnableWindow(GetDlgItem(hwndDlg,ID_NEXT),FALSE);
				FORK(ContinueCheck,hwndDlg);
			}
		}
	}
	if(uMsg==WM_PAINT){
		PAINTSTRUCT lpPaint;
		memset(&lpPaint,0,sizeof(lpPaint));
		HDC dcH=BeginPaint(hwndDlg,&lpPaint);
		CDC dc;
		dc.Attach(lpPaint.hdc);
		dc.SetStretchBltMode(HALFTONE);
		//DefWindowProc(
		if(sPathInLeft!=""){
			if(btLeft){
				CRect rt,rtw;
				::GetClientRect(GetDlgItem(hwndDlg,IDC_IMGL),&rt);
				::GetWindowRect(GetDlgItem(hwndDlg,IDC_IMGL),&rtw);
				CPoint ptLT(rtw.left,rtw.top);
				ScreenToClient(hwndDlg,&ptLT);
				CDC dc2;
				CDesktopDC dcDesk;
				dc2.CreateCompatibleDC(&dcDesk);
				CBitmap* bmpTmp=dc2.SelectObject(btLeft);
				FitImageToRect(rt,szLeftSize);
				dc.StretchBlt(ptLT.x+rt.left,ptLT.y+rt.top,rt.Width(),rt.Height(),&dc2,0,0,szLeftSize.cx,szLeftSize.cy,SRCCOPY);
				dc2.SelectObject(bmpTmp);
			}
		}
		if(sPathInRight!=""){
			if(btRight){
				CRect rt,rtw;
				::GetClientRect(GetDlgItem(hwndDlg,IDC_IMGR),&rt);
				::GetWindowRect(GetDlgItem(hwndDlg,IDC_IMGR),&rtw);
				CPoint ptLT(rtw.left,rtw.top);
				ScreenToClient(hwndDlg,&ptLT);
				CDC dc2;
				CDesktopDC dcDesk;
				dc2.CreateCompatibleDC(&dcDesk);
				CBitmap* bmpTmp=dc2.SelectObject(btRight);
				FitImageToRect(rt,szLeftSize);
				dc.StretchBlt(ptLT.x+rt.left,ptLT.y+rt.top,rt.Width(),rt.Height(),&dc2,0,0,szRightSize.cx,szRightSize.cy,SRCCOPY);
				dc2.SelectObject(bmpTmp);
			}
		}
		dc.Detach();
		EndPaint(hwndDlg,&lpPaint);
		return TRUE;
	}
	if(uMsg==WM_SYSCOMMAND && wParam==SC_CLOSE){
		uMsg=WM_COMMAND;
		wParam=IDOK;
	}
	if(uMsg==WM_COMMAND && wParam==IDOK){
		bStopCheck=1;
		csCheck.Lock();
		csCheck.Unlock();
		if(sListOfImagesToDelete.GetSize()>0){
			if(dwDeleteOptions){
				if(AfxMessageBox(Format("%s. %s: %i\n%s?",_l("Search for duplicated images: finished"),_l("Image(s) found"),sListOfImagesToDelete.GetSize(),_l("Do you really want to delete image(s)")),MB_YESNO|MB_ICONQUESTION)==IDYES){
					for(int i=0;i<sListOfImagesToDelete.GetSize();i++){
						char szPath[MAX_PATH+2]="";
						memset(&szPath,0,sizeof(szPath));
						strcpy(szPath,sListOfImagesToDelete[i]);
						if(isFileExist(szPath)){
							SHFILEOPSTRUCT str;
							memset(&str,0,sizeof(str));
							str.hwnd=hwndDlg;
							str.wFunc=FO_DELETE;
							str.pFrom=szPath;
							str.pTo=NULL;
							str.fFlags=FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_SILENT;
							SHFileOperation(&str);
							lDeletedFiles++;
						}
					}
				}
			}else{
				lDeletedFiles+=sListOfImagesToDelete.GetSize();
			}
		}
		if(bReplaceMode){
			CString sDump;
			int ik=0;
			for(ik=0;ik<aClosestImage.GetSize();ik++){
				sDump+=Format("%i -> %i, %i %s\n",ik,aClosestImage[ik],aClosestImageTaken[ik],sListOfImages[ik]);
				aClosestImageTaken[ik]=0;
			}
			int iCnt=0;
			int iJumper=-1;
			CStringArray aFrom;
			CStringArray aFromTo;
			while(1){
				if(iJumper==-1){
					// Ищем первую картинку
					for(ik=0;ik<aClosestImage.GetSize();ik++){
						if(aClosestImageTaken[ik]==0){
							iJumper=ik;
							break;
						}
					}
				}
				if(iJumper==-1){
					// Не нашли!!
					break;
				}
				aClosestImageTaken[iJumper]=1;// Чтобы не циклится
				int iNext=aClosestImage[iJumper];
				if(iNext==-1 || aClosestImageTaken[iNext]!=0){
					iJumper=-1;
					continue;
				}
				CString sFrom=sListOfImages[iJumper];
				CString sTo=Format("%s%05i_%s",GetPathPart(sFrom,1,1,0,0),iCnt+1,GetPathPart(sFrom,0,0,1,1));
				aFrom.SetAtGrow(iCnt,sFrom);
				aFromTo.SetAtGrow(iCnt,sTo);
				sDump+=Format("Jumping %i -> %i\n",iJumper,iNext);
				iJumper=iNext;
				iCnt++;
			}
			SaveFile("f:\\rename.txt",sDump);
			for(int i=0;i<aFrom.GetSize();i++)
			{
				if(isFileExist(aFrom[i])){
					SHFILEOPSTRUCT str;
					memset(&str,0,sizeof(str));
					str.hwnd=hwndDlg;
					str.wFunc=FO_RENAME;
					
					char szPath[MAX_PATH+2]="";
					memset(&szPath,0,sizeof(szPath));
					strcpy(szPath,aFrom[i]);
					str.pFrom=szPath;
					
					char szPath2[MAX_PATH+2]="";
					memset(&szPath2,0,sizeof(szPath2));
					strcpy(szPath2,aFromTo[i]);
					str.pTo=szPath2;
					str.fFlags=FOF_NOCONFIRMATION|FOF_SILENT;
					SHFileOperation(&str);
				}
			}

		}
		EndDialog(hwndDlg,0);
		return TRUE;
	}
	if(uMsg==WM_NCDESTROY){
		SetEvent(hStopEvent);
	}
	return FALSE;
}