Buenas tardes
tengo una aplicación que queda activa en el administrador de tareas y no cierra después de darle el "close", por favor si alguien me puede ayudar le agradezco mucho por su colaboración y tiempo ya que lo que había en los foros no me sirvió ninguno, o mas bien no supe interpretarlo para saber que hacer muchas gracias de nuevo.
este es mi código para el form principal.
Código Delphi
[-]
unit pantalla;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, JvExControls, JvgDigits, StdCtrls, CPort, JvComponentBase, JvTFManager, JvTFAlarm;
type
TForm1 = class(TForm)
ComPort1: TComPort;
procedure FormCreate(Sender: TObject);
procedure ComPort1RxChar(Sender: TObject; Count: Integer);
procedure validar();
private
public
StartX, StartY, StartW, StartH,s1,h1: Integer;
flat : Boolean;
end;
var
Form1: TForm1;
a,h,m,s,b: Integer;
var dato1,dato3,t,t1: string;
implementation
{$R *.dfm}
uses reloj;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComPort1.ShowSetupDialog;
a:= 0;
b:= 0;
ComPort1.Open;
SwitchDesktop(CreateDesktop('ClubDelphi', nil, nil, 0, MAXIMUM_ALLOWED, nil));
BoundsRect := Rect(0, 0, 0, 0);
end;
procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
begin
ComPort1.ReadStr(dato1, Count);
dato3 := dato3+dato1;
if Length(dato3) = 8 then
validar();
end;
procedure TForm1.validar();
begin
h1:=0;
t:= Copy(dato3,1,1);
if t = 'I' then
begin
t1:= Copy(dato3,3,3);
s1:=StrToInt(t1)+ reloj.mm;
if s1 > 59 then
begin
while s1 > 59 do
begin
s1:= s1-60;
Inc(h1);
end;
end;
SwitchDesktop(OpenDesktop('Default', 0, False, DESKTOP_SWITCHDESKTOP));
with TClock.Create(Self) do
SetWindowPos(Handle, HWND_TOPMOST, 1, 739, 60,
20,
SWP_NOREPOSITION);
end
else
if t= 'C' then
begin
ComPort1.WriteStr('CERRANDO');
SwitchDesktop(OpenDesktop('Default', 0, False, DESKTOP_SWITCHDESKTOP));
ComPort1.Close;
Close;
end;
dato3 := '';
dato1 := '';
end;
end.
y el form2 es el siguiente;
Código Delphi
[-]
unit reloj;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, JvExControls, JvSegmentedLEDDisplay, ExtCtrls, StdCtrls;
type
TClock = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
public
flat: Boolean;
end;
var
Clock: TClock;
ss,mm,hh,t: Integer;
s,m,h: string;
implementation
uses pantalla;
{$R *.dfm}
procedure TClock.FormCreate(Sender: TObject);
begin
flat := False;
ss:= 59;
mm:= Form1.s1;
hh:= Form1.h1+hh;
t:=0;
if mm > 59 then
begin
while mm > 59 do
begin
mm:= mm-60;
Inc(hh);
end;
end;
end;
procedure TClock.Timer1Timer(Sender: TObject);
begin
if mm = 0 then
begin
if hh > 0 then
begin
Dec(hh);
mm:=59;
ss:=60;
end
else
if ss = 0 then
begin
Form1.ComPort1.WriteStr('I1');
SwitchDesktop(CreateDesktop('ClubDelphi', nil, nil, 0, MAXIMUM_ALLOWED, nil));
Clock.Close;
end;
end;
if t=60 then
begin
if mm > 0 then
begin
Dec(mm);
ss:=60;
t:=0;
end;
t:=0;
end;
inc(t);
Dec(ss);
end;
end.
los datos por el puerto los acepta bien pero cuando intento cerrar, queda la aplicación activa en el administrador de tareas no se cierra definitivamente,
de nuevo mucas gracias