Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-07-2015
viveba viveba is offline
Miembro
 
Registrado: nov 2006
Posts: 24
Poder: 0
viveba Va por buen camino
Crear ActiveX en delphi XE 4

Hola gente.

Estoy tratando de crear un ActiveX desde delphi, a modo de prueba y aprendizaje.

Creo un nuevo componente, un sencillo PanelReloj, el siguiente:

Código Delphi [-]
unit PanelReloj;
 
interface
 
uses
  System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, Vcl.Dialogs, Winapi.Windows;
 
type
  TModoPanel = (Reloj, Texto);
 
  TPanelReloj = class(TPanel)
 
  private
    { Private declarations }
    FModo       : TModoPanel;
    FHoraActual : TTime;
    FTimerAlarma: TTimer;
    FAlarma     : String;
    FOnAlarma   : TNotifyEvent;
 
    procedure ObtenerHora(Sender: TObject);
    procedure ValidarAlarma(Alarma: String);
  protected
    { Protected declarations }
    procedure Paint; override;
  public
    { Public declarations }
    Constructor Create(AOwner: TComponent); override;
    Destructor Destroy; override;
    function CambiarHora(Hora: TTime): Integer;
    function CambiarFecha(Fecha: TDate): Integer;
  published
    { Published declarations }
    property Modo    : TModoPanel   read FModo     Write FModo;
    property Alarma  : String       read FAlarma   write ValidarAlarma;
    Property OnAlarma: TNotifyEvent read FOnAlarma write FOnAlarma;
  end;
 
procedure Register;
 
implementation
 
function TPanelReloj.CambiarFecha(Fecha: TDate): Integer;
var FechaHora: TSYSTEMTIME;
    HAno, HMes, HDia: word;
begin
  try
    DecodeDate(Fecha, HAno, HMes, HDia);
    GetLocalTime(FechaHora);
 
    with FechaHora do
    begin
      wYear  := HAno;
      wMonth := HMes;
      wDay   := HDia
    end;
    SetLocalTime(FechaHora);
 
    Result := 0
  except
    Result := 1
  end
end;
 
function TPanelReloj.CambiarHora(Hora: TTime): Integer;
var FechaHora: TSYSTEMTIME;
    HHor, HMin, HSeg, HMil: word;
begin
  try
    DecodeTime(Hora, HHor, HMin, HSeg, HMil);
    GetLocalTime(FechaHora);
 
    with FechaHora do
    begin
      wHour   := HHor;
      wMinute := HMin;
      wSecond := HSeg
    end;
    SetLocalTime(FechaHora);
 
    Result := 0
  except
    Result := 1
  end
end;
 
Constructor TPanelReloj.Create(AOwner: TComponent);
begin
  Inherited Create(AOwner);
  Height     := 25;
  Width      := 120;
  BevelInner := bvLowered;
  BevelOuter := bvLowered;
  FModo      := Reloj;
  FHoraActual:= Time;
  Refresh;
 
  FTimerAlarma          := TTimer.Create(self);
  FTimerAlarma.Interval := 1000;
  FTimerAlarma.OnTimer  := ObtenerHora;
end;
 
Destructor TPanelReloj.Destroy;
begin
  FTimerAlarma.Free;
  Inherited Destroy
end;
 
procedure TPanelReloj.ObtenerHora(Sender: TObject);
var
  LaHoraActual: string;
 
begin
  FHoraActual := Time;
  LaHoraActual:= TimeToStr(FHoraActual);
  Refresh;
  if Enabled and (Alarma = LaHoraActual) and (Assigned(FOnAlarma)) then
    FOnAlarma(self)
end;
 
procedure TPanelReloj.Paint;
begin
  Inherited Paint;
  if Modo = Reloj then Caption := TimeToStr(FHoraActual)
end;
 
procedure TPanelReloj.ValidarAlarma(Alarma: String);
var
  HoraCorrecta: TTime;
 
begin
  Try
    HoraCorrecta := StrToTime(Alarma);
    FAlarma      := TimeToStr(HoraCorrecta)
  except
    ShowMessage('Hora incorrecta')
  end
end;
 
procedure Register;
begin
  RegisterComponents('Mis tonterias', [TPanelReloj])
end;
 
end.

Y ahora???? cómo lo convierto en un ActiveX???

Desde ya, muchas gracias por vuestras respuestas.
Responder Con Cita
Respuesta



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
crear activeX o dll para usar en otros sistemas roberto_alg Providers 2 03-06-2013 16:20:47
crear controles activex totote OOP 3 01-08-2007 00:09:34
crear un Activex dentro de una BPL injavies Varios 0 03-11-2003 16:42:49
Uso de los Activex en Delphi 7 unicode OOP 0 15-08-2003 02:56:45
Crear Aplicacion como ActiveX Germi Internet 1 12-07-2003 04:17:59


La franja horaria es GMT +2. Ahora son las 06:09:06.


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
Copyright 1996-2007 Club Delphi