Browse Source

Find dialog is not modal when search finishes + Its Focus button does not close the window

Source commit: 38c8537bd054d4dca24651708057d0fa163da34e
Martin Prikryl 9 years ago
parent
commit
ce439f45a1

+ 47 - 19
source/forms/CustomScpExplorer.cpp

@@ -306,6 +306,8 @@ __fastcall TCustomScpExplorerForm::~TCustomScpExplorerForm()
   ForceCloseLocalEditors();
   delete FLocalEditors;
 
+  HideFileFindDialog();
+
   if (FDelayedDeletionTimer)
   {
     DoDelayedDeletion(NULL);
@@ -5778,6 +5780,12 @@ void __fastcall TCustomScpExplorerForm::ExecuteCurrentFileWith(bool OnFocused)
 void __fastcall TCustomScpExplorerForm::TerminalRemoved(TObject * Sender)
 {
   FEditorManager->ProcessFiles(FileTerminalRemoved, Sender);
+
+  if (FFileFindTerminal == Sender)
+  {
+    FFileFindTerminal = NULL;
+    HideFileFindDialog();
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::FileTerminalRemoved(const UnicodeString FileName,
@@ -8381,15 +8389,17 @@ void __fastcall TCustomScpExplorerForm::StatusBarPanelDblClick(
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::LockWindow()
+void __fastcall TCustomScpExplorerForm::LockWindow(bool Force)
 {
   // workaround:
   // 1) for unknown reason, disabling window, while minimized,
   // prevents it from restoring, even if it was enabled again meanwhile
   // 2) when disabling the main window, while another has focus
-  // minimize is no longer possible ("keep up to date" dialog)
-  // Whouldn't we use IsApplicationMinimized() here?
-  if ((FLockSuspendLevel == 0) && !IsIconic(Application->Handle) && (Screen->ActiveForm == this))
+  // minimize is no longer possible
+  // ("keep up to date" dialog - though does not seem to be the case with "find file" -
+  // so it has probably something to do with the semi-modalness of the "keep up to date" dialog)
+  // Shouldn't we use IsApplicationMinimized() here?
+  if ((FLockSuspendLevel == 0) && !IsIconic(Application->Handle) && (Force || (Screen->ActiveForm == this)))
   {
     Enabled = false;
   }
@@ -8635,32 +8645,50 @@ void __fastcall TCustomScpExplorerForm::FormShow(TObject * /*Sender*/)
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::DoFindFiles(
-  UnicodeString Directory, const TFileMasks & FileMask,
+  TTerminal * ATerminal, UnicodeString Directory, const TFileMasks & FileMask,
   TFileFoundEvent OnFileFound, TFindingFileEvent OnFindingFile)
 {
-  Configuration->Usage->Inc(L"FileFinds");
-  FTerminal->FilesFind(Directory, FileMask, OnFileFound, OnFindingFile);
+  if (!NonVisualDataModule->Busy)
+  {
+    TTerminalManager::Instance()->ActiveTerminal = ATerminal;
+    Configuration->Usage->Inc(L"FileFinds");
+    LockWindow(true);
+    NonVisualDataModule->StartBusy();
+    WinConfiguration->LockedInterface = true;
+    try
+    {
+      FTerminal->FilesFind(Directory, FileMask, OnFileFound, OnFindingFile);
+    }
+    __finally
+    {
+      WinConfiguration->LockedInterface = false;
+      NonVisualDataModule->EndBusy();
+      UnlockWindow();
+    }
+  }
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::DoFocusRemotePath(UnicodeString Path)
+void __fastcall TCustomScpExplorerForm::DoFocusRemotePath(TTerminal * ATerminal, const UnicodeString & Path)
 {
-  RemoteDirView->Path = UnixExtractFilePath(Path);
-  TListItem * Item = RemoteDirView->FindFileItem(UnixExtractFileName(Path));
-  if (Item != NULL)
+  if (!NonVisualDataModule->Busy)
   {
-    RemoteDirView->ItemFocused = Item;
-    RemoteDirView->ItemFocused->MakeVisible(false);
-    RemoteDirView->SetFocus();
+    TTerminalManager::Instance()->ActiveTerminal = ATerminal;
+    SetFocus();
+    RemoteDirView->Path = UnixExtractFilePath(Path);
+    TListItem * Item = RemoteDirView->FindFileItem(UnixExtractFileName(Path));
+    if (Item != NULL)
+    {
+      RemoteDirView->ItemFocused = Item;
+      RemoteDirView->ItemFocused->MakeVisible(false);
+      RemoteDirView->SetFocus();
+    }
   }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemoteFindFiles()
 {
-  UnicodeString Path;
-  if (DoFileFindDialog(RemoteDirView->Path, DoFindFiles, Path))
-  {
-    DoFocusRemotePath(Path);
-  }
+  FFileFindTerminal = Terminal;
+  ShowFileFindDialog(Terminal, RemoteDirView->Path, DoFindFiles, DoFocusRemotePath);
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::UpdateTaskbarList(ITaskbarList3 * TaskbarList)

+ 4 - 3
source/forms/CustomScpExplorer.h

@@ -253,6 +253,7 @@ private:
   bool FStandaloneEditing;
   TFeedSynchronizeError FOnFeedSynchronizeError;
   bool FNeedSession;
+  TTerminal * FFileFindTerminal;
 
   bool __fastcall GetEnableFocusedOperation(TOperationSide Side, int FilesOnly);
   bool __fastcall GetEnableSelectedOperation(TOperationSide Side, int FilesOnly);
@@ -516,9 +517,9 @@ protected:
   virtual void __fastcall DestroyWnd();
   void __fastcall ClickToolbarItem(TTBCustomItem * Item, bool PositionCursor);
   virtual bool __fastcall OpenBookmark(UnicodeString Local, UnicodeString Remote);
-  void __fastcall DoFindFiles(UnicodeString Directory, const TFileMasks & FileMask,
+  void __fastcall DoFindFiles(TTerminal * Terminal, UnicodeString Directory, const TFileMasks & FileMask,
     TFileFoundEvent OnFileFound, TFindingFileEvent OnFindingFile);
-  virtual void __fastcall DoFocusRemotePath(UnicodeString Path);
+  virtual void __fastcall DoFocusRemotePath(TTerminal * Terminal, const UnicodeString & Path);
   bool __fastcall ExecuteFileOperation(TFileOperation Operation, TOperationSide Side,
     bool OnFocused, bool NoConfirmation = false, void * Param = NULL);
   void __fastcall UpdateCopyParamCounters(const TCopyParamType & CopyParam);
@@ -591,7 +592,7 @@ public:
     TCustomCommandType & CustomCommand, int & State);
   void __fastcall LastCustomCommand(bool OnFocused);
   void __fastcall BothCustomCommand(const TCustomCommandType & Command);
-  void __fastcall LockWindow();
+  void __fastcall LockWindow(bool Force = false);
   void __fastcall UnlockWindow();
   void __fastcall SuspendWindowLock();
   void __fastcall ResumeWindowLock();

+ 1 - 0
source/forms/Editor.cpp

@@ -998,6 +998,7 @@ void __fastcall TEditorForm::ApplyConfiguration()
   UpdateBackgroundColor();
   EditorMemo->Modified = PrevModified;
   EditorMemo->ClearUndo();
+  Enabled = !WinConfiguration->LockedInterface;
   UpdateControls();
 }
 //---------------------------------------------------------------------------

+ 128 - 71
source/forms/FileFind.cpp

@@ -10,6 +10,7 @@
 #include <CoreMain.h>
 #include <Tools.h>
 #include <BaseUtils.hpp>
+#include <Terminal.h>
 #include "FileFind.h"
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
@@ -21,30 +22,32 @@
 #pragma resource "*.dfm"
 #endif
 //---------------------------------------------------------------------------
-bool __fastcall DoFileFindDialog(UnicodeString Directory,
-  TFindEvent OnFind, UnicodeString & Path)
+TFileFindDialog * FileFindDialog = NULL;
+//---------------------------------------------------------------------------
+void __fastcall ShowFileFindDialog(
+  TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile)
 {
-  bool Result;
-  TFileFindDialog * Dialog = new TFileFindDialog(Application, OnFind);
-  try
+  if (FileFindDialog == NULL)
   {
-    Result = Dialog->Execute(Directory, Path);
+    FileFindDialog = new TFileFindDialog(Application);
   }
-  __finally
+  FileFindDialog->Init(Terminal, Directory, OnFind, OnFocusFile);
+  FileFindDialog->Show();
+}
+//---------------------------------------------------------------------------
+void __fastcall HideFileFindDialog()
+{
+  if (FileFindDialog != NULL)
   {
-    delete Dialog;
+    FileFindDialog->Close();
   }
-
-  return Result;
 }
 //---------------------------------------------------------------------------
-__fastcall TFileFindDialog::TFileFindDialog(TComponent * Owner, TFindEvent OnFind)
+__fastcall TFileFindDialog::TFileFindDialog(TComponent * Owner)
   : TForm(Owner)
 {
   UseSystemSettings(this);
-  FOnFind = OnFind;
   FState = ffInit;
-  FMinimizedByMe = false;
 
   FixComboBoxResizeBug(MaskEdit);
   FixComboBoxResizeBug(RemoteDirectoryEdit);
@@ -61,17 +64,27 @@ __fastcall TFileFindDialog::TFileFindDialog(TComponent * Owner, TFindEvent OnFin
   UseDesktopFont(FileView);
   UseDesktopFont(StatusBar);
 
-  SetGlobalMinimizeHandler(this, GlobalMinimize);
   FFrameAnimation.Init(AnimationPaintBox, L"Find");
   FixFormIcons(this);
 }
 //---------------------------------------------------------------------------
 __fastcall TFileFindDialog::~TFileFindDialog()
 {
-  ClearGlobalMinimizeHandler(GlobalMinimize);
+  TFindFileConfiguration FormConfiguration = CustomWinConfiguration->FindFile;
+  FormConfiguration.ListParams = FileView->ColProperties->ParamsStr;
+  UnicodeString WindowParams = StoreFormSize(this);
+  // this is particularly to prevent saving the form state
+  // for the first time, keeping default positioning by a system
+  if (!FWindowParams.IsEmpty() && (FWindowParams != WindowParams))
+  {
+    FormConfiguration.WindowParams = WindowParams;
+  }
+  CustomWinConfiguration->FindFile = FormConfiguration;
 
   Clear();
   delete FSystemImageList;
+  DebugAssert(FileFindDialog == this);
+  FileFindDialog = NULL;
 }
 //---------------------------------------------------------------------------
 bool __fastcall TFileFindDialog::IsFinding()
@@ -82,7 +95,7 @@ bool __fastcall TFileFindDialog::IsFinding()
 void __fastcall TFileFindDialog::UpdateControls()
 {
   bool Finding = IsFinding();
-  Caption = LoadStr(Finding ? FIND_FILE_FINDING : FIND_FILE_TITLE);
+  Caption = FORMAT("%s - %s", (LoadStr(Finding ? FIND_FILE_FINDING : FIND_FILE_TITLE), FTerminalName));
   UnicodeString StartStopCaption;
   if (Finding)
   {
@@ -95,9 +108,7 @@ void __fastcall TFileFindDialog::UpdateControls()
     StartStopCaption = LoadStr(FIND_FILE_START);
   }
   StartStopButton->Caption = StartStopCaption;
-  CancelButton->Visible = !Finding;
   EnableControl(FilterGroup, !Finding);
-  MinimizeButton->Visible = Finding;
   EnableControl(FocusButton, (FileView->ItemFocused != NULL));
   EnableControl(CopyButton, (FileView->Items->Count > 0));
   switch (FState)
@@ -137,30 +148,30 @@ void __fastcall TFileFindDialog::ControlChange(TObject * /*Sender*/)
   UpdateControls();
 }
 //---------------------------------------------------------------------------
-bool __fastcall TFileFindDialog::Execute(UnicodeString Directory, UnicodeString & Path)
+void __fastcall TFileFindDialog::Init(
+  TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile)
 {
-  MaskEdit->Text = WinConfiguration->SelectMask;
-  RemoteDirectoryEdit->Text = UnixExcludeTrailingBackslash(Directory);
-
-  // have to set history after value, to prevent autocompletition
-  MaskEdit->Items = WinConfiguration->History[L"Mask"];
-  RemoteDirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteDirectory"];
-
-  bool Result = (ShowModal() == FocusButton->ModalResult);
-  if (Result)
+  if (FTerminal != Terminal)
   {
-    Path = static_cast<TRemoteFile *>(FileView->ItemFocused->Data)->FullFileName;
-    // To make focussing directories work,
-    // otherwise it would try to focus "empty-named file" in the Path
-    Path = UnixExcludeTrailingBackslash(Path);
+    FTerminal = Terminal;
+    FTerminalName = Terminal->SessionData->SessionName;
+    Clear();
+    FState = ffInit;
+    ActiveControl = MaskEdit;
   }
 
-  TFindFileConfiguration FormConfiguration = CustomWinConfiguration->FindFile;
-  FormConfiguration.ListParams = FileView->ColProperties->ParamsStr;
-  FormConfiguration.WindowParams = StoreFormSize(this);
-  CustomWinConfiguration->FindFile = FormConfiguration;
+  FOnFind = OnFind;
+  FOnFocusFile = OnFocusFile;
 
-  return Result;
+  MaskEdit->Text = WinConfiguration->SelectMask;
+  RemoteDirectoryEdit->Text = UnixExcludeTrailingBackslash(Directory);
+  UpdateControls();
+}
+//---------------------------------------------------------------------------
+void __fastcall TFileFindDialog::CreateParams(TCreateParams & Params)
+{
+  TForm::CreateParams(Params);
+  Params.WndParent = GetDesktopWindow();
 }
 //---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::Clear()
@@ -209,7 +220,7 @@ void __fastcall TFileFindDialog::Start()
       FDirectory = UnicodeString();
     }
 
-    FOnFind(Directory, MaskEdit->Text, FileFound, FindingFile);
+    FOnFind(FTerminal, Directory, MaskEdit->Text, FileFound, FindingFile);
   }
   __finally
   {
@@ -223,13 +234,20 @@ void __fastcall TFileFindDialog::Start()
       FState = ffAborted;
     }
     FFrameAnimation.Stop();
-    if (IsApplicationMinimized() && FMinimizedByMe)
+    if (WindowState == wsMinimized)
     {
       ShowNotification(
         NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)),
         qtInformation);
-      FMinimizedByMe = false;
     }
+
+    if (!FFocusPath.IsEmpty())
+    {
+      UnicodeString FocusPath = FFocusPath;
+      FFocusPath = L"";
+      DoFocusFile(FocusPath);
+    }
+
     UpdateControls();
   }
 }
@@ -317,25 +335,25 @@ void __fastcall TFileFindDialog::Stop()
   UpdateControls();
 }
 //---------------------------------------------------------------------------
-void __fastcall TFileFindDialog::MinimizeButtonClick(TObject * Sender)
-{
-  CallGlobalMinimizeHandler(Sender);
-}
-//---------------------------------------------------------------------------
-void __fastcall TFileFindDialog::GlobalMinimize(TObject * /*Sender*/)
-{
-  ApplicationMinimize();
-  FMinimizedByMe = true;
-}
-//---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::FormShow(TObject * /*Sender*/)
 {
   InstallPathWordBreakProc(MaskEdit);
   InstallPathWordBreakProc(RemoteDirectoryEdit);
 
+  // have to set history after value, to prevent autocompletition
+  MaskEdit->Items = WinConfiguration->History[L"Mask"];
+  RemoteDirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteDirectory"];
+
   UpdateFormPosition(this, poOwnerFormCenter);
   RestoreFormSize(CustomWinConfiguration->FindFile.WindowParams, this);
   FileView->ColProperties->ParamsStr = CustomWinConfiguration->FindFile.ListParams;
+
+  DebugAssert(FWindowParams.IsEmpty());
+  if (FWindowParams.IsEmpty())
+  {
+    FWindowParams = StoreFormSize(this);
+  }
+
   UpdateControls();
 }
 //---------------------------------------------------------------------------
@@ -360,19 +378,47 @@ void __fastcall TFileFindDialog::HelpButtonClick(TObject * /*Sender*/)
   FormHelp(this);
 }
 //---------------------------------------------------------------------------
-void __fastcall TFileFindDialog::FormKeyDown(TObject * /*Sender*/, WORD & Key,
-  TShiftState Shift)
+void __fastcall TFileFindDialog::Dispatch(void * Message)
 {
-  if ((Key == VK_ESCAPE) && StopIfFinding())
+  TMessage * M = reinterpret_cast<TMessage*>(Message);
+  if (M->Msg == CM_DIALOGKEY)
   {
-    Key = 0;
+    CMDialogKey(*((TWMKeyDown *)Message));
   }
+  else
+  {
+    TForm::Dispatch(Message);
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TFileFindDialog::CMDialogKey(TWMKeyDown & Message)
+{
+  // Handling VK_ESCAPE in FormKeyDown causes a beep when any "edit" has focus.
+  // Moreover FormKeyDown is called when the the "esc" is pressed while drop down list is unrolled.
+  if (Message.CharCode == VK_ESCAPE)
+  {
+    Close();
+    Message.Result = 1;
+    return;
+  }
+  TForm::Dispatch(&Message);
+}
+//---------------------------------------------------------------------------
+void __fastcall TFileFindDialog::FormKeyDown(TObject * /*Sender*/, WORD & Key,
+  TShiftState Shift)
+{
   if ((Key == L'C') && Shift.Contains(ssCtrl) &&
       (dynamic_cast<TCustomCombo *>(ActiveControl) == NULL))
   {
     CopyToClipboard();
     Key = 0;
   }
+  else if ((Key == VK_F10) && Shift.Empty())
+  {
+    Key = 0;
+    StopIfFinding();
+    Close();
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::MaskEditExit(TObject * /*Sender*/)
@@ -380,18 +426,39 @@ void __fastcall TFileFindDialog::MaskEditExit(TObject * /*Sender*/)
   ValidateMaskEdit(MaskEdit);
 }
 //---------------------------------------------------------------------------
+void __fastcall TFileFindDialog::DoFocusFile(const UnicodeString & Path)
+{
+  FOnFocusFile(FTerminal, Path);
+}
+//---------------------------------------------------------------------------
+void __fastcall TFileFindDialog::FocusFile()
+{
+  UnicodeString Path = static_cast<TRemoteFile *>(FileView->ItemFocused->Data)->FullFileName;
+  // To make focussing directories work,
+  // otherwise it would try to focus "empty-named file" in the Path
+  Path = UnixExcludeTrailingBackslash(Path);
+
+  if (StopIfFinding())
+  {
+    FFocusPath = Path;
+  }
+  else
+  {
+    DoFocusFile(Path);
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::FileViewDblClick(TObject * /*Sender*/)
 {
   if (FileView->ItemFocused != NULL)
   {
-    StopIfFinding();
-    ModalResult = FocusButton->ModalResult;
+    FocusFile();
   }
 }
 //---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::FocusButtonClick(TObject * /*Sender*/)
 {
-  StopIfFinding();
+  FocusFile();
 }
 //---------------------------------------------------------------------------
 void __fastcall TFileFindDialog::FileViewSelectItem(TObject * /*Sender*/,
@@ -427,19 +494,9 @@ void __fastcall TFileFindDialog::CopyButtonClick(TObject * /*Sender*/)
   CopyToClipboard();
 }
 //---------------------------------------------------------------------------
-void __fastcall TFileFindDialog::Dispatch(void * Message)
+void __fastcall TFileFindDialog::FormClose(TObject * /*Sender*/, TCloseAction & Action)
 {
-  TMessage * M = reinterpret_cast<TMessage*>(Message);
-  if (M->Msg == WM_SYSCOMMAND)
-  {
-    if (!HandleMinimizeSysCommand(*M))
-    {
-      TForm::Dispatch(Message);
-    }
-  }
-  else
-  {
-    TForm::Dispatch(Message);
-  }
+  StopIfFinding();
+  Action = caFree;
 }
 //---------------------------------------------------------------------------

+ 6 - 27
source/forms/FileFind.dfm

@@ -1359,6 +1359,7 @@ object FileFindDialog: TFileFindDialog
   KeyPreview = True
   OldCreateOrder = False
   Position = poOwnerFormCenter
+  OnClose = FormClose
   OnCloseQuery = FormCloseQuery
   OnKeyDown = FormKeyDown
   OnShow = FormShow
@@ -1448,17 +1449,6 @@ object FileFindDialog: TFileFindDialog
       OnClick = MaskButtonClick
     end
   end
-  object CancelButton: TButton
-    Left = 476
-    Top = 43
-    Width = 80
-    Height = 25
-    Anchors = [akTop, akRight]
-    Cancel = True
-    Caption = 'Close'
-    ModalResult = 2
-    TabOrder = 2
-  end
   object StartStopButton: TButton
     Left = 476
     Top = 11
@@ -1472,12 +1462,12 @@ object FileFindDialog: TFileFindDialog
   end
   object HelpButton: TButton
     Left = 476
-    Top = 75
+    Top = 42
     Width = 80
     Height = 25
     Anchors = [akTop, akRight]
     Caption = '&Help'
-    TabOrder = 4
+    TabOrder = 2
     OnClick = HelpButtonClick
   end
   object FileView: TIEListView
@@ -1490,7 +1480,7 @@ object FileFindDialog: TFileFindDialog
     FullDrag = True
     ReadOnly = True
     RowSelect = True
-    TabOrder = 5
+    TabOrder = 3
     ViewStyle = vsReport
     OnDblClick = FileViewDblClick
     NortonLike = nlOff
@@ -1530,20 +1520,9 @@ object FileFindDialog: TFileFindDialog
     Height = 25
     Anchors = [akTop, akRight]
     Caption = 'Fo&cus'
-    ModalResult = 1
-    TabOrder = 6
+    TabOrder = 4
     OnClick = FocusButtonClick
   end
-  object MinimizeButton: TButton
-    Left = 476
-    Top = 43
-    Width = 80
-    Height = 25
-    Anchors = [akTop, akRight]
-    Caption = '&Minimize'
-    TabOrder = 3
-    OnClick = MinimizeButtonClick
-  end
   object CopyButton: TButton
     Left = 475
     Top = 173
@@ -1551,7 +1530,7 @@ object FileFindDialog: TFileFindDialog
     Height = 25
     Anchors = [akTop, akRight]
     Caption = '&Copy'
-    TabOrder = 7
+    TabOrder = 5
     OnClick = CopyButtonClick
   end
 end

+ 13 - 5
source/forms/FileFind.h

@@ -22,7 +22,6 @@ class TFileFindDialog : public TForm
 {
 __published:
   TGroupBox *FilterGroup;
-  TButton *CancelButton;
   TLabel *MaskLabel;
   TLabel *RemoteDirectoryLabel;
   THistoryComboBox *RemoteDirectoryEdit;
@@ -32,7 +31,6 @@ __published:
   TIEListView *FileView;
   TStatusBar *StatusBar;
   TButton *FocusButton;
-  TButton *MinimizeButton;
   TStaticText *MaskHintText;
   TButton *MaskButton;
   TPaintBox *AnimationPaintBox;
@@ -40,7 +38,6 @@ __published:
   void __fastcall ControlChange(TObject *Sender);
   void __fastcall StartStopButtonClick(TObject *Sender);
   void __fastcall StopButtonClick(TObject *Sender);
-  void __fastcall MinimizeButtonClick(TObject *Sender);
   void __fastcall FormShow(TObject *Sender);
   void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
   void __fastcall HelpButtonClick(TObject *Sender);
@@ -53,12 +50,14 @@ __published:
           bool Selected);
   void __fastcall MaskButtonClick(TObject *Sender);
   void __fastcall CopyButtonClick(TObject *Sender);
+  void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
 
 public:
-  __fastcall TFileFindDialog(TComponent * Owner, TFindEvent OnFind);
+  __fastcall TFileFindDialog(TComponent * Owner);
   virtual __fastcall ~TFileFindDialog();
 
-  bool __fastcall Execute(UnicodeString Directory, UnicodeString & Path);
+  void __fastcall Init(
+    TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile);
 
 protected:
   void __fastcall Clear();
@@ -69,22 +68,31 @@ protected:
   void __fastcall UpdateControls();
   bool __fastcall IsFinding();
 
+  virtual void __fastcall CreateParams(TCreateParams & Params);
   virtual void __fastcall Dispatch(void * Message);
 
 private:
   enum { ffInit, ffFinding, ffAborting, ffAborted, ffDone } FState;
   bool FMinimizedByMe;
+  TTerminal * FTerminal;
+  UnicodeString FTerminalName;
   UnicodeString FFindingInDirectory;
   UnicodeString FDirectory;
+  UnicodeString FWindowParams;
   TFindEvent FOnFind;
+  TFocusFileEvent FOnFocusFile;
   TImageList * FSystemImageList;
   TFrameAnimation FFrameAnimation;
+  UnicodeString FFocusPath;
 
   void __fastcall FileFound(TTerminal * Terminal,
     const UnicodeString FileName, const TRemoteFile * File, bool & Cancel);
   void __fastcall FindingFile(TTerminal * Terminal, const UnicodeString Directory,
     bool & Cancel);
   void __fastcall CopyToClipboard();
+  void __fastcall FocusFile();
+  void __fastcall DoFocusFile(const UnicodeString & Path);
+  void __fastcall CMDialogKey(TWMKeyDown & Message);
 };
 //---------------------------------------------------------------------------
 #endif

+ 2 - 2
source/forms/ScpCommander.cpp

@@ -2059,10 +2059,10 @@ void __fastcall TScpCommanderForm::QueueSubmenuItemPopup(
   NonVisualDataModule->QueueSpeedComboBoxItemUpdate(QueueSpeedComboBoxItem);
 }
 //---------------------------------------------------------------------------
-void __fastcall TScpCommanderForm::DoFocusRemotePath(UnicodeString Path)
+void __fastcall TScpCommanderForm::DoFocusRemotePath(TTerminal * Terminal, const UnicodeString & Path)
 {
   TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
-  TCustomScpExplorerForm::DoFocusRemotePath(Path);
+  TCustomScpExplorerForm::DoFocusRemotePath(Terminal, Path);
 }
 //---------------------------------------------------------------------------
 TOperationSide __fastcall TScpCommanderForm::GetOtherSize(TOperationSide Side)

+ 1 - 1
source/forms/ScpCommander.h

@@ -562,7 +562,7 @@ protected:
   virtual void __fastcall ToolbarItemResize(TTBXCustomDropDownItem * Item, int Width);
   void __fastcall DoOpenBookmark(UnicodeString Local, UnicodeString Remote);
   virtual bool __fastcall OpenBookmark(UnicodeString Local, UnicodeString Remote);
-  virtual void __fastcall DoFocusRemotePath(UnicodeString Path);
+  virtual void __fastcall DoFocusRemotePath(TTerminal * Terminal, const UnicodeString & Path);
   UnicodeString __fastcall ChangeFilePath(UnicodeString Path, TOperationSide Side);
   virtual bool __fastcall EligibleForImageDisplayMode(TTBCustomItem * Item);
   virtual bool __fastcall UpdateToolbarDisplayMode();

+ 6 - 0
source/windows/WinConfiguration.cpp

@@ -562,6 +562,7 @@ void __fastcall TWinConfiguration::Default()
   FTipsShown = Now();
   FRunsSinceLastTip = 0;
   FExtensionsDeleted = L"";
+  FLockedInterface = false;
 
   HonorDrivePolicy = true;
 
@@ -2460,6 +2461,11 @@ void __fastcall TWinConfiguration::SetCustomCommandOptions(TStrings * value)
   }
 }
 //---------------------------------------------------------------------------
+void __fastcall TWinConfiguration::SetLockedInterface(bool value)
+{
+  SET_CONFIG_PROPERTY(LockedInterface);
+}
+//---------------------------------------------------------------------------
 TStringList * __fastcall TWinConfiguration::LoadJumpList(
   THierarchicalStorage * Storage, UnicodeString Name)
 {

+ 3 - 0
source/windows/WinConfiguration.h

@@ -431,6 +431,7 @@ private:
   UnicodeString FTipsSeen;
   TDateTime FTipsShown;
   int FRunsSinceLastTip;
+  bool FLockedInterface;
   int FDontDecryptPasswords;
   int FMasterPasswordSession;
   bool FMasterPasswordSessionAsked;
@@ -533,6 +534,7 @@ private:
   TFont * __fastcall GetSystemIconFont();
   TStrings * __fastcall GetCustomCommandOptions();
   void __fastcall SetCustomCommandOptions(TStrings * value);
+  void __fastcall SetLockedInterface(bool value);
 
   bool __fastcall GetDDExtInstalled();
   void __fastcall AddVersionToHistory();
@@ -704,6 +706,7 @@ public:
   __property TMasterPasswordPromptEvent OnMasterPasswordPrompt = { read = FOnMasterPasswordPrompt, write = FOnMasterPasswordPrompt };
   __property TFont * SystemIconFont = { read = GetSystemIconFont };
   __property TStrings * CustomCommandOptions = { read = GetCustomCommandOptions, write = SetCustomCommandOptions };
+  __property bool LockedInterface = { read = FLockedInterface, write = SetLockedInterface };
 };
 //---------------------------------------------------------------------------
 class TCustomCommandType

+ 6 - 3
source/windows/WinInterface.h

@@ -412,10 +412,13 @@ bool __fastcall DoEditorPreferencesDialog(TEditorData * Editor,
 
 // forms\Find.cpp
 typedef void __fastcall (__closure *TFindEvent)
-  (UnicodeString Directory, const TFileMasks & FileMask,
+  (TTerminal * Terminal, UnicodeString Directory, const TFileMasks & FileMask,
    TFileFoundEvent OnFileFound, TFindingFileEvent OnFindingFile);
-bool __fastcall DoFileFindDialog(UnicodeString Directory,
-  TFindEvent OnFind, UnicodeString & Path);
+typedef void __fastcall (__closure *TFocusFileEvent)
+  (TTerminal * Terminal, const UnicodeString & Path);
+void __fastcall ShowFileFindDialog(
+  TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile);
+void __fastcall HideFileFindDialog();
 
 // forms\GenerateUrl.cpp
 void __fastcall DoGenerateUrlDialog(TSessionData * Data, TStrings * Paths);