Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 04-09-2008
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Cuando estás creando componentes, no se usan los eventos directamente. Lo que debes hacer es redefinir el método Change:

Código Delphi [-]
type
  TIPEdit = class(TEdit)
    ...
    procedure Change; override;
    ...
  end;

implementation

procedure TIPEdit.Change; 
begin
  inherited;
  
  { aquí tu código }
end;

// Saludos
Responder Con Cita
  #2  
Antiguo 04-09-2008
rauros rauros is offline
Miembro
 
Registrado: feb 2008
Ubicación: Alicante - Sax / Sax - Alicante
Posts: 235
Poder: 19
rauros Va por buen camino
Vale, voy a probar.
Responder Con Cita
  #3  
Antiguo 04-09-2008
rauros rauros is offline
Miembro
 
Registrado: feb 2008
Ubicación: Alicante - Sax / Sax - Alicante
Posts: 235
Poder: 19
rauros Va por buen camino
Tengo esto y me da el siguiente error en la línea de OnKeyPress:

Código Delphi [-]
Procedure TipEdit.ApretarUnBoton(Sender: TObject);
Begin
End;

Constructor TIpEdit.Crear(Padre: TWinControl;
X: Integer; Y: Integer;
TX: Integer; TY: Integer);
Begin
  With TIpEdit.Create(Padre) do Begin
    Self.OnKeyPress:=ApretarUnBoton;
  End;
End;

[Error] EditSoloIp.pas(30): Incompatible types: 'Parameter lists differ'
Responder Con Cita
  #4  
Antiguo 04-09-2008
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Poder: 26
maeyanes Va por buen camino
Hola...

En lugar de usar el evento OnKeyPress, es mejor que redefinas el método KeyPress:

Código Delphi [-]
TIpEdit = class(TEdit)
protected
  procedure KeyPress(var Key: Char); override;
end;

implementation

procedure TIpEdit.KeyPress(var Key: Char);
begin
  // Tu código
  inherited
end;


Saludos...
Responder Con Cita
  #5  
Antiguo 05-09-2008
rauros rauros is offline
Miembro
 
Registrado: feb 2008
Ubicación: Alicante - Sax / Sax - Alicante
Posts: 235
Poder: 19
rauros Va por buen camino
Bua, me he tirado toda la tarde pero mirad lo que he conseguido:

Conjunto de edits especiales para escribir ips:

Código Delphi [-]
unit EditSoloIp;

interface

Uses StdCtrls, Controls, SysUtils, Windows;

Type
  TEditByte=Class(TEdit)
  Public
  SiguienteEdit: HWnd;
  protected
  procedure KeyPress(var Key: Char); override;
End;

Type
  TEditIp=Object
  Edits: Array [1..4] of TEditByte;
  Separadores: Array [1..3] of TLabel;
  Public
  Function GetIp: String;
  Procedure SetIp(Ip: String);
  Procedure Crear(Padre: TWinControl; X: Integer; Y: Integer; Separador: Char);
End;

implementation

Function TEditIp.GetIp: String;
Begin
Result:=Edits[1].Text + '.' + Edits[2].Text + '.' + Edits[3].Text + '.' + Edits[4].Text
End;

Procedure TEditIp.SetIp(Ip: String);
Var
I,b: Integer;
Bytes: Array [1..4] of string;
Begin
IP:=Trim(ip);
I:=0;
If not (Ip[1] in ['0'..'9']) then
Begin
MessageBox(0,'Error, esa ip es incorrecta','Error IpToStr',16);
Exit;
End;
b:=1;
Repeat Inc(I);
If Ip[i] = '.' then
Inc(b)
Else If B > 4 Then Begin
MessageBox(0,'Error, esa ip es incorrecta','Error IpToStr',16);
Exit;
End Else If not (Ip[i] in ['0'..'9']) then
Begin
MessageBox(0,'Error, esa ip es incorrecta','Error IpToStr',16);
Exit;
End
Else
Bytes[b]:=Bytes[b] + Ip[i];
Until I = Length(ip);
For I := 1 to 4 do
If StrToInt(Bytes[i]) > 255 then Bytes[i]:='255';
Edits[1].Text:=bytes[1];
Edits[2].Text:=bytes[2];
Edits[3].Text:=bytes[3];
Edits[4].Text:=bytes[4];
End;

Procedure TEditByte.KeyPress(var key: Char);
Begin
If Key = ' ' then Begin
Windows.SetFocus(SiguienteEdit);
Key:=#0;
End;
If not (key in ['0'..'9',' ',Char(8),Char(46)]) then Key:=#0;
Inherited;
If Text = '' then exit;
If StrToInt(Text) > 255 Then Begin Text:='255';
Key:=#0;
End;
End;

Procedure TEditIP.Crear(Padre: TWinControl;
X: Integer; Y: Integer; Separador: Char);
Var
I: Byte;
Begin
  For I:=1 to 4 Do
  Begin
    Edits[i]:=TEditByte.Create(Padre);
    Edits[i].Parent:=Padre;
    Edits[i].Text:='255';
    Edits[i].Top:=x;
    Edits[i].Left:=y;
    Edits[i].Height:=17;
    Edits[i].Width:=25;
    Edits[i].Visible:=True;
    Y:=Y + 32;
  End;
  Y:=y - 126 + 24;
    For I:=1 to 3 Do
  Begin
    Separadores[i]:=TLabel.Create(Padre);
    Separadores[i].Parent:=Padre;
    Separadores[i].Caption:=Separador;
    Separadores[i].Top:=x;
    Separadores[i].Left:=y;
    Separadores[i].Height:=20;
    Separadores[i].Width:=4;
    Separadores[i].Font.Size:=12;
    Separadores[i].Visible:=True;
    Y:=Y + 32;
  End;
Edits[1].SiguienteEdit:=Edits[2].Handle;
Edits[2].SiguienteEdit:=Edits[3].Handle;
Edits[3].SiguienteEdit:=Edits[4].Handle;
Edits[4].SiguienteEdit:=Edits[1].Handle;
End;

End.

Un ejemplo para crearlo:

var
EditIp: TEditIp;

procedure TForm1.FormCreate(Sender: TObject);
begin
EditIp.Crear(Form1,96,296,'.');
end;
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Heredar un frame. adebonis OOP 4 21-05-2008 20:10:57
Heredar Objetos ADO mcarazas Varios 3 19-10-2006 10:07:20
Problema al heredar frames choty Varios 5 21-06-2006 17:03:47
Heredar objeto carlomagno OOP 5 19-06-2006 01:00:05
Heredar del DBNavigator Carlosj OOP 0 11-01-2005 09:29:43


La franja horaria es GMT +2. Ahora son las 17:51:32.


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