/* $ 30.07.2001 IS 1. Проверяем правильность параметров. 2. Теперь обработка каталогов не зависит от маски файлов 3. Маска может быть стандартного фаровского вида (со скобками, перечислением и пр.). Может быть несколько масок файлов, разделенных запятыми или точкой с запятой, можно указывать маски исключения, можно заключать маски в кавычки. Короче, все как и должно быть :-) */ void WINAPI FarRecursiveSearch(const wchar_t *InitDir,const wchar_t *Mask,FRSUSERFUNC Func,DWORD Flags,void *Param) { if (Func && InitDir && *InitDir && Mask && *Mask) { CFileMask FMask; if (!FMask.Set(Mask, FMF_SILENT)) return; Flags=Flags&0x000000FF; // только младший байт! ScanTree ScTree(Flags & FRS_RETUPDIR,Flags & FRS_RECUR, Flags & FRS_SCANSYMLINK); FAR_FIND_DATA_EX FindData; string strFullName; ScTree.SetFindPath(InitDir,L"*"); while (ScTree.GetNextName(&FindData,strFullName)) { if (FMask.Compare(FindData.strFileName)) { FAR_FIND_DATA fdata; apiFindDataExToData(&FindData, &fdata); if (!Func(&fdata,strFullName,Param)) { apiFreeFindData(&fdata); break; } apiFreeFindData(&fdata); } } } }
int GetDescriptionWidth(const wchar_t *Name=nullptr,const wchar_t *ShortName=nullptr) { int Width=0; RenumKeyRecord(FTS.Associations,FTS.TypeFmt,FTS.Type0); for (int NumLine=0;; NumLine++) { string strRegKey; strRegKey.Format(FTS.TypeFmt, NumLine); string strMask; if (!GetRegKey(strRegKey,FTS.Mask, strMask, L"")) break; CFileMask FMask; if (!FMask.Set(strMask, FMF_SILENT)) continue; string strDescription; GetRegKey(strRegKey,FTS.Desc,strDescription,L""); int CurWidth; if (!Name) CurWidth = HiStrlen(strDescription); else { if (!FMask.Compare(Name)) continue; string strExpandedDesc = strDescription; SubstFileName(strExpandedDesc,Name,ShortName,nullptr,nullptr,nullptr,nullptr,TRUE); CurWidth = HiStrlen(strExpandedDesc); } if (CurWidth>Width) Width=CurWidth; } if (Width>ScrX/2) Width=ScrX/2; return(Width); }
LONG_PTR WINAPI EditTypeRecordDlgProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2) { switch (Msg) { case DN_BTNCLICK: switch (Param1) { case ETR_COMBO_EXEC: case ETR_COMBO_ALTEXEC: case ETR_COMBO_VIEW: case ETR_COMBO_ALTVIEW: case ETR_COMBO_EDIT: case ETR_COMBO_ALTEDIT: SendDlgMessage(hDlg,DM_ENABLE,Param1+1,Param2==BSTATE_CHECKED?TRUE:FALSE); break; } break; case DN_CLOSE: if (Param1==ETR_BUTTON_OK) { BOOL Result=TRUE; LPCWSTR Masks=reinterpret_cast<LPCWSTR>(SendDlgMessage(hDlg,DM_GETCONSTTEXTPTR,ETR_EDIT_MASKS,0)); CFileMask FMask; if (!FMask.Set(Masks,0)) { Result=FALSE; } return Result; } break; } return DefDlgProc(hDlg,Msg,Param1,Param2); }
/* $ 06.07.2001 + Используем CFileMask вместо GetCommaWord, этим самым добиваемся того, что можно использовать маски исключения - Убрал непонятный мне запрет на использование маски файлов типа "*.*" (был когда-то, вроде, такой баг-репорт) */ bool ProcessLocalFileTypes(const wchar_t *Name, const wchar_t *ShortName, int Mode, bool AlwaysWaitFinish) { RenumKeyRecord(FTS.Associations,FTS.TypeFmt,FTS.Type0); MenuItemEx TypesMenuItem; VMenu TypesMenu(MSG(MSelectAssocTitle),nullptr,0,ScrY-4); TypesMenu.SetHelp(FTS.Help); TypesMenu.SetFlags(VMENU_WRAPMODE); TypesMenu.SetPosition(-1,-1,0,0); int DizWidth=GetDescriptionWidth(Name, ShortName); int ActualCmdCount=0; // отображаемых ассоциаций в меню CFileMask FMask; // для работы с масками файлов string strCommand, strDescription; int CommandCount=0; for (int I=0;; I++) { strCommand.Clear(); string strRegKey, strMask; strRegKey.Format(FTS.TypeFmt,I); if (!GetRegKey(strRegKey,FTS.Mask,strMask,L"")) break; if (FMask.Set(strMask,FMF_SILENT)) { if (FMask.Compare(Name)) { LPCWSTR Type=nullptr; switch (Mode) { case FILETYPE_EXEC: Type=FTS.Execute; break; case FILETYPE_VIEW: Type=FTS.View; break; case FILETYPE_EDIT: Type=FTS.Edit; break; case FILETYPE_ALTEXEC: Type=FTS.AltExec; break; case FILETYPE_ALTVIEW: Type=FTS.AltView; break; case FILETYPE_ALTEDIT: Type=FTS.AltEdit; break; } DWORD State=GetRegKey(strRegKey,FTS.State,0xffffffff); if (State&(1<<Mode)) { string strNewCommand; GetRegKey(strRegKey,Type,strNewCommand,L""); if (!strNewCommand.IsEmpty()) { strCommand = strNewCommand; GetRegKey(strRegKey,FTS.Desc,strDescription,L""); CommandCount++; } } } if (strCommand.IsEmpty()) continue; } TypesMenuItem.Clear(); string strCommandText = strCommand; SubstFileName(strCommandText,Name,ShortName,nullptr,nullptr,nullptr,nullptr,TRUE); // все "подставлено", теперь проверим условия "if exist" if (!ExtractIfExistCommand(strCommandText)) continue; ActualCmdCount++; string strMenuText; if (DizWidth) { string strTitle; if (!strDescription.IsEmpty()) { strTitle = strDescription; SubstFileName(strTitle, Name,ShortName,nullptr,nullptr,nullptr,nullptr,TRUE); } size_t Pos=0; bool Ampersand=strTitle.Pos(Pos,L'&'); if (DizWidth+Ampersand>ScrX/2 && Ampersand && static_cast<int>(Pos)>DizWidth) Ampersand=false; strMenuText.Format(L"%-*.*s %c ",DizWidth+Ampersand,DizWidth+Ampersand,strTitle.CPtr(),BoxSymbols[BS_V1]); } TruncStr(strCommandText,ScrX-DizWidth-14); strMenuText += strCommandText; TypesMenuItem.strName = strMenuText; TypesMenuItem.SetSelect(!I); TypesMenu.SetUserData(strCommand.CPtr(),0,TypesMenu.AddItem(&TypesMenuItem)); } if (!CommandCount) return false; if (!ActualCmdCount) return true; int ExitCode=0; if (ActualCmdCount>1) { TypesMenu.Process(); ExitCode=TypesMenu.Modal::GetExitCode(); if (ExitCode<0) return true; } int Size=TypesMenu.GetUserDataSize(ExitCode); LPWSTR Command=strCommand.GetBuffer(Size/sizeof(wchar_t)); TypesMenu.GetUserData(Command,Size,ExitCode); strCommand.ReleaseBuffer(Size); string strListName, strAnotherListName; string strShortListName, strAnotherShortListName; int PreserveLFN=SubstFileName(strCommand,Name,ShortName,&strListName,&strAnotherListName, &strShortListName, &strAnotherShortListName); bool ListFileUsed=!strListName.IsEmpty()||!strAnotherListName.IsEmpty()||!strShortListName.IsEmpty()||!strAnotherShortListName.IsEmpty(); // Снова все "подставлено", теперь проверим условия "if exist" if (ExtractIfExistCommand(strCommand)) { PreserveLongName PreserveName(ShortName,PreserveLFN); RemoveExternalSpaces(strCommand); if (!strCommand.IsEmpty()) { bool isSilent=(strCommand.At(0)==L'@'); if (isSilent) { strCommand.LShift(1); } ProcessOSAliases(strCommand); if (!isSilent) { CtrlObject->CmdLine->ExecString(strCommand,AlwaysWaitFinish, false, false, ListFileUsed); if (!(Opt.ExcludeCmdHistory&EXCLUDECMDHISTORY_NOTFARASS) && !AlwaysWaitFinish) //AN CtrlObject->CmdHistory->AddToHistory(strCommand); } else { #if 1 SaveScreen SaveScr; CtrlObject->Cp()->LeftPanel->CloseFile(); CtrlObject->Cp()->RightPanel->CloseFile(); Execute(strCommand,AlwaysWaitFinish, 0, 0, 0, ListFileUsed, true); #else // здесь была бага с прорисовкой (и... вывод данных // на команду "@type !@!" пропадал с экрана) // сделаем по аналогии с CommandLine::CmdExecute() { RedrawDesktop RdrwDesktop(TRUE); Execute(strCommand,AlwaysWaitFinish, 0, 0, 0, ListFileUsed); ScrollScreen(1); // обязательно, иначе деструктор RedrawDesktop // проредравив экран забьет последнюю строку вывода. } CtrlObject->Cp()->LeftPanel->UpdateIfChanged(UIC_UPDATE_FORCE); CtrlObject->Cp()->RightPanel->UpdateIfChanged(UIC_UPDATE_FORCE); CtrlObject->Cp()->Redraw(); #endif } if (FrameManager->GetCurrentFrame()->GetType()==MODALTYPE_VIEWER) { TypesMenu.ResetCursor(); } } } if (!strListName.IsEmpty()) apiDeleteFile(strListName); if (!strAnotherListName.IsEmpty()) apiDeleteFile(strAnotherListName); if (!strShortListName.IsEmpty()) apiDeleteFile(strShortListName); if (!strAnotherShortListName.IsEmpty()) apiDeleteFile(strAnotherShortListName); return true; }
bool FileFilterConfig(FileFilterParams *FF, bool ColorConfig) { const wchar_t VerticalLine[] = {BoxSymbols[BS_T_H1V1],BoxSymbols[BS_V1],BoxSymbols[BS_V1],BoxSymbols[BS_V1],BoxSymbols[BS_B_H1V1],0}; // Временная маска. CFileMask FileMask; // История для маски файлов const wchar_t FilterMasksHistoryName[] = L"FilterMasks"; // История для имени фильтра const wchar_t FilterNameHistoryName[] = L"FilterName"; // Маски для диалога настройки // Маска для ввода дней для относительной даты const wchar_t DaysMask[] = L"9999"; string strDateMask, strTimeMask; // Определение параметров даты и времени в системе. wchar_t DateSeparator=GetDateSeparator(); wchar_t TimeSeparator=GetTimeSeparator(); wchar_t DecimalSeparator=GetDecimalSeparator(); int DateFormat=GetDateFormat(); switch (DateFormat) { case 0: // Маска даты для форматов DD.MM.YYYYY и MM.DD.YYYYY strDateMask = FormatString() << L"99" << DateSeparator << "99" << DateSeparator << "9999N"; break; case 1: // Маска даты для форматов DD.MM.YYYYY и MM.DD.YYYYY strDateMask = FormatString() << L"99" << DateSeparator << "99" << DateSeparator << "9999N"; break; default: // Маска даты для формата YYYYY.MM.DD strDateMask = FormatString() << L"N9999" << DateSeparator << "c99" << DateSeparator << "c99"; break; } // Маска времени strTimeMask = FormatString() << L"99" << TimeSeparator << "99" << TimeSeparator << "99" << DecimalSeparator << "999"; FarDialogItem FilterDlgData[]= { {DI_DOUBLEBOX,3,1,76,20,0,nullptr,nullptr,DIF_SHOWAMPERSAND,MSG(MFileFilterTitle)}, {DI_TEXT,5,2,0,2,0,nullptr,nullptr,DIF_FOCUS,MSG(MFileFilterName)}, {DI_EDIT,5,2,74,2,0,FilterNameHistoryName,nullptr,DIF_HISTORY,L""}, {DI_TEXT,0,3,0,3,0,nullptr,nullptr,DIF_SEPARATOR,L""}, {DI_CHECKBOX,5,4,0,4,0,nullptr,nullptr,DIF_AUTOMATION,MSG(MFileFilterMatchMask)}, {DI_EDIT,5,4,74,4,0,FilterMasksHistoryName,nullptr,DIF_HISTORY,L""}, {DI_TEXT,0,5,0,5,0,nullptr,nullptr,DIF_SEPARATOR,L""}, {DI_CHECKBOX,5,6,0,6,0,nullptr,nullptr,DIF_AUTOMATION,MSG(MFileFilterSize)}, {DI_TEXT,7,7,8,7,0,nullptr,nullptr,0,MSG(MFileFilterSizeFromSign)}, {DI_EDIT,10,7,20,7,0,nullptr,nullptr,0,L""}, {DI_TEXT,7,8,8,8,0,nullptr,nullptr,0,MSG(MFileFilterSizeToSign)}, {DI_EDIT,10,8,20,8,0,nullptr,nullptr,0,L""}, {DI_CHECKBOX,24,6,0,6,0,nullptr,nullptr,DIF_AUTOMATION,MSG(MFileFilterDate)}, {DI_COMBOBOX,26,7,41,7,0,nullptr,nullptr,DIF_DROPDOWNLIST|DIF_LISTNOAMPERSAND,L""}, {DI_CHECKBOX,26,8,0,8,0,nullptr,nullptr,0,MSG(MFileFilterDateRelative)}, {DI_TEXT,48,7,50,7,0,nullptr,nullptr,0,MSG(MFileFilterDateBeforeSign)}, {DI_FIXEDIT,51,7,61,7,0,nullptr,strDateMask.CPtr(),DIF_MASKEDIT,L""}, {DI_FIXEDIT,51,7,61,7,0,nullptr,DaysMask,DIF_MASKEDIT,L""}, {DI_FIXEDIT,63,7,74,7,0,nullptr,strTimeMask.CPtr(),DIF_MASKEDIT,L""}, {DI_TEXT,48,8,50,8,0,nullptr,nullptr,0,MSG(MFileFilterDateAfterSign)}, {DI_FIXEDIT,51,8,61,8,0,nullptr,strDateMask.CPtr(),DIF_MASKEDIT,L""}, {DI_FIXEDIT,51,8,61,8,0,nullptr,DaysMask,DIF_MASKEDIT,L""}, {DI_FIXEDIT,63,8,74,8,0,nullptr,strTimeMask.CPtr(),DIF_MASKEDIT,L""}, {DI_BUTTON,0,6,0,6,0,nullptr,nullptr,DIF_BTNNOCLOSE,MSG(MFileFilterCurrent)}, {DI_BUTTON,0,6,74,6,0,nullptr,nullptr,DIF_BTNNOCLOSE,MSG(MFileFilterBlank)}, {DI_TEXT,0,9,0,9,0,nullptr,nullptr,DIF_SEPARATOR,L""}, {DI_VTEXT,22,5,22,9,0,nullptr,nullptr,DIF_BOXCOLOR,VerticalLine}, {DI_CHECKBOX, 5,10,0,10,0,nullptr,nullptr,DIF_AUTOMATION,MSG(MFileFilterAttr)}, {DI_CHECKBOX, 7,11,0,11,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrR)}, {DI_CHECKBOX, 7,12,0,12,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrA)}, {DI_CHECKBOX, 7,13,0,13,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrH)}, {DI_CHECKBOX, 7,14,0,14,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrS)}, {DI_CHECKBOX,29,11,0,11,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrD)}, {DI_CHECKBOX,29,12,0,12,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrC)}, {DI_CHECKBOX,29,13,0,13,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrE)}, {DI_CHECKBOX,29,14,0,14,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrNI)}, {DI_CHECKBOX,29,15,0,15,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrReparse)}, {DI_CHECKBOX,51,11,0,11,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrSparse)}, {DI_CHECKBOX,51,12,0,12,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrT)}, {DI_CHECKBOX,51,13,0,13,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrOffline)}, {DI_CHECKBOX,51,14,0,14,0,nullptr,nullptr,DIF_3STATE,MSG(MFileFilterAttrVirtual)}, {DI_TEXT,-1,14,0,14,0,nullptr,nullptr,DIF_SEPARATOR,MSG(MHighlightColors)}, {DI_TEXT,7,15,0,15,0,nullptr,nullptr,0,MSG(MHighlightMarkChar)}, {DI_FIXEDIT,5,15,5,15,0,nullptr,nullptr,0,L""}, {DI_CHECKBOX,0,15,0,15,0,nullptr,nullptr,0,MSG(MHighlightTransparentMarkChar)}, {DI_BUTTON,5,16,0,16,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightFileName1)}, {DI_BUTTON,0,16,0,16,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightMarking1)}, {DI_BUTTON,5,17,0,17,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightFileName2)}, {DI_BUTTON,0,17,0,17,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightMarking2)}, {DI_BUTTON,5,18,0,18,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightFileName3)}, {DI_BUTTON,0,18,0,18,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightMarking3)}, {DI_BUTTON,5,19,0,19,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightFileName4)}, {DI_BUTTON,0,19,0,19,0,nullptr,nullptr,DIF_BTNNOCLOSE|DIF_NOBRACKETS,MSG(MHighlightMarking4)}, {DI_USERCONTROL,73-15-1,16,73-2,19,0,nullptr,nullptr,DIF_NOFOCUS,L""}, {DI_CHECKBOX,5,20,0,20,0,nullptr,nullptr,0,MSG(MHighlightContinueProcessing)}, {DI_TEXT,0,16,0,16,0,nullptr,nullptr,DIF_SEPARATOR,L""}, {DI_CHECKBOX,5,17,0,17,0,nullptr,nullptr,0,MSG(MFileHardLinksCount)},//добавляем новый чекбокс в панель {DI_TEXT,0,18,0,18,0,nullptr,nullptr,DIF_SEPARATOR,L""},// и разделитель {DI_BUTTON,0,19,0,19,0,nullptr,nullptr,DIF_DEFAULTBUTTON|DIF_CENTERGROUP,MSG(MOk)}, {DI_BUTTON,0,19,0,19,0,nullptr,nullptr,DIF_CENTERGROUP|DIF_BTNNOCLOSE,MSG(MFileFilterReset)}, {DI_BUTTON,0,19,0,19,0,nullptr,nullptr,DIF_CENTERGROUP,MSG(MFileFilterCancel)}, {DI_BUTTON,0,19,0,19,0,nullptr,nullptr,DIF_CENTERGROUP|DIF_BTNNOCLOSE,MSG(MFileFilterMakeTransparent)}, }; FilterDlgData[0].Data=MSG(ColorConfig?MFileHilightTitle:MFileFilterTitle); MakeDialogItemsEx(FilterDlgData,FilterDlg); if (ColorConfig) { FilterDlg[ID_FF_TITLE].Y2+=5; for (int i=ID_FF_NAME; i<=ID_FF_SEPARATOR1; i++) FilterDlg[i].Flags|=DIF_HIDDEN; for (int i=ID_FF_MATCHMASK; i<=ID_FF_VIRTUAL; i++) { FilterDlg[i].Y1-=2; FilterDlg[i].Y2-=2; } for (int i=ID_FF_SEPARATOR5; i<=ID_FF_MAKETRANSPARENT; i++) { FilterDlg[i].Y1+=5; FilterDlg[i].Y2+=5; } } else { for (int i=ID_HER_SEPARATOR1; i<=ID_HER_CONTINUEPROCESSING; i++) FilterDlg[i].Flags|=DIF_HIDDEN; FilterDlg[ID_FF_MAKETRANSPARENT].Flags=DIF_HIDDEN; } FilterDlg[ID_FF_NAMEEDIT].X1=FilterDlg[ID_FF_NAME].X1+(int)FilterDlg[ID_FF_NAME].strData.GetLength()-(FilterDlg[ID_FF_NAME].strData.Contains(L'&')?1:0)+1; FilterDlg[ID_FF_MASKEDIT].X1=FilterDlg[ID_FF_MATCHMASK].X1+(int)FilterDlg[ID_FF_MATCHMASK].strData.GetLength()-(FilterDlg[ID_FF_MATCHMASK].strData.Contains(L'&')?1:0)+5; FilterDlg[ID_FF_BLANK].X1=FilterDlg[ID_FF_BLANK].X2-(int)FilterDlg[ID_FF_BLANK].strData.GetLength()+(FilterDlg[ID_FF_BLANK].strData.Contains(L'&')?1:0)-3; FilterDlg[ID_FF_CURRENT].X2=FilterDlg[ID_FF_BLANK].X1-2; FilterDlg[ID_FF_CURRENT].X1=FilterDlg[ID_FF_CURRENT].X2-(int)FilterDlg[ID_FF_CURRENT].strData.GetLength()+(FilterDlg[ID_FF_CURRENT].strData.Contains(L'&')?1:0)-3; FilterDlg[ID_HER_MARKTRANSPARENT].X1=FilterDlg[ID_HER_MARK_TITLE].X1+(int)FilterDlg[ID_HER_MARK_TITLE].strData.GetLength()-(FilterDlg[ID_HER_MARK_TITLE].strData.Contains(L'&')?1:0)+1; for (int i=ID_HER_NORMALMARKING; i<=ID_HER_SELECTEDCURSORMARKING; i+=2) FilterDlg[i].X1=FilterDlg[ID_HER_NORMALFILE].X1+(int)FilterDlg[ID_HER_NORMALFILE].strData.GetLength()-(FilterDlg[ID_HER_NORMALFILE].strData.Contains(L'&')?1:0)+1; FAR_CHAR_INFO VBufColorExample[15*4]= {}; HighlightDataColor Colors; FF->GetColors(&Colors); HighlightDlgUpdateUserControl(VBufColorExample,Colors); FilterDlg[ID_HER_COLOREXAMPLE].VBuf=VBufColorExample; wchar_t MarkChar[] = {static_cast<wchar_t>(Colors.MarkChar), 0}; FilterDlg[ID_HER_MARKEDIT].strData=MarkChar; FilterDlg[ID_HER_MARKTRANSPARENT].Selected=(Colors.MarkChar&0xFF0000?1:0); FilterDlg[ID_HER_CONTINUEPROCESSING].Selected=(FF->GetContinueProcessing()?1:0); FilterDlg[ID_FF_NAMEEDIT].strData = FF->GetTitle(); const wchar_t *FMask; FilterDlg[ID_FF_MATCHMASK].Selected=FF->GetMask(&FMask)?1:0; FilterDlg[ID_FF_MASKEDIT].strData=FMask; if (!FilterDlg[ID_FF_MATCHMASK].Selected) FilterDlg[ID_FF_MASKEDIT].Flags|=DIF_DISABLE; const wchar_t *SizeAbove, *SizeBelow; FilterDlg[ID_FF_MATCHSIZE].Selected=FF->GetSize(&SizeAbove,&SizeBelow)?1:0; FilterDlg[ID_FF_SIZEFROMEDIT].strData=SizeAbove; FilterDlg[ID_FF_SIZETOEDIT].strData=SizeBelow; FilterDlg[ID_FF_HARDLINKS].Selected=FF->GetHardLinks(nullptr,nullptr)?1:0; //пока что мы проверям только флаг использования данного условия if (!FilterDlg[ID_FF_MATCHSIZE].Selected) for (int i=ID_FF_SIZEFROMSIGN; i <= ID_FF_SIZETOEDIT; i++) FilterDlg[i].Flags|=DIF_DISABLE; // Лист для комбобокса времени файла FarList DateList= {sizeof(FarList)}; FarListItem TableItemDate[FDATE_COUNT]= {}; // Настройка списка типов дат файла DateList.Items=TableItemDate; DateList.ItemsNumber=FDATE_COUNT; for (int i=0; i < FDATE_COUNT; ++i) TableItemDate[i].Text=MSG(MFileFilterWrited+i); DWORD DateType; FILETIME DateAfter, DateBefore; bool bRelative; FilterDlg[ID_FF_MATCHDATE].Selected=FF->GetDate(&DateType,&DateAfter,&DateBefore,&bRelative)?1:0; FilterDlg[ID_FF_DATERELATIVE].Selected=bRelative?1:0; FilterDlg[ID_FF_DATETYPE].ListItems=&DateList; TableItemDate[DateType].Flags=LIF_SELECTED; if (bRelative) { ConvertRelativeDate(DateAfter, FilterDlg[ID_FF_DAYSAFTEREDIT].strData, FilterDlg[ID_FF_TIMEAFTEREDIT].strData); ConvertRelativeDate(DateBefore, FilterDlg[ID_FF_DAYSBEFOREEDIT].strData, FilterDlg[ID_FF_TIMEBEFOREEDIT].strData); } else { ConvertDate(DateAfter,FilterDlg[ID_FF_DATEAFTEREDIT].strData,FilterDlg[ID_FF_TIMEAFTEREDIT].strData,12,FALSE,FALSE,2); ConvertDate(DateBefore,FilterDlg[ID_FF_DATEBEFOREEDIT].strData,FilterDlg[ID_FF_TIMEBEFOREEDIT].strData,12,FALSE,FALSE,2); } if (!FilterDlg[ID_FF_MATCHDATE].Selected) for (int i=ID_FF_DATETYPE; i <= ID_FF_BLANK; i++) FilterDlg[i].Flags|=DIF_DISABLE; DWORD AttrSet, AttrClear; FilterDlg[ID_FF_MATCHATTRIBUTES].Selected=FF->GetAttr(&AttrSet,&AttrClear)?1:0; FilterDlg[ID_FF_READONLY].Selected=(AttrSet & FILE_ATTRIBUTE_READONLY?1:AttrClear & FILE_ATTRIBUTE_READONLY?0:2); FilterDlg[ID_FF_ARCHIVE].Selected=(AttrSet & FILE_ATTRIBUTE_ARCHIVE?1:AttrClear & FILE_ATTRIBUTE_ARCHIVE?0:2); FilterDlg[ID_FF_HIDDEN].Selected=(AttrSet & FILE_ATTRIBUTE_HIDDEN?1:AttrClear & FILE_ATTRIBUTE_HIDDEN?0:2); FilterDlg[ID_FF_SYSTEM].Selected=(AttrSet & FILE_ATTRIBUTE_SYSTEM?1:AttrClear & FILE_ATTRIBUTE_SYSTEM?0:2); FilterDlg[ID_FF_COMPRESSED].Selected=(AttrSet & FILE_ATTRIBUTE_COMPRESSED?1:AttrClear & FILE_ATTRIBUTE_COMPRESSED?0:2); FilterDlg[ID_FF_ENCRYPTED].Selected=(AttrSet & FILE_ATTRIBUTE_ENCRYPTED?1:AttrClear & FILE_ATTRIBUTE_ENCRYPTED?0:2); FilterDlg[ID_FF_DIRECTORY].Selected=(AttrSet & FILE_ATTRIBUTE_DIRECTORY?1:AttrClear & FILE_ATTRIBUTE_DIRECTORY?0:2); FilterDlg[ID_FF_NOTINDEXED].Selected=(AttrSet & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED?1:AttrClear & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED?0:2); FilterDlg[ID_FF_SPARSE].Selected=(AttrSet & FILE_ATTRIBUTE_SPARSE_FILE?1:AttrClear & FILE_ATTRIBUTE_SPARSE_FILE?0:2); FilterDlg[ID_FF_TEMP].Selected=(AttrSet & FILE_ATTRIBUTE_TEMPORARY?1:AttrClear & FILE_ATTRIBUTE_TEMPORARY?0:2); FilterDlg[ID_FF_REPARSEPOINT].Selected=(AttrSet & FILE_ATTRIBUTE_REPARSE_POINT?1:AttrClear & FILE_ATTRIBUTE_REPARSE_POINT?0:2); FilterDlg[ID_FF_OFFLINE].Selected=(AttrSet & FILE_ATTRIBUTE_OFFLINE?1:AttrClear & FILE_ATTRIBUTE_OFFLINE?0:2); FilterDlg[ID_FF_VIRTUAL].Selected=(AttrSet & FILE_ATTRIBUTE_VIRTUAL?1:AttrClear & FILE_ATTRIBUTE_VIRTUAL?0:2); if (!FilterDlg[ID_FF_MATCHATTRIBUTES].Selected) { for (int i=ID_FF_READONLY; i <= ID_FF_VIRTUAL; i++) FilterDlg[i].Flags|=DIF_DISABLE; } Dialog Dlg(FilterDlg,ARRAYSIZE(FilterDlg),FileFilterConfigDlgProc,ColorConfig?&Colors:nullptr); Dlg.SetHelp(ColorConfig?L"HighlightEdit":L"Filter"); Dlg.SetPosition(-1,-1,FilterDlg[ID_FF_TITLE].X2+4,FilterDlg[ID_FF_TITLE].Y2+2); Dlg.SetAutomation(ID_FF_MATCHMASK,ID_FF_MASKEDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHSIZE,ID_FF_SIZEFROMSIGN,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHSIZE,ID_FF_SIZEFROMEDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHSIZE,ID_FF_SIZETOSIGN,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHSIZE,ID_FF_SIZETOEDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DATETYPE,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DATERELATIVE,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DATEAFTERSIGN,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DATEAFTEREDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DAYSAFTEREDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_TIMEAFTEREDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DATEBEFORESIGN,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DATEBEFOREEDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_DAYSBEFOREEDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_TIMEBEFOREEDIT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_CURRENT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHDATE,ID_FF_BLANK,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_READONLY,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_ARCHIVE,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_HIDDEN,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_SYSTEM,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_COMPRESSED,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_ENCRYPTED,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_NOTINDEXED,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_SPARSE,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_TEMP,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_REPARSEPOINT,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_OFFLINE,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_VIRTUAL,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); Dlg.SetAutomation(ID_FF_MATCHATTRIBUTES,ID_FF_DIRECTORY,DIF_DISABLE,DIF_NONE,DIF_NONE,DIF_DISABLE); for (;;) { Dlg.ClearDone(); Dlg.Process(); int ExitCode=Dlg.GetExitCode(); if (ExitCode==ID_FF_OK) // Ok { // Если введённая пользователем маска не корректна, тогда вернёмся в диалог if (FilterDlg[ID_FF_MATCHMASK].Selected && !FileMask.Set(FilterDlg[ID_FF_MASKEDIT].strData,0)) continue; if (FilterDlg[ID_HER_MARKTRANSPARENT].Selected) Colors.MarkChar|=0x00FF0000; else Colors.MarkChar&=0x0000FFFF; FF->SetColors(&Colors); FF->SetContinueProcessing(FilterDlg[ID_HER_CONTINUEPROCESSING].Selected!=0); FF->SetTitle(FilterDlg[ID_FF_NAMEEDIT].strData); FF->SetMask(FilterDlg[ID_FF_MATCHMASK].Selected!=0, FilterDlg[ID_FF_MASKEDIT].strData); FF->SetSize(FilterDlg[ID_FF_MATCHSIZE].Selected!=0, FilterDlg[ID_FF_SIZEFROMEDIT].strData, FilterDlg[ID_FF_SIZETOEDIT].strData); FF->SetHardLinks(FilterDlg[ID_FF_HARDLINKS].Selected!=0,0,0); //пока устанавливаем только флаг использования признака bRelative = FilterDlg[ID_FF_DATERELATIVE].Selected!=0; LPWSTR TimeBefore = FilterDlg[ID_FF_TIMEBEFOREEDIT].strData.GetBuffer(); TimeBefore[8] = TimeSeparator; FilterDlg[ID_FF_TIMEBEFOREEDIT].strData.ReleaseBuffer(FilterDlg[ID_FF_TIMEBEFOREEDIT].strData.GetLength()); LPWSTR TimeAfter = FilterDlg[ID_FF_TIMEAFTEREDIT].strData.GetBuffer(); TimeAfter[8] = TimeSeparator; FilterDlg[ID_FF_TIMEAFTEREDIT].strData.ReleaseBuffer(FilterDlg[ID_FF_TIMEAFTEREDIT].strData.GetLength()); StrToDateTime(FilterDlg[bRelative?ID_FF_DAYSAFTEREDIT:ID_FF_DATEAFTEREDIT].strData,FilterDlg[ID_FF_TIMEAFTEREDIT].strData,DateAfter,DateFormat,DateSeparator,TimeSeparator,bRelative); StrToDateTime(FilterDlg[bRelative?ID_FF_DAYSBEFOREEDIT:ID_FF_DATEBEFOREEDIT].strData,FilterDlg[ID_FF_TIMEBEFOREEDIT].strData,DateBefore,DateFormat,DateSeparator,TimeSeparator,bRelative); FF->SetDate(FilterDlg[ID_FF_MATCHDATE].Selected!=0, FilterDlg[ID_FF_DATETYPE].ListPos, DateAfter, DateBefore, bRelative); AttrSet=0; AttrClear=0; AttrSet|=(FilterDlg[ID_FF_READONLY].Selected==1?FILE_ATTRIBUTE_READONLY:0); AttrSet|=(FilterDlg[ID_FF_ARCHIVE].Selected==1?FILE_ATTRIBUTE_ARCHIVE:0); AttrSet|=(FilterDlg[ID_FF_HIDDEN].Selected==1?FILE_ATTRIBUTE_HIDDEN:0); AttrSet|=(FilterDlg[ID_FF_SYSTEM].Selected==1?FILE_ATTRIBUTE_SYSTEM:0); AttrSet|=(FilterDlg[ID_FF_COMPRESSED].Selected==1?FILE_ATTRIBUTE_COMPRESSED:0); AttrSet|=(FilterDlg[ID_FF_ENCRYPTED].Selected==1?FILE_ATTRIBUTE_ENCRYPTED:0); AttrSet|=(FilterDlg[ID_FF_DIRECTORY].Selected==1?FILE_ATTRIBUTE_DIRECTORY:0); AttrSet|=(FilterDlg[ID_FF_NOTINDEXED].Selected==1?FILE_ATTRIBUTE_NOT_CONTENT_INDEXED:0); AttrSet|=(FilterDlg[ID_FF_SPARSE].Selected==1?FILE_ATTRIBUTE_SPARSE_FILE:0); AttrSet|=(FilterDlg[ID_FF_TEMP].Selected==1?FILE_ATTRIBUTE_TEMPORARY:0); AttrSet|=(FilterDlg[ID_FF_REPARSEPOINT].Selected==1?FILE_ATTRIBUTE_REPARSE_POINT:0); AttrSet|=(FilterDlg[ID_FF_OFFLINE].Selected==1?FILE_ATTRIBUTE_OFFLINE:0); AttrSet|=(FilterDlg[ID_FF_VIRTUAL].Selected==1?FILE_ATTRIBUTE_VIRTUAL:0); AttrClear|=(FilterDlg[ID_FF_READONLY].Selected==0?FILE_ATTRIBUTE_READONLY:0); AttrClear|=(FilterDlg[ID_FF_ARCHIVE].Selected==0?FILE_ATTRIBUTE_ARCHIVE:0); AttrClear|=(FilterDlg[ID_FF_HIDDEN].Selected==0?FILE_ATTRIBUTE_HIDDEN:0); AttrClear|=(FilterDlg[ID_FF_SYSTEM].Selected==0?FILE_ATTRIBUTE_SYSTEM:0); AttrClear|=(FilterDlg[ID_FF_COMPRESSED].Selected==0?FILE_ATTRIBUTE_COMPRESSED:0); AttrClear|=(FilterDlg[ID_FF_ENCRYPTED].Selected==0?FILE_ATTRIBUTE_ENCRYPTED:0); AttrClear|=(FilterDlg[ID_FF_DIRECTORY].Selected==0?FILE_ATTRIBUTE_DIRECTORY:0); AttrClear|=(FilterDlg[ID_FF_NOTINDEXED].Selected==0?FILE_ATTRIBUTE_NOT_CONTENT_INDEXED:0); AttrClear|=(FilterDlg[ID_FF_SPARSE].Selected==0?FILE_ATTRIBUTE_SPARSE_FILE:0); AttrClear|=(FilterDlg[ID_FF_TEMP].Selected==0?FILE_ATTRIBUTE_TEMPORARY:0); AttrClear|=(FilterDlg[ID_FF_REPARSEPOINT].Selected==0?FILE_ATTRIBUTE_REPARSE_POINT:0); AttrClear|=(FilterDlg[ID_FF_OFFLINE].Selected==0?FILE_ATTRIBUTE_OFFLINE:0); AttrClear|=(FilterDlg[ID_FF_VIRTUAL].Selected==0?FILE_ATTRIBUTE_VIRTUAL:0); FF->SetAttr(FilterDlg[ID_FF_MATCHATTRIBUTES].Selected!=0, AttrSet, AttrClear); return true; } else break; } return false; }