Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Error: RichEdit line insertation error (https://www.clubdelphi.com/foros/showthread.php?t=12461)

DarkByte 16-07-2004 15:18:48

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.

DarkByte 16-07-2004 15:21:50

Añado que cuando estoy en modo "Frase a Frase", es decir, escribiendo arriba la original y debajo la encriptada, me lanza:

Cita:

Error al escribir la línea encriptada
Por lo que supongo que el error estará en
Código Delphi [-]
      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));
         //------------AQUI SALTA EL MENSAJE------------
        except ShowMessage ('Error al escribir la linea encriptada'); end;
      end;

DarkByte 16-07-2004 15:22:27

Otra cosita ahora que caigo... mmEncriptado también es un RichEdit

DarkByte 19-07-2004 12:28:09

:s Como veo que la respuesta se demora mucho para lo normal en clubdelphi, ruego que me avisen si me he equivocado o faltado a la Guía de Estilo en la pregunta y también añadir que uso Delphi 7 Enterprise bajo WinXp en un AMD Anthlon con 1Gb de memoria ram, pantalla TFT de no me acuerdo cuantas pulgadas, 6 puertos USB, altavoces con Dolby Sorrund 3.1 (Agiler), webcam Dexxa, Grabadora de cd's Lg (52x24x52x), lector de DVD Lg también....

Me parece que ya he dado suficiente información :p :p :p


La franja horaria es GMT +2. Ahora son las 05:20:36.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi