OSDN Git Service

個別あぼ〜んに関する不具合の修正
authorh677 <h677>
Fri, 8 Oct 2004 15:12:52 +0000 (15:12 +0000)
committerh677 <h677>
Fri, 8 Oct 2004 15:12:52 +0000 (15:12 +0000)
AbonUnit.pas
Giko.dfm
Giko.pas
IndividualAbon.dfm
IndividualAbon.pas

index f299b1e..aecd96c 100644 (file)
@@ -78,9 +78,13 @@ type
        //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82µ\82å\82è
        procedure IndividualAbon(var ThreadStrings : TStringList; SetResNumFile : String); overload;
        procedure IndividualAbon(var ResString : String; SetResNumFile : String; ResNumber : Integer); overload;
-       procedure AddIndividualAbon( ResNum : Integer ; option : Integer);
-       procedure DeleteIndividualAbon( ResNum : Integer);
-       function GetAbonResCount() : Integer;
+       procedure AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
+       procedure DeleteIndividualAbon( ResNum : Integer); overload;
+       procedure DeleteIndividualAbon( ResNum : Integer; SetResNumFile : String); overload;
+
+       function GetAbonResCount() : Integer; overload;
+       function GetAbonResCount(SetResNumFile : String) : Integer; overload;
+
        function GetAbonResString(Num : Integer) : String;
        function CheckIndividualAbonList(ResNum : Integer) : Boolean;
 
@@ -739,35 +743,41 @@ begin
     Result := true;
 end;
 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\83t\83@\83C\83\8b\82É\92Ç\89Á
-procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer);
+procedure TAbon.AddIndividualAbon( ResNum : Integer ; option : Integer; SetResNumFile : String);
 var
        IndividualFile : TStringList;
-    linebuf : String;
-    i : Integer;
+       i, j : Integer;
 begin
-    IndividualFile := TStringList.Create;
-       if FAbonRes[0].Res <> 0 then begin
-        for i := 0 to High(FAbonRes) do begin
-            if FAbonRes[i].Res <> ResNum then begin
-                       linebuf := IntToStr(FAbonRes[i].Res) + '-' + IntToStr(FabonRes[i].option);
-               IndividualFile.Append(linebuf);
-            end;
-        end;
-    end;
-    linebuf := IntToStr(ResNum) + '-' + IntToStr(option);
-    IndividualFile.Append(linebuf);
-    try
-       IndividualFile.SaveToFile(FIndividualFileName);
-    finally
-        IndividualFile.Free;
-    end;
+       IndividualFile := TStringList.Create;
+       try
+               if FileExists(SetResNumFile) then begin
+                       IndividualFile.LoadFromFile(SetResNumFile);
+                       i := -1;
+                       for j := 0 to IndividualFile.Count -1 do begin
+                               if AnsiPos(IntToStr(ResNum) + '-', IndividualFile[j]) = 1 then begin
+                                       i := j;
+                                       break;
+                               end;
+                       end;
+                       if i = -1 then
+                               IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option))
+                       else
+                               IndividualFile[j] := IntToStr(ResNum) + '-' + IntToStr(option);
+
+               end else begin
+                       IndividualFile.Add(IntToStr(ResNum) + '-' + IntToStr(option));
+               end;
+               IndividualFile.SaveToFile(SetResNumFile);
+       finally
+               IndividualFile.Free;
+       end;
 end;
 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\83t\83@\83C\83\8b\82©\82ç\8dí\8f\9c
 procedure TAbon.DeleteIndividualAbon( ResNum : Integer);
 var
        IndividualFile : TStringList;
-    linebuf : String;
-    i : Integer;
+       linebuf : String;
+       i : Integer;
 begin
     IndividualFile := TStringList.Create;
        if FAbonRes[0].Res <> 0 then begin
@@ -779,51 +789,90 @@ begin
         end;
     end;
        if IndividualFile.Count <> 0 then begin
-       try
-               IndividualFile.SaveToFile(FIndividualFileName);
-       finally
-               IndividualFile.Free;
-       end;
-    end else begin
-       if FileExists(FIndividualFileName) = true then begin
-               DeleteFile(FIndividualFileName);
-        end;
-    end;
+               try
+                       IndividualFile.SaveToFile(FIndividualFileName);
+               finally
+                       IndividualFile.Free;
+               end;
+       end else begin
+               if FileExists(FIndividualFileName) = true then begin
+                       DeleteFile(FIndividualFileName);
+               end;
+       end;
 end;
 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82Ì\83\8a\83X\83g\82Ì\8cÂ\90\94\82ð\95Ô\82·
 function TAbon.GetAbonResCount() : Integer;
 var
        i : Integer;
 begin
-    if FAbonRes[0].Res = 0 then begin
-       Result := 0
-    end else begin
+       if FAbonRes[0].Res = 0 then begin
+               Result := 0
+       end else begin
                i := High(FAbonRes);
-        Result := i+1;
-    end;
+               Result := i+1;
+       end;
 end;
 //\8cÂ\95Ê\82 \82Ú\81`\82ñ\82Ì\83\8a\83X\83g\82Ì\82\8e\8ds\96Ú\82Ì\83\8c\83X\82ð\95\8e\9a\97ñ\82Å\95Ô\82·
 function TAbon.GetAbonResString(Num : Integer) : String;
 begin
        if (Num <= High(FAbonRes)) and (Num >= 0) then begin
-       Result := IntToStr(FAbonRes[Num].Res);
-    end else begin
-       Result := '';
-    end;
+               Result := IntToStr(FAbonRes[Num].Res);
+       end else begin
+               Result := '';
+       end;
+end;
+function TAbon.GetAbonResCount(SetResNumFile : String) : Integer;
+var
+       bufStringList : TStringList;
+begin
+       Result := 0;
+       if FileExists(SetResNumFile) then begin
+               bufStringList := TStringList.Create;
+               try
+                       try
+                               bufStringList.LoadFromFile(SetResNumFile);
+                               Result := bufStringList.Count;
+                       except
+                       end;
+               finally
+                       bufStringList.Free;
+               end;
+       end;
 end;
+procedure TAbon.DeleteIndividualAbon( ResNum : Integer; SetResNumFile : String);
+var
+       i: Integer;
+       bufStringList : TStringList;
+begin
+       if FileExists(SetResNumFile) then begin
+               bufStringList := TStringList.Create;
+               try
+                       try
+                               bufStringList.LoadFromFile(SetResNumFile);
+                               i := bufStringList.IndexOf(IntToStr(ResNum)+'-');
+                               if i > 0 then
+                                       bufStringList.Delete(i);
+                       except
+                       end;
+               finally
+                       bufStringList.Free;
+               end;
+       end;
+end;
+
 //\83|\83b\83v\83A\83b\83v\82Ì\94»\92è\97p
 function TAbon.CheckIndividualAbonList(ResNum : Integer) : Boolean;
 var
        i : Integer;
 begin
        if FAbonRes[0].Res <> 0 then begin
-       for i := 0 to High(FAbonRes) do begin
-               if FAbonRes[i].Res = ResNum then begin
-               Result := true;
-                Exit;
-            end;
-        end;
-    end;
+               for i := 0 to High(FAbonRes) do begin
+                       if FAbonRes[i].Res = ResNum then begin
+                               Result := true;
+                               Exit;
+                       end;
+               end;
+       end;
        Result := false;
 
 end;
@@ -881,5 +930,8 @@ begin
                tmp := tmp + AString;
        Result := tmp;
 end;
+
+
+
 end.
 
index 873ecf7..d1756c2 100644 (file)
--- a/Giko.dfm
+++ b/Giko.dfm
@@ -1,6 +1,6 @@
 object GikoForm: TGikoForm
-  Left = 112
-  Top = 218
+  Left = 290
+  Top = 123
   HorzScrollBar.Visible = False
   VertScrollBar.Visible = False
   AutoScroll = False
index 462147d..bd0276a 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -9315,11 +9315,9 @@ var
        ThreadItem : TThreadItem;
        i: Integer;
 begin
-       GikoSys.FAbon.AddIndividualAbon(KokoPopupMenu.Tag,1);
        ThreadItem := GetActiveContent;
-       for i := BrowserTab.Tabs.Count - 1 downto 0 do
-               TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
-
+       GikoSys.FAbon.AddIndividualAbon(KokoPopupMenu.Tag, 1, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
+       FActiveContent.Repaint := true;
        if ThreadItem <> nil then
                InsertBrowserTab( ThreadItem, True );
 end;
@@ -9329,30 +9327,35 @@ var
        ThreadItem : TThreadItem;
        i: Integer;
 begin
-       GikoSys.FAbon.AddIndividualAbon(KokoPopupMenu.Tag,0);
        ThreadItem := GetActiveContent;
-       for i := BrowserTab.Tabs.Count - 1 downto 0 do
-               TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
+       GikoSys.FAbon.AddIndividualAbon(KokoPopupMenu.Tag, 0, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
+       FActiveContent.Repaint := true;
        if ThreadItem <> nil then
                InsertBrowserTab( ThreadItem, True );
 end;
 //\8cÂ\95Ê\82 \82Ú\81[\82ñ\89ð\8f\9c\81i\81j
 procedure TGikoForm.AntiIndividualAbonClick(Sender: TObject);
 var
+       IndividualForm :TIndividualAbonForm;
        ThreadItem : TThreadItem;
        msg : String;
-       i: Integer;
 begin
-       if GikoSys.FAbon.GetAbonResCount <> 0 then begin
-               GikoSys.FAbon.DeleteIndividualAbon(KokoPopupMenu.Tag);
+       IndividualForm := TIndividualAbonForm.Create(Self);
+       try
                ThreadItem := GetActiveContent;
-               for i := BrowserTab.Tabs.Count - 1 downto 0 do
-                       TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
-               if ThreadItem <> nil then
-                       InsertBrowserTab( ThreadItem, True );
-       end else begin
-               msg := '\82±\82Ì\83X\83\8c\83b\83h\82Å\82Í\8cÂ\95Ê\82 \82Ú\81`\82ñ\82ð\8ds\82Á\82Ä\82Ü\82¹\82ñ';
-               MsgBox(Handle, msg, '\83\81\83b\83Z\81[\83W', MB_OK);
+               if (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
+                       if IndividualForm.SetThreadLogFileName(ThreadItem.GetThreadFileName) then begin
+                               if IndividualForm.DeleteNG(KokoPopupMenu.Tag) then begin
+                                       FActiveContent.Repaint := true;
+                                       InsertBrowserTab( ThreadItem, True );
+                               end;
+                       end else begin
+                               msg := '\82±\82Ì\83X\83\8c\83b\83h\82Å\82Í\8cÂ\95Ê\82 \82Ú\81`\82ñ\82ð\8ds\82Á\82Ä\82Ü\82¹\82ñ';
+                               MsgBox(Handle, msg, '\83\81\83b\83Z\81[\83W', MB_OK);
+                       end;
+               end;
+       finally
+               IndividualForm.Release;
        end;
 end;
 //\8cÂ\95Ê\82 \82Ú\81[\82ñ\89ð\8f\9c
@@ -9360,29 +9363,26 @@ procedure TGikoForm.N42Click(Sender: TObject);
 var
        IndividualForm :TIndividualAbonForm;
        ThreadItem : TThreadItem;
-       i : Integer;
        msg : String;
 begin
        IndividualForm := TIndividualAbonForm.Create(Self);
        try
-               if GikoSys.FAbon.GetAbonResCount <> 0 then begin
-                       for i :=0 to GikoSys.FAbon.GetAbonResCount-1 do begin
-                       IndividualForm.ComboBox1.Items.Add(GikoSys.FAbon.GetAbonResString(i));
-                       end;
-                       if IndividualForm.ShowModal = mrOK then begin
-                               GikoSys.FAbon.DeleteIndividualAbon(IndividualForm.ResNumber);
-               end;
-               for i := BrowserTab.Tabs.Count - 1 downto 0 do
-                       TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
                ThreadItem := GetActiveContent;
-               if ThreadItem <> nil then
-                       InsertBrowserTab( ThreadItem, True );
-               end else begin
-                       msg := '\82±\82Ì\83X\83\8c\83b\83h\82Å\82Í\8cÂ\95Ê\82 \82Ú\81`\82ñ\82ð\8ds\82Á\82Ä\82Ü\82¹\82ñ';
-                       MsgBox(Handle, msg, '\83\81\83b\83Z\81[\83W', MB_OK);
+               if (ThreadItem <> nil) and (ThreadItem.IsLogFile) then begin
+                       if IndividualForm.SetThreadLogFileName(ThreadItem.GetThreadFileName) then begin
+                               if IndividualForm.ShowModal = mrOK then begin
+                                       if IndividualForm.FRepaint then begin
+                                               FActiveContent.Repaint := true;
+                                               InsertBrowserTab( ThreadItem, True );
+                                       end;
+                               end;
+                       end else begin
+                               msg := '\82±\82Ì\83X\83\8c\83b\83h\82Å\82Í\8cÂ\95Ê\82 \82Ú\81`\82ñ\82ð\8ds\82Á\82Ä\82Ü\82¹\82ñ';
+                               MsgBox(Handle, msg, '\83\81\83b\83Z\81[\83W', MB_OK);
+                       end;
                end;
        finally
-               IndividualForm.Free;
+               IndividualForm.Release;
        end;
 end;
 
@@ -11214,8 +11214,9 @@ var
        i: Integer;
 begin
        for i := BROWSER_COUNT - 1 downto 0 do begin
-               SetWindowPos(TWebBrowser(FBrowsers[i]).Handle, HWND_NOTOPMOST, 0, 0, NewWidth, NewHeight, SWP_NOMOVE + SWP_NOZORDER);
+               SetWindowPos(TWebBrowser(FBrowsers[i]).Handle, HWND_NOTOPMOST, 0, 0, NewWidth, NewHeight, SWP_NOACTIVATE + SWP_NOCOPYBITS + SWP_NOREDRAW + SWP_NOMOVE + SWP_NOZORDER);
        end;
+
 end;
 
 procedure TGikoForm.LogFolderOpenActionExecute(Sender: TObject);
index b1bdc28..ff6cc02 100644 (file)
@@ -1,6 +1,6 @@
 object IndividualAbonForm: TIndividualAbonForm
-  Left = 531
-  Top = 420
+  Left = 476
+  Top = 363
   Width = 219
   Height = 123
   Caption = #20491#21029#12354#12412#12540#12435#35299#38500
index d17295a..bda2222 100644 (file)
@@ -14,10 +14,15 @@ type
     BitBtn1: TBitBtn;
     procedure Button1Click(Sender: TObject);
   private
-    { Private \90é\8c¾ }
+       { Private \90é\8c¾ }
+       FThreadLogFileName: String;
+       FNGFileName: String;
   public
-    { Public \90é\8c¾ }
-    ResNumber : Integer;
+       { Public \90é\8c¾ }
+       FRepaint : boolean;
+       ResNumber : Integer;
+       function SetThreadLogFileName(AFileName: String): boolean;
+       function DeleteNG(AResNum: Integer): boolean;
   end;
 
 var
@@ -28,14 +33,107 @@ implementation
 {$R *.dfm}
 
 procedure TIndividualAbonForm.Button1Click(Sender: TObject);
+var
+       NGFile: TStringList;
+       i, j: Integer;
+
+       str: String;
+begin
+       if (FileExists(FNGFileName)) and (ComboBox1.ItemIndex >= 0) then begin
+               NGFile := TStringList.Create;
+               try
+                       try
+                               NGFile.LoadFromFile(FNGFileName);
+                               str := ComboBox1.Items[ComboBox1.ItemIndex] + '-';
+                               i := -1;
+                               for j := 0 to NGFile.Count - 1 do begin
+                                       if AnsiPos(str, NGFile[j]) = 1 then begin
+                                               i := j;
+                                               break;
+                                       end;
+                               end;
+
+                               //i := NGFile.IndexOf(str);
+                               if i >= 0 then begin
+                                       FRepaint := true;
+                                       NGFile.Delete(i);
+                                       if NGFile.Count = 0 then
+                                               DeleteFile(FNGFileName)
+                                       else
+                                               NGFile.SaveToFile(FNGFileName);
+                               end else
+                                       FRepaint := false;
+                       except
+                       end;
+               finally
+                       NGFile.Free;
+               end;
+       end;
+end;
+function TIndividualAbonForm.SetThreadLogFileName(AFileName: String): boolean;
+var
+       NGFile: TStringList;
+       i: Integer;
+       str: String;
+begin
+       FThreadLogFileName := AFileName;
+       FNGFileName := ChangeFileExt(AFileName, '.NG');
+       Result := false;
+       if FileExists(FNGFileName) then begin
+               NGFile := TStringList.Create;
+               try
+                       try
+                               NGFile.LoadFromFile(FNGFileName);
+                               ComboBox1.Items.Clear;
+                               for i := 0 to NGFile.Count - 1do begin
+                                       str := Copy(NGFile.Strings[i], 1, AnsiPos('-', NGFile.Strings[i]) - 1);
+                                       ComboBox1.Items.Add(str);
+                               end;
+                               if NGFile.Count > 0 then
+                                       Result := true;
+                       except
+                               Result := false;
+                       end;
+               finally
+                       NGFile.Free;
+               end;
+       end;
+end;
+function TIndividualAbonForm.DeleteNG(AResNum: Integer): boolean;
+var
+       NGFile: TStringList;
+       i, j: Integer;
+
+       str: String;
 begin
-    if ComboBox1.Text <> '' then begin
-       try
-                       ResNumber := StrToInt(ComboBox1.Items[ComboBox1.ItemIndex]);
-        Except
-            ResNumber := 0;
-        end;
-    end;
+       Result := false;
+       if (FileExists(FNGFileName)) and (AResNum > 0) then begin
+               NGFile := TStringList.Create;
+               try
+                       try
+                               NGFile.LoadFromFile(FNGFileName);
+                               str := IntToStr(AResNum) + '-';
+                i := -1;
+                               for j := 0 to NGFile.Count - 1 do begin
+                                       if AnsiPos(str, NGFile[j]) = 1 then begin
+                                               i := j;
+                                               break;
+                                       end;
+                               end;
+                               if i >= 0 then begin
+                                       Result := true;
+                                       NGFile.Delete(i);
+                                       if NGFile.Count = 0 then
+                                               DeleteFile(FNGFileName)
+                                       else
+                                               NGFile.SaveToFile(FNGFileName);
+                               end;
+                       except
+                       end;
+               finally
+                       NGFile.Free;
+               end;
+       end;
 end;
 
 end.