Jeg vil tru det er nemmest at lave din egen replave dialog og så bare bruge: SynEdit.lines.text := StringReplace(SynEdit.lines.text, 'text2replace', 'texten som det skal erstates med',[rfReplaceAll]);
Replace dilogen kan være svært at få til at virke dkn
begin FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top); FindDialog1.Execute; end;
procedure TForm1.FindDialog1Find(Sender: TObject); var FoundAt: LongInt; StartPos, ToEnd: Integer; begin with RichEdit1 do begin { begin the search after the current selection if there is one } { otherwise, begin at the start of the text } if SelLength <> 0 then
StartPos := SelStart + SelLength else
StartPos := 0;
{ ToEnd is the length from StartPos to the end of the text in the rich edit control }
ToEnd := Length(Text) - StartPos;
FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, [stMatchCase]); if FoundAt <> -1 then begin SetFocus; SelStart := FoundAt; SelLength := Length(FindDialog1.FindText); end; end; end;
if newpos <> -1 then begin RichEdit1.SelStart := newpos; RichEdit1.SelLength := Length(cd.FindText); end else begin MessageDlg('Færdig',mtInformation,[mbOK],0); RichEdit1.SelStart := 0; end;
end;
procedure TForm1.ReplaceDialog1Replace(Sender: TObject); begin if RichEdit1.SelLength = 0 then FindDialog1Find(Sender) else begin RichEdit1.SelText := ReplaceDialog1.ReplaceText; FindDialog1Find(Sender); end;
if frReplaceAll in ReplaceDialog1.Options then while (RichEdit1.SelLength <> 0) do ReplaceDialog1Replace(Sender); end;
procedure TForm1.FormCreate(Sender: TObject); begin RichEdit1.SelStart := 0; end;
nå men...stoney får 30 points (for at løse ½ af spm...)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.