Crear ActiveX en delphi XE 4
Publicado por Víctor (16 intervenciones) el 06/07/2015 01:47:49
Hola gente.
Estoy tratando de crear un ActiveX desde delphi, a modo de prueba y aprendizaje.
Creo en componente, un sencillo PanelReloj, como el siguiente:
Y ahora???? cómo lo convierto en un ActiveX???
Desde ya, muchas gracias por vuestras respuestas.
Estoy tratando de crear un ActiveX desde delphi, a modo de prueba y aprendizaje.
Creo en componente, un sencillo PanelReloj, como el siguiente:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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.
Valora esta pregunta


0