Tag: delphi

  • Delphi 2009

    The compiled exe/dll can’t be executed in Windows 95/98/ME because there is no unicode support.
    The bad news because CodeGear could create the wrappers (from unicode->ansi functions) for this situation. Now they suggest to create these wrappers yourself and update the Windows.pas unit

    Hope they will include the new unit with wrappers in next update for D2009

  • TRichEdit: change the substring but don’t change color/font attributes

    For example, if you have some TRichEdit instance and you want to change some substring there but do not change the formatting (color/font etc) for this text, you may use this code:

    var
      i: Integer;
    begin
      if SameText(strNewValue, strOldValue) then exit;
      repeat
        i := Pos(strOldValue, yourRichEdit.Lines.Text);
        if (i > 0) then
        begin
          yourRichEdit.SelStart := i-1;
          yourRichEdit.SelLength := Length(strOldValue);
          yourRichEdit.SelText := strNewValue;
        end;
      until (i = 0)
    end;

    PS: if use the next code, then formatting will be lost:
    yourRichEdit.Lines.Text := StringReplace(yourRichEdit.Lines.Text, strOldValue, strNewValue, [rfIgnoreCase, rfReplaceAll])