Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  4 454

•  TDictionary Custom Sort  6 490

•  Fast Watermark Sources  6 283

•  3D Designer  9 229

•  Sik Screen Capture  6 618

•  Patch Maker  6 997

•  Айболит (remote control)  7 004

•  ListBox Drag & Drop  5 871

•  Доска для игры Реверси  97 080

•  Графические эффекты  7 201

•  Рисование по маске  6 503

•  Перетаскивание изображений  5 369

•  Canvas Drawing  5 743

•  Рисование Луны  5 455

•  Поворот изображения  4 983

•  Рисование стержней  3 536

•  Paint on Shape  2 805

•  Генератор кроссвордов  3 675

•  Головоломка Paletto  2 959

•  Теорема Монжа об окружностях  3 763

•  Пазл Numbrix  2 482

•  Заборы и коммивояжеры  3 166

•  Игра HIP  2 134

•  Игра Go (Го)  2 068

•  Симулятор лифта  2 440

•  Программа укладки плитки  2 114

•  Генератор лабиринта  2 585

•  Проверка числового ввода  2 264

•  HEX View  2 593

•  Физический маятник  2 202

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Поиск в TMemo с использованием TFindDialog



Оформил: DeeCo

  private
     { Private declarations }
     FSelPos: integer;
   public
     { Public declarations }
   end;

 var
   Form1 : TForm1;

 implementation

 {$R *.dfm}

 procedure TForm1.FindDialog1Find(Sender : TObject);
 var
   S : string;
   startpos : integer;
 begin
   with TFindDialog(Sender) do
   begin
     {If the stored position is 0 this cannot be a find next. }
     if FSelPos = 0 then
       Options := Options - [frFindNext];

      { Figure out where to start the search and get the corresponding 
       text from the memo. }
     if frfindNext in Options then
     begin
       { This is a find next, start after the end of the last found word. }
       StartPos := FSelPos + Length(Findtext);
       S := Copy(Memo1.Lines.Text, StartPos, MaxInt);
     end
     else
     begin
       { This is a find first, start at the, well, start. }
       S := Memo1.Lines.Text;
       StartPos := 1;
     end;
     { Perform a global case-sensitive search for FindText in S }
     FSelPos := Pos(FindText, S);
     if FSelPos > 0 then
     begin
        { Found something, correct position for the location of the start 
         of search. }
       FSelPos := FSelPos + StartPos - 1;
       Memo1.SelStart := FSelPos - 1;
       Memo1.SelLength := Length(FindText);
       Memo1.SetFocus;
     end
     else
     begin
       { No joy, show a message. }
       if frfindNext in Options then
         S := Concat('There are no further occurences of "', FindText,
           '" in Memo1.')
       else
         S := Concat('Could not find "', FindText, '" in Memo1.');
       MessageDlg(S, mtError, [mbOK], 0);
     end;
   end;
 end;

 // Show the FindDialog 
// Den FindDialog anzeigen 

procedure TForm1.Button1Click(Sender : TObject);
 begin
   FSelPos := 0;
   FindDialog1.Execute;
 end;