Ver Mensaje Individual
  #2  
Antiguo 15-07-2013
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
RoyTan,

Cita:
Empezado por RoyTan
...es posible limitar el número de caracteres por línea en un Memo...
Revisa este código:
Código Delphi [-]
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure OnKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.OnKeyPress(Sender: TObject; var Key: Char);
var
   Line,Column : Integer;

begin

   With Memo1 do 
   begin
      Line := Perform(EM_LINEFROMCHAR,SelStart, 0);
      Column := SelStart - Perform(EM_LINEINDEX, Line, 0);
      if (Column >= 10) and (Key <> #8) and (Key <> #13) then
         Key := #0;
   end;

end;

end.
El código anterior limita cada línea de un control TMemo a 10 carácteres por medio del evento OnKeyPress y el método Perform.

Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 15-07-2013 a las 21:43:06.
Responder Con Cita