Ver Mensaje Individual
  #1  
Antiguo 16-07-2004
Avatar de DarkByte
DarkByte DarkByte is offline
Miembro
 
Registrado: sep 2003
Ubicación: Desconocido
Posts: 1.322
Reputación: 22
DarkByte Va por buen camino
Error: RichEdit line insertation error

Saludos.

Estoy intentando hacer un programa que encripte el texto a medida que se escribe y cuando escribo por ejemplo, al principio, un montón de "aches"
Cita:
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hh
Me lanza:
Cita:
Project Project1.exe raised exception class EOutOfResources with message 'RichEdit line insertation error'.
Proccess stopped. Use Step or Run to continue
¿Qué significa?. ¿Que no tengo recursos?.

Dejo aquí la unit
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ExtCtrls, StdCtrls, Menus;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    StatusBar1: TStatusBar;
    Bevel1: TBevel;
    reTexto: TRichEdit;
    Programa1: TMenuItem;
    Vision1: TMenuItem;
    Modofraseafrase1: TMenuItem;
    mmEncriptado: TRichEdit;
    Borrartodo1: TMenuItem;
    Edicin1: TMenuItem;
    Borrartodo2: TMenuItem;
    procedure Modofraseafrase1Click(Sender: TObject);
    procedure Borrartodo2Click(Sender: TObject);
    procedure reTextoChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Clave: Word;
  MFrase: Boolean;

implementation

{$R *.dfm}
const
    {C1 y C2 are used for encryption of Master Password string}
    {C1 y C2 aon usadas para encriptar la cadena de la clave}
         C1 = 25895;
         C2 = 09617;
         C3 = 65127;


      { Standard Decryption algorithm - Copied from Borland}
      function Decrypt(const S: String; Key: Word): String;
      var
        I: byte;
      begin
        SetLength(Result,Length(S));
        for I := 1 to Length(S) do begin
          Result[i] := char(byte(S[i]) xor (Key shr 8));
          Key := (byte(S[i]) + Key) * C1 + C2 + C3;
        end;
      end;

      { Standard Encryption algorithm - Copied from Borland}
      function Encrypt(const S: String; Key: Word): String;
      var
        I: byte;
      begin
        SetLength(Result,Length(S));
        for I := 1 to Length(S) do begin
          Result[i] := char(byte(S[i]) xor (Key shr 8));
          Key := (byte(Result[i]) + Key) * C1 + C2 +C3;
        end;
      end;
procedure TForm1.Modofraseafrase1Click(Sender: TObject);
begin
  If Modofraseafrase1.Checked = True then
    begin
      MFrase := True;
    end
  Else
    begin
      MFrase := False;
    end;
end;

procedure TForm1.Borrartodo2Click(Sender: TObject);
begin
  mmEncriptado.Clear;
  reTexto.Clear;
end;

procedure TForm1.reTextoChange(Sender: TObject);
var
  I:integer;
begin
  Clave :=9681;
  mmEncriptado.Clear;
  If MFrase <> True Then
    begin
     for I:=0 to reTexto.Lines.Count do
      begin
        mmEncriptado.Lines.Add(Encrypt(reTexto.Lines[i],Clave));
      end;
     end
  Else
    begin
     for I:=0 to reTexto.Lines.Count do
       begin
        with mmEncriptado do
        begin
        try SelAttributes.Color := clRed;
          except ShowMessage ('Error al colorear el texto desencriptado'); end;
          try mmEncriptado.Lines.Add(reTexto.Lines[i]);
            except ShowMessage ('Error al escribir la línea desencriptada');end;
        end;
      with mmEncriptado do
        begin
        try SelAttributes.Color := clBlue;
          except ShowMessage ('Error al colorear el texto encriptado'); end;
        try mmEncriptado.Lines.Add(Encrypt(reTexto.Lines[i],9681));
        except ShowMessage ('Error al escribir la linea encriptada'); end;
      end;
      end;
     end
end;

end.
__________________
:)
Responder Con Cita