Ejemplo n.º 1
0
HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) {
  setImage(Icon::Device::Keyboard);
  setText("Hotkeys");

  layout.setMargin(5);
  mappingList.onActivate([&] { assignMapping(); });
  mappingList.onChange([&] {
    eraseButton.setEnabled((bool)mappingList.selected());
  });
  resetButton.setText("Reset").onActivate([&] {
    if(MessageDialog("Are you sure you want to erase all hotkey mappings?").setParent(*settingsManager).question() == "Yes") {
      for(auto& mapping : inputManager->hotkeys) mapping->unbind();
      refreshMappings();
    }
  });
  eraseButton.setText("Erase").onActivate([&] {
    if(auto item = mappingList.selected()) {
      inputManager->hotkeys[item->offset()]->unbind();
      refreshMappings();
    }
  });

  reloadMappings();
  refreshMappings();
}
Ejemplo n.º 2
0
void CGameGUIFileDialog::ProcessSelect()
{
	std::string sFile=m_sFile;
	if(m_piEDPath){sFile=m_piEDPath->GetText();}
	
	if(FileIsDirectory(sFile.c_str()))
	{
	  UpdateFiles();
	  return;
	}
	
	if(m_bOpenMode)
	{
	  if(!FileExists(sFile.c_str()))
	  {
		MessageDialog((std::string)"The file '"+sFile+"' does not exist.","Error",eMessageDialogType_Error);
		if(m_piEDPath){m_piGUIManager->SetFocus(m_piEDPath);}
		return;
	  }
	}
	else
	{
	  if(FileExists(sFile.c_str()) && m_bOverWriteWarn)
	  {
		if(ConfirmDialog((std::string)"Overwrite '"+sFile+"' ?.","Warning!",eMessageDialogType_Warning)!=DIALOG_OK)
		{
		  if(m_piEDPath){m_piGUIManager->SetFocus(m_piEDPath);}
		  return;
		}
	  }
	}
	m_sFile=sFile;
	EndDialog(DIALOG_OK);
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeProgressForm::CancelButtonClick(TObject * /*Sender*/)
{
    if (!FCanceled && (MessageDialog(LoadStr(CANCEL_OPERATION2), qtConfirmation,
                                     qaOK | qaCancel, HELP_NONE) == qaOK))
    {
        FCanceled = true;
    }
}
Ejemplo n.º 4
0
void MainWindow::onPreferencesPressed()
{
	ConfigDialog configdialog;
	if (configdialog.exec()) {
		util::Config::instance().save("data/config.xml");
		MessageDialog("The configuration has been saved.", "You should restart the program in order to activate the changes.",
				gui::MessageDialog::QINFO);
	} else {
		util::Config::instance().destroy();
		util::Config::instance().load("data/config.xml");
	}
}
Ejemplo n.º 5
0
//---------------------------------------------------------------------------
void __fastcall TEditorForm::Reload()
{
  if (!EditorMemo->Modified ||
      (MessageDialog(MainInstructions(LoadStr(EDITOR_MODIFIED_RELOAD)), qtConfirmation,
        qaOK | qaCancel) != qaCancel))
  {
    if (FOnFileReload)
    {
      FOnFileReload(this);
    }
    LoadFile();
  }
}
Ejemplo n.º 6
0
  /// Called from Message() for MSG_EDIT (when a user double-clicks
  /// the object icon). Toggles the protection state of the container.
  void ToggleProtect(BaseObject* op)
  {
    BaseDocument* doc = op->GetDocument();
    if (doc)
    {
      doc->StartUndo();
      doc->AddUndo(UNDOTYPE_CHANGE_SMALL, op);
      doc->EndUndo();
    }

    BaseContainer const* bc = op->GetDataInstance();
    if (!bc) return;

    if (!m_protected)
    {
      String password;
      if (!PasswordDialog(&password, false, true)) return;
      String hashed = HashString(password);
      m_protected = true;
      m_protectionHash = hashed;

      HideNodes(op, doc, true);
    }
    else
    {
      String password;
      Bool unlock = false;
      String emptyPassHash = HashString("");
      if (m_protectionHash == emptyPassHash)
      {
        unlock = true;
      }
      else if (PasswordDialog(&password, true, true))
      {
        unlock = (m_protectionHash == HashString(password));
        if (!unlock)
          MessageDialog(GeLoadString(IDS_PASSWORD_INVALID));
      }
      if (unlock)
      {
        m_protected = false;
        HideNodes(op, doc, false);
      }
    }

    op->Message(MSG_CHANGE);
    op->SetDirty(DIRTYFLAGS_DESCRIPTION);
    EventAdd();
  }
Ejemplo n.º 7
0
//---------------------------------------------------------------------------
void __fastcall TEditorForm::FormCloseQuery(TObject * /*Sender*/,
      bool &CanClose)
{
  if (EditorMemo->Modified)
  {
    SetFocus();
    UnicodeString Message = MainInstructions(LoadStr(SAVE_CHANGES));
    unsigned int Answer = MessageDialog(Message, qtConfirmation,
      qaYes | qaNo | qaCancel);
    CanClose = (Answer != qaCancel);
    if (Answer == qaYes)
    {
      SaveAction->Execute();
    }
  }
}
void CEntityEditorClassSelector::ProcessSelect()
{
	if(m_piLSClasses)
	{
		if(m_piLSClasses->GetSelectedElement()==-1)
		{
			MessageDialog((std::string)"Please select a class","Error",eMessageDialogType_Error);
			m_piGUIManager->SetFocus(m_piLSClasses);
			return;
		}
		else
		{
			m_sSelectedClass=m_piLSClasses->GetElement(m_piLSClasses->GetSelectedElement());
		}
	}
	EndDialog(DIALOG_OK);
}
Ejemplo n.º 9
0
//---------------------------------------------------------------------------
void __fastcall TFullSynchronizeDialog::FormCloseQuery(TObject * /*Sender*/,
        bool & CanClose)
{
    if ((ModalResult == DefaultResult(this)) &&
            SaveSettings && (FOrigMode != Mode) && !FSaveMode)
    {
        switch (MessageDialog(LoadStr(SAVE_SYNCHRONIZE_MODE2),
                              qtConfirmation, qaYes | qaNo | qaCancel, HELP_SYNCHRONIZE_SAVE_MODE))
        {
        case qaYes:
            FSaveMode = true;
            break;

        case qaCancel:
            CanClose = false;
            break;
        }
    }
}
Ejemplo n.º 10
0
Bool MenuTest::Execute(BaseDocument* doc)
{
	ControlThread ct;
	String msg;

	GeShowMouse(MOUSE_BUSY);
	if (ct.Start())
	{
		ct.Wait();
		msg = ct.GetResult();
	}
	else
		msg = "Thread start failed";
	GeShowMouse(MOUSE_NORMAL);

	MessageDialog(msg);

	return true;
}
Ejemplo n.º 11
0
//---------------------------------------------------------------------------
void __fastcall ImportSitesIfAny()
{
    if (!WinConfiguration->AutoImportedFromPuttyOrFilezilla)
    {
        bool AnyPuttySession = GUIConfiguration->AnyPuttySessionForImport(StoredSessions);
        bool AnyFilezillaSession = GUIConfiguration->AnyFilezillaSessionForImport(StoredSessions);

        if (AnyPuttySession || AnyFilezillaSession)
        {
            UnicodeString PuttySource = LoadStrPart(IMPORT_SESSIONS2, 2);
            UnicodeString FilezillaSource = LoadStrPart(IMPORT_SESSIONS2, 3);
            UnicodeString Source;
            if (AnyPuttySession && AnyFilezillaSession)
            {
                Source = FORMAT(LoadStrPart(IMPORT_SESSIONS2, 4), (PuttySource, FilezillaSource));
            }
            else if (AnyPuttySession)
            {
                Source = PuttySource;
            }
            else if (AnyFilezillaSession)
            {
                Source = FilezillaSource;
            }
            else
            {
                FAIL;
            }

            UnicodeString Message = FORMAT(LoadStrPart(IMPORT_SESSIONS2, 1), (Source));

            if (MessageDialog(Message, qtConfirmation,
                              qaYes | qaNo, HELP_IMPORT_SESSIONS) == qaYes)
            {
                DoImportSessionsDialog(NULL);
            }

            WinConfiguration->AutoImportedFromPuttyOrFilezilla = true;
        }
    }
}
Ejemplo n.º 12
0
InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) {
  setIcon(Icon::Device::Joypad);
  setText("Input");

  layout.setMargin(5);
  focusLabel.setText("When Focus is Lost:");
  pauseEmulation.setText("Pause Emulation").setChecked(settings["Input/FocusLoss/Pause"].boolean()).onToggle([&] {
    settings["Input/FocusLoss/Pause"].setValue(pauseEmulation.checked());
    allowInput.setEnabled(!pauseEmulation.checked());
  }).doToggle();
  allowInput.setText("Allow Input").setChecked(settings["Input/FocusLoss/AllowInput"].boolean()).onToggle([&] {
    settings["Input/FocusLoss/AllowInput"].setValue(allowInput.checked());
  });
  for(auto& emulator : inputManager->emulators) {
    emulatorList.append(ComboButtonItem().setText(emulator.name));
  }
  emulatorList.onChange([&] { reloadPorts(); });
  portList.onChange([&] { reloadDevices(); });
  deviceList.onChange([&] { reloadMappings(); });
  mappingList.onActivate([&] { assignMapping(); });
  mappingList.onChange([&] { updateControls(); });
  assignMouse1.setVisible(false).onActivate([&] { assignMouseInput(0); });
  assignMouse2.setVisible(false).onActivate([&] { assignMouseInput(1); });
  assignMouse3.setVisible(false).onActivate([&] { assignMouseInput(2); });
  resetButton.setText("Reset").onActivate([&] {
    if(MessageDialog("Are you sure you want to erase all mappings for this device?").setParent(*settingsManager).question() == "Yes") {
      for(auto& mapping : activeDevice().mappings) mapping->unbind();
      refreshMappings();
    }
  });
  eraseButton.setText("Erase").onActivate([&] {
    if(auto mapping = mappingList.selected()) {
      activeDevice().mappings[mapping->offset()]->unbind();
      refreshMappings();
    }
  });

  reloadPorts();
}
Ejemplo n.º 13
0
//---------------------------------------------------------------------------
void __fastcall TCopyDialog::FormCloseQuery(TObject * /*Sender*/,
      bool &CanClose)
{
  if (ModalResult == DefaultResult(this))
  {
    if (!RemotePaths() && ((FOptions & coTemp) == 0))
    {
      UnicodeString Dir = Directory;
      UnicodeString Drive = ExtractFileDrive(Dir);
      if (!DirectoryExists(Dir))
      {
        if (MessageDialog(MainInstructions(FMTLOAD(CREATE_LOCAL_DIRECTORY, (Dir))),
              qtConfirmation, qaOK | qaCancel, HELP_NONE) != qaCancel)
        {
          if (!ForceDirectories(Dir))
          {
            SimpleErrorDialog(FMTLOAD(CREATE_LOCAL_DIR_ERROR, (Dir)));
            CanClose = false;
          }
        }
        else
        {
          CanClose = False;
        }
      }

      if (!CanClose)
      {
        DirectoryEdit->SelectAll();
        DirectoryEdit->SetFocus();
      }
    };

    if (CanClose)
    {
      ExitActiveControl(this);
    }
  }
}
Ejemplo n.º 14
0
//---------------------------------------------------------------------------
void __fastcall TLocationProfilesDialog::RemoveBookmark(TObject * Sender)
{
  TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  TTreeView * ProfilesView = GetProfilesView(Sender);
  TStringList * Folders = GetFolders(Sender);

  assert(ProfilesView->Selected);
  TTreeNode * Node = ProfilesView->Selected;
  if (Node->Data)
  {
    BookmarkList->Delete((TBookmark *)Node->Data);
    TTreeNode * ParentNode = Node->Parent;
    Node->Delete();
    if (ParentNode && !ParentNode->Count)
    {
      assert(Folders->IndexOfObject(ParentNode) >= 0);
      Folders->Delete(Folders->IndexOfObject(ParentNode));
      ParentNode->Delete();
    }
  }
  else
  {
    UnicodeString Message = MainInstructions(LoadStr(DELETE_BOOKMARK_FOLDER));
    if (MessageDialog(Message, qtConfirmation,
          qaYes | qaNo, HELP_LOCATION_PROFILE_DELETE) == qaYes)
    {
      assert(Node->Count);
      for (int i = 0; i < Node->Count; i++)
      {
        BookmarkList->Delete((TBookmark *)Node->Item[i]->Data);
      }
      assert(Folders->IndexOfObject(Node) >= 0);
      Folders->Delete(Folders->IndexOfObject(Node));
      Node->Delete();
    }
  }
  UpdateControls();
}
Ejemplo n.º 15
0
//---------------------------------------------------------------------------
void __fastcall TEditorForm::ChangeEncoding(TEncoding * Encoding)
{
  if (FEncoding != Encoding)
  {
    if (!EditorMemo->Modified ||
        (MessageDialog(MainInstructions(LoadStr(EDITOR_MODIFIED_ENCODING)), qtConfirmation,
          qaOK | qaCancel) != qaCancel))
    {
      TEncoding * PrevEncoding = FEncoding;
      try
      {
        FEncoding = Encoding;
        LoadFile();
      }
      catch(...)
      {
        // try to restore
        FEncoding = PrevEncoding;
        LoadFile();
        throw;
      }
    }
  }
}
Ejemplo n.º 16
0
//---------------------------------------------------------------------------
void __fastcall TRemoteTransferDialog::FormCloseQuery(TObject * /*Sender*/,
  bool & /*CanClose*/)
{
  if (ModalResult == DefaultResult(this))
  {
    if ((SessionCombo->ItemIndex == FCurrentSession) &&
        (FAllowDirectCopy == drcConfirmCommandSession) &&
        !NotDirectCopyCheck->Checked &&
        GUIConfiguration->ConfirmCommandSession)
    {
      TMessageParams Params(mpNeverAskAgainCheck);
      unsigned int Answer = MessageDialog(LoadStr(REMOTE_COPY_COMMAND_SESSION2),
        qtConfirmation, qaOK | qaCancel, HelpKeyword, &Params);
      if (Answer == qaNeverAskAgain)
      {
        GUIConfiguration->ConfirmCommandSession = false;
      }
      else if (Answer != qaOK)
      {
        Abort();
      }
    }
  }
}
Ejemplo n.º 17
0
bool C4Application::DoInit(int argc, char * argv[])
{
	assert(AppState == C4AS_None);
	// Config overwrite by parameter
	StdStrBuf sConfigFilename;
	for (int32_t iPar=0; iPar < argc; iPar++)
		if (SEqual2NoCase(argv[iPar], "--config="))
			sConfigFilename.Copy(argv[iPar] + 9);
	// Config check
	Config.Init();
	Config.Load(sConfigFilename.getData());
	Config.Save();
	// sometimes, the configuration can become corrupted due to loading errors or w/e
	// check this and reset defaults if necessary
	if (Config.IsCorrupted())
	{
		if (sConfigFilename)
		{
			// custom config corrupted: Fail
			Log("ERROR: Custom configuration corrupted - program abort!\n");
			return false;
		}
		else
		{
			// default config corrupted: Restore default
			Log("Warning: Configuration corrupted - restoring default!\n");
			Config.Default();
			Config.Save();
			Config.Load();
		}
	}
	// Open log
	OpenLog();

	Revision.Ref(C4REVISION);

	// Engine header message
	Log(C4ENGINECAPTION);
	LogF("Version: %s %s (%s)", C4VERSION, C4_OS, Revision.getData());
	LogF("ExePath: \"%s\"", Config.General.ExePath.getData());
	LogF("SystemDataPath: \"%s\"", Config.General.SystemDataPath);
	LogF("UserDataPath: \"%s\"", Config.General.UserDataPath);

	// Init C4Group
	C4Group_SetProcessCallback(&ProcessCallback);
	C4Group_SetTempPath(Config.General.TempPath.getData());
	C4Group_SetSortList(C4CFN_FLS);

	// Cleanup temp folders left behind
	Config.CleanupTempUpdateFolder();

	// Initialize game data paths
	Reloc.Init();

	// init system group
	if (!Reloc.Open(SystemGroup, C4CFN_System))
	{
		// Error opening system group - no LogFatal, because it needs language table.
		// This will *not* use the FatalErrors stack, but this will cause the game
		// to instantly halt, anyway.
		const char *szMessage = "Error opening system group file (System.ocg)!";
		Log(szMessage);
		// Fatal error, game cannot start - have player notice
		MessageDialog(szMessage);
		return false;
	}
	// Parse command line
	ParseCommandLine(argc, argv);

	// Open additional logs that depend on command line
	OpenExtraLogs();

	// Init external language packs
	Languages.Init();
	// Load language string table
	if (!Languages.LoadLanguage(Config.General.LanguageEx))
		// No language table was loaded - bad luck...
		if (!Languages.HasStringTable())
			Log("WARNING: No language string table loaded!");

#if defined(WIN32) && defined(WITH_AUTOMATIC_UPDATE)
	// Windows: handle incoming updates directly, even before starting up the gui
	//          because updates will be applied in the console anyway.
	if (Application.IncomingUpdate)
		if (C4UpdateDlg::ApplyUpdate(Application.IncomingUpdate.getData(), false, NULL))
			return true;
#endif

	// Fixup resolution
	if (!Config.Graphics.Windowed)
		ApplyResolutionConstraints();

	// activate
	Active=true;

	// Init carrier window
	if (!isEditor)
	{
		if (!(pWindow = FullScreen.Init(this)))
			{ Clear(); ShowGfxErrorDialog(); return false; }
	}
	else
	{
		if (!(pWindow = Console.Init(this)))
			{ Clear(); return false; }
	}

	// init timers (needs window)
	Add(pGameTimer = new C4ApplicationGameTimer());

	// Initialize OpenGL
	bool success = DDrawInit(this, GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.Monitor);
	if (!success) { LogFatal(LoadResStr("IDS_ERR_DDRAW")); Clear(); ShowGfxErrorDialog(); return false; }

	if (!isEditor)
	{
		if (!SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
			pWindow->SetSize(Config.Graphics.WindowX, Config.Graphics.WindowY);
	}

	// Initialize gamepad
	if (!pGamePadControl && Config.General.GamepadEnabled)
		pGamePadControl = new C4GamePadControl();

	AppState = C4AS_PreInit;

	return true;
}
Ejemplo n.º 18
0
//---------------------------------------------------------------------------
void __fastcall TEditorForm::LoadFromFile(bool PrimaryEncoding)
{
  TStream * Stream = new TFileStream(FFileName, fmOpenRead | fmShareDenyWrite);
  try
  {
    bool CanTrySecondary;
    if (FEncoding == NULL)
    {
      int Encoding;
      if (ContainsPreamble(Stream, TEncoding::UTF8->GetPreamble()))
      {
        Encoding = CP_UTF8;
        CanTrySecondary = false;
      }
      else
      {
        Encoding = WinConfiguration->Editor.Encoding;
        CanTrySecondary = true;
      }

      switch (Encoding)
      {
        case CP_UTF8:
          FEncoding = PrimaryEncoding ? TEncoding::UTF8 : TEncoding::Default;
          break;

        default:
          CanTrySecondary = false;
          FAIL;
          // fallthru

        case CP_ACP:
          FEncoding = PrimaryEncoding ? TEncoding::Default : TEncoding::UTF8;
          break;
      }
    }
    else
    {
      CanTrySecondary = false;
    }

    FEncodingName = GetCodePageName(FEncoding);

    bool EncodingError;
    if (!EditorMemo->LoadFromStream(Stream, FEncoding, EncodingError))
    {
      if (EncodingError)
      {
        UnicodeString Message = FMTLOAD(EDITOR_ENCODING_ERROR, (FFileName, FEncodingName));

        if (CanTrySecondary)
        {
          TEncoding * EncodingBackup = FEncoding;
          UnicodeString EncodingNameBackup = FEncodingName;

          try
          {
            FEncoding = NULL;
            LoadFromFile(false);
            TEditorConfiguration EditorConfiguration = WinConfiguration->Editor;
            if (EditorConfiguration.WarnOnEncodingFallback)
            {
              // by now the FEncodingName is the secondary encoding
              Message = Message + L" " + FMTLOAD(EDITOR_ENCODING_REVERTED, (FEncodingName));
              TMessageParams Params(mpNeverAskAgainCheck);
              unsigned int Answer =
                MessageDialog(MainInstructions(Message), qtInformation, qaOK, HELP_NONE, &Params);
              if (Answer == qaNeverAskAgain)
              {
                EditorConfiguration.WarnOnEncodingFallback = false;
                WinConfiguration->Editor = EditorConfiguration;
              }
            }
          }
          catch(...)
          {
            // restored values are never used anyway, as this can get here only
            // when opening editor and this is fatal error preventing the editor from opening
            FEncoding = EncodingBackup;
            FEncodingName = EncodingNameBackup;
            throw Exception(Message);
          }
        }
        else
        {
          throw Exception(Message);
        }
      }
      else
      {
        throw Exception(MainInstructions(FMTLOAD(EDITOR_LOAD_ERROR, (FFileName))));
      }
    }
  }
  __finally
  {
    delete Stream;
  }

  SendMessage(EditorMemo->Handle, EM_EXLIMITTEXT, 0, 0x7FFFFFF0);
}
Ejemplo n.º 19
0
  /// Called from Message() for MSG_DESCRIPTION_COMMAND.
  void OnDescriptionCommand(BaseObject* op, DescriptionCommand* cmdData)
  {
    BaseDocument* doc = op->GetDocument();
    const AutoUndo au(doc);
    const LONG id = cmdData->id[0].id;

    switch (id)
    {
      case NRCONTAINER_PACKUP:
        ToggleProtect(op);
        break;
      case NRCONTAINER_ICON_LOAD:
      {
        if (m_protected) break;

        // Ask the user for an image-file.
        Filename flname;
        flname.SetDirectory(GeGetC4DPath(C4D_PATH_DESKTOP));
        Bool ok = flname.FileSelect(FILESELECTTYPE_IMAGES, FILESELECT_LOAD,
            GeLoadString(IDS_SELECTICON));

        if (ok)
        {
          // Ensure the destination bitmap is allocated.
          if (!m_customIcon)
            m_customIcon = BaseBitmap::Alloc();
          else
            m_customIcon->FlushAll();

          // If it is still null here, allocation failed.
          if (!m_customIcon)
            MessageDialog(GeLoadString(IDS_INFO_OUTOFMEMORY));
          else
          {
            IMAGERESULT res = m_customIcon->Init(flname);
            if (res != IMAGERESULT_OK)
            {
              MessageDialog(IDS_INFO_INVALIDIMAGE);
              BaseBitmap::Free(m_customIcon);
            }
            else
            {
              // Scale the bitmap down to 64x64 pixels.
              BaseBitmap* dest = BaseBitmap::Alloc();
              const LONG size = CONTAINEROBJECT_ICONSIZE;
              dest->Init(size, size);
              m_customIcon->ScaleIt(dest, 256, true, true);
              BaseBitmap::Free(m_customIcon);
              m_customIcon = dest;
            }
          }
        }
        break;
      }
      case NRCONTAINER_ICON_CLEAR:
      {
        if (m_protected) break;
        if (m_customIcon)
        {
          // TODO: We possibly require a flag for removing the icon
          // on the next MSG_GETCUSTOMICON message, because Cinema
          // still references this bitmap.
          BaseBitmap::Free(m_customIcon);
        }
        break;
      }
    }
  }
Ejemplo n.º 20
0
//---------------------------------------------------------------------------
void __fastcall TFileSystemInfoDialog::CertificateViewButtonClick(
  TObject * /*Sender*/)
{
  MessageDialog(FSessionInfo.Certificate, qtInformation, qaOK);
}
Ejemplo n.º 21
0
//---------------------------------------------------------------------------
void __fastcall TEditorForm::Find()
{
  int NewPos;
  int Replacements = 0;

  do
  {
    assert(FLastFindDialog);

    TSearchTypes SearchTypes;

    // length condition is there to improve performance when large
    // block is selected in editor
    if (FLastFindDialog == FReplaceDialog &&
        (FReplaceDialog->Options.Contains(frReplace) ||
         FReplaceDialog->Options.Contains(frReplaceAll)) &&
        FReplaceDialog->FindText.Length() == EditorMemo->SelLength &&
        AnsiSameText(FReplaceDialog->FindText, EditorMemo->SelText))
    {
      EditorMemo->SelText = FReplaceDialog->ReplaceText;
      Replacements++;
    }

    TEditorConfiguration EditorConfiguration = WinConfiguration->Editor;
    EditorConfiguration.FindText = FLastFindDialog->FindText;
    EditorConfiguration.ReplaceText = FReplaceDialog->ReplaceText;
    EditorConfiguration.FindMatchCase = FLastFindDialog->Options.Contains(frMatchCase);
    EditorConfiguration.FindWholeWord = FLastFindDialog->Options.Contains(frWholeWord);
    EditorConfiguration.FindDown = FLastFindDialog->Options.Contains(frDown);
    WinConfiguration->Editor = EditorConfiguration;

    if (EditorConfiguration.FindMatchCase)
    {
      SearchTypes << stMatchCase;
    }
    if (EditorConfiguration.FindWholeWord)
    {
      SearchTypes << stWholeWord;
    }

    NewPos = EditorMemo->FindText(EditorConfiguration.FindText,
      EditorMemo->SelLength ? EditorMemo->SelStart+1 : EditorMemo->SelStart,
      EditorMemo->Text.Length(), SearchTypes, EditorConfiguration.FindDown);

    if (NewPos >= 0)
    {
      EditorMemo->SelStart = NewPos;
      EditorMemo->SelLength = EditorConfiguration.FindText.Length();
    }

    if (FLastFindDialog->Handle)
    {
      PositionFindDialog(true);
    }

    if (NewPos < 0)
    {
      if ((Replacements == 0) || FReplaceDialog->Options.Contains(frReplaceAll))
      {
        // now Screen->ActiveForm can be NULL when other form was meanwhile
        // activated and then focus was returned back to "find" dialog
        // (non VCL form)
        if (Screen->ActiveForm != this)
        {
          SetFocus();
          FLastFindDialog->Execute();
        }

        if (Replacements == 0)
        {
          UnicodeString Message = MainInstructions(FMTLOAD(EDITOR_FIND_END, (EditorConfiguration.FindText)));
          MessageDialog(Message, qtInformation, qaOK, HELP_NONE);
        }
        else if (FReplaceDialog->Options.Contains(frReplaceAll))
        {
          UnicodeString Message = MainInstructions(FMTLOAD(EDITOR_REPLACE_END, (Replacements)));
          MessageDialog(Message, qtInformation, qaOK, HELP_NONE);
        }
      }
    }
  }
  while (NewPos >= 0 && FLastFindDialog == FReplaceDialog &&
         FReplaceDialog->Options.Contains(frReplaceAll));
}