
09.04.2010, 16:30
|
Активный
|
|
Регистрация: 15.04.2009
Сообщения: 369
Репутация: 93
|
|
Цитата:
Сообщение от T-dayne
Попробовал запихнуть close в отдельную процедуру и запустить ее из под OnShow , ошибки нет, но программа виснет наглухо в этот момент.
Вопрсо все еще актуален!
|
А что-то вроде этого :
Код:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form9};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm9, Form9);
Application.Run;
end.
=======================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form9.MyShowForm;
end;
end.
=======================
unit Unit2;
interface
uses
IniFiles,
Dialogs,
Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, jpeg;
type
TForm9 = class(TForm)
Panel1: TPanel;
OKBtn: TButton;
CancelBtn: TButton;
Panel2: TPanel;
Label1: TLabel;
gif: TImage;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
FileOnNet, LocalFileName: string;
ini: tinifile;
public
procedure MyShowForm;
function GetInetFile(FileOnNet,LocalFileName : string) : boolean;
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
procedure TForm9.MyShowForm;
begin
gif.Visible:=true;
label1.Visible:=true;
//Height:=80;
memo1.Visible:=false;
button1.Visible:=false;
button2.Visible:=false; //возвращаем исходные данные окна
Show;
Timer1.Enabled:=true;
end;
function TForm9.GetInetFile(FileOnNet,LocalFileName : string) : boolean;
begin
Result:=true;
//...
end;
procedure TForm9.Timer1Timer(Sender: TObject);
Var
fnSize : integer;
begin
Timer1.Enabled:=false;
FileOnNet:='http://127.0.0.1/mysite/finalv.ini';
LocalFileName:='finalv.ini';
label1.Caption:='Подключаемся...';
if GetInetFile(FileOnNet,LocalFileName) then //Если файл скачан успешно
begin
label1.Caption:='Проверка наличия версии...';
ini:=tinifile.Create(extractfiledir(application.ExeName)+'\finalv.ini');
TRY
fnSize:=ini.ReadInteger('main', 'finalv', 1);
FINALLY
ini.Free;
END;
if fnSize>1331033 then //сравниваем версию на сайте и версию программы
begin
gif.Visible:=false; //если есть новая версия активируем текст и кнопки обновления
label1.Visible:=false;
//Height:=134;
memo1.Visible:=true;
button1.Visible:=true;
button2.Visible:=true;
end
else
begin //если при сравнении версии одинаковы то
showmessage('У вас самая последняя версия');
Close;
end;
end
else //если файл скачать не удалось то выводим:
showmessage('Не удалось подключиться к серверу обновления!');
end;
end.
|