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

 
 
Herramientas Buscar en Tema Desplegado
  #7  
Antiguo 29-07-2007
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Poder: 22
cHackAll Va por buen camino
Código Delphi [-]
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure ButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
  Button1,Button2: TButton;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
    Button1:= TButton.Create(Self);
    Button1.Parent := Self;
    Button1.Caption := 'Botón 1';
    Button1.Left:= 20;
    Button1.Top:= 10;
    Button1.OnClick := ButtonClick;
 
    Button2:= TButton.Create(Self);
    Button2.Parent := Self;
    Button2.Caption := 'Botón 2';
    Button2.Left:= 100;
    Button2.Top:= 10;
    Button2.OnClick := ButtonClick;
end;
 
procedure TForm1.ButtonClick(Sender: TObject);
begin
 ShowMessage('Presionaste el ' + (Sender as TButton).Caption + '!');
end;
 
end.

Y me parece que al no interesar más datos de los botones se podría hacer algo como ésto:

Código Delphi [-]
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure ButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
 with TButton.Create(Self) do
  begin
   Parent := Self;
   Caption := 'Botón 1';
   Left:= 20;
   Top:= 10;
   OnClick := ButtonClick;
  end;
 with TButton.Create(Self) do
  begin
   Parent := Self;
   Caption := 'Botón 2';
   Left:= 100;
   Top:= 10;
   OnClick := ButtonClick;
  end;
end;
 
procedure TForm1.ButtonClick(Sender: TObject);
begin
 ShowMessage('Presionaste el ' + (Sender as TButton).Caption + '!');
end;
 
end.

PD: Claro que hay N formas de obtener lo que quieres.
Responder Con Cita
 


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


La franja horaria es GMT +2. Ahora son las 01:02:59.


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