OSDN Git Service

close #16234,#16235
authorh677 <h677>
Sun, 26 Apr 2009 11:47:41 +0000 (11:47 +0000)
committerh677 <h677>
Sun, 26 Apr 2009 11:47:41 +0000 (11:47 +0000)
人柱版のボタンもdisableにするように修正。
タイムアウト時間は0に設定して、キャンセルボタンを追加。

UpdateCheck.dfm
UpdateCheck.pas

index 2c33b3b..c836b67 100644 (file)
@@ -40,6 +40,35 @@ object UpdateCheckForm: TUpdateCheckForm
       TabOrder = 1
       OnClick = NightBuildCheckButtonClick
     end
+    object CancelBitBtn: TBitBtn
+      Left = 96
+      Top = 8
+      Width = 97
+      Height = 25
+      Cancel = True
+      Caption = #12461#12515#12531#12475#12523
+      Enabled = False
+      TabOrder = 2
+      OnClick = CancelBitBtnClick
+      Glyph.Data = {
+        DE010000424DDE01000000000000760000002800000024000000120000000100
+        0400000000006801000000000000000000001000000000000000000000000000
+        80000080000000808000800000008000800080800000C0C0C000808080000000
+        FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
+        333333333333333333333333000033338833333333333333333F333333333333
+        0000333911833333983333333388F333333F3333000033391118333911833333
+        38F38F333F88F33300003339111183911118333338F338F3F8338F3300003333
+        911118111118333338F3338F833338F3000033333911111111833333338F3338
+        3333F8330000333333911111183333333338F333333F83330000333333311111
+        8333333333338F3333383333000033333339111183333333333338F333833333
+        00003333339111118333333333333833338F3333000033333911181118333333
+        33338333338F333300003333911183911183333333383338F338F33300003333
+        9118333911183333338F33838F338F33000033333913333391113333338FF833
+        38F338F300003333333333333919333333388333338FFF830000333333333333
+        3333333333333333333888330000333333333333333333333333333333333333
+        0000}
+      NumGlyphs = 2
+    end
   end
   object Panel2: TPanel
     Left = 0
index b2b7469..2fb5e86 100644 (file)
@@ -5,7 +5,7 @@ interface
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
-  IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls, ExtCtrls;
+  IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls, ExtCtrls, Buttons;
 
 type
   TUpdateCheckForm = class(TForm)
@@ -16,14 +16,17 @@ type
     IdHTTP: TIdHTTP;
     IdAntiFreeze: TIdAntiFreeze;
     NightBuildCheckButton: TButton;
+    CancelBitBtn: TBitBtn;
     procedure UpdateButtonClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure NightBuildCheckButtonClick(Sender: TObject);
+    procedure CancelBitBtnClick(Sender: TObject);
   private
     { Private \90é\8c¾ }
     FExecPath : string;
     FExecArgs : string;
     FAllowshutdown : Boolean;
+    FCanceled : Boolean;
     function  GetDesktopDir:string;
     function  GetDownloadFilePath(FileName: String): String;
     function  CreateShortCut(FileName, Argment, SavePath :string):boolean;
@@ -92,6 +95,7 @@ begin
     ResultMemo.Lines.Clear;
     Screen.Cursor := crHourGlass;
     UpdateButton.Enabled := False;
+    NightBuildCheckButton.Enabled := False;
 
     try
         ResStream := TMemoryStream.Create;
@@ -102,6 +106,7 @@ begin
 
             IdHTTP.Request.CacheControl := 'no-cache';
             IdHTTP.Request.CustomHeaders.Add('Pragma: no-cache');
+            IdHTTP.ReadTimeout := 0;
             IdHTTP.HandleRedirects := true;
             downResult := TStringList.Create;
             newest     := TStringList.Create;
@@ -110,7 +115,13 @@ begin
             try
                 try
                     ResStream.Clear;
+                    FCanceled := False;
+                    CancelBitBtn.Enabled := True;
                     IdHTTP.Get(CHECK_URL, ResStream);
+                    CancelBitBtn.Enabled := False;
+                    if (FCanceled) then begin
+                        raise Exception.Create('\83_\83E\83\93\83\8d\81[\83h\82ª\83L\83\83\83\93\83Z\83\8b\82³\82ê\82Ü\82µ\82½\81B');
+                    end;
                     value := GikoSys.GzipDecompress(ResStream,
                             IdHTTP.Response.ContentEncoding);
                     downResult.Text := value;
@@ -169,6 +180,7 @@ begin
             ResStream.Free;
         end;
     finally
+        NightBuildCheckButton.Enabled := True;
         UpdateButton.Enabled := True;
         Screen.Cursor := crDefault;
     end;
@@ -184,7 +196,12 @@ begin
     filename := GetDownloadFilePath(Copy(url, LastDelimiter('/', url) + 1,  Length(url)));
     fileStrem := TFileStream.Create(filename, fmCreate);
     try
+        CancelBitBtn.Enabled := True;
         IdHTTP.Get(url, fileStrem);
+        CancelBitBtn.Enabled := False;
+        if (FCanceled) then begin
+            raise Exception.Create('\83_\83E\83\93\83\8d\81[\83h\82ª\83L\83\83\83\93\83Z\83\8b\82³\82ê\82Ü\82µ\82½\81B');
+        end;
         ResultMemo.Lines.Add(
             IdHttp.ResponseText + '(' + IntToStr(IdHttp.ResponseCode) + ')');
         FExecPath := filename;
@@ -268,5 +285,14 @@ begin
     FExecArgs := '';
     FAllowshutdown := False;
 end;
+//! \83L\83\83\83\93\83Z\83\8b\83{\83^\83\93\89\9f\89º
+procedure TUpdateCheckForm.CancelBitBtnClick(Sender: TObject);
+begin
+    CancelBitBtn.Enabled := False;
+    FCanceled := True;
+    if IdHTTP.Connected then begin
+        IdHTTP.Disconnect;
+    end;
+end;
 
 end.