Ver Mensaje Individual
  #2  
Antiguo 27-12-2005
Avatar de Ohcan
[Ohcan] Ohcan is offline
Miembro Premium
 
Registrado: ago 2004
Ubicación: Madrid (España)
Posts: 119
Reputación: 20
Ohcan Va por buen camino
Y si esto va a ser para todos los TMemo....
Código Delphi [-]
unit Unit1;

interface

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

type

  TMemo = class(StdCtrls.TMemo)

  private
    FMaxLines:Integer;
    FOnKeyUp: TKeyEvent;
    procedure WMKeyUp(var Message: TWMKeyUp); message WM_KEYUP;
    procedure SetMaxLines(Value:Integer);
  protected
    property OnKeyUp: TKeyEvent read FOnKeyUp write FOnKeyUp;
  public
    property MaxLines:Integer read FMaxLines Write SetMaxLines default 0;
  end;

  TForm1 = class(TForm)
    ElMemo: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TMemo }

procedure TMemo.SetMaxLines(Value: Integer);
begin
  if Value<>FMaxLines then
    if Value<0 then
      raise Exception.Create('A MaxLines no se le pueden asignar valores menores de cero(0).')
    else
      FMaxLines := Value;
end;

procedure TMemo.WMKeyUp(var Message: TWMKeyUp);
begin
  if FMaxLines<>0 then
    while Lines.Count > FMaxLines do
      Lines.Delete(Lines.Count-1);
end;

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  ElMemo.MaxLines := 3;
end;

end.
Crea una palicación desde cero... pon un memo en el formulario (llámalo ElMemo) y sustituye el código de la Unit1 por el que está aquí arriba.
__________________
La violencia es el último recurso del incompetente. (Salvor Hardin)
Responder Con Cita