OSDN Git Service

タスクトレイへの格納で、レスエディタのタスクバーが消えない不具合の修正
[gikonavigoeson/gikonavi.git] / Editor.pas
index 156916b..0a0c78a 100644 (file)
@@ -118,7 +118,7 @@ type
     LocalEdit: TMemo;
     N6: TMenuItem;
     LocalRuleBrowse: TMenuItem;
-    ToolButton4: TToolButton;
+       ToolButton4: TToolButton;
     ToolButton6: TToolButton;
     SaveNameMailAction: TAction;
     ToolButton7: TToolButton;
@@ -265,6 +265,8 @@ type
                procedure InputAssistMenuClick(Sender: TObject);
                //! TMemo\82Ì\83J\81[\83\\83\8b\88Ê\92u\82É\95\8e\9a\97ñ\91}\93ü
                procedure InsertText(Memo: TMemo; Text: String);
+               //! \91\97\90M\92\86\8e~
+               procedure CancelSend(ABoard: TBoard; ASysMenu: HMENU);
        protected
                procedure CreateParams(var Params: TCreateParams); override;
        public
@@ -305,17 +307,6 @@ const
        RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
        RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
 
-
-    //BBS2CH_NAME:                                      string = '\82Q\82¿\82á\82ñ\82Ë\82é';
-       //BBS2CH_LOG_FOLDER:             string = '2ch';
-       //EXTERNAL_LOG_FOLDER:          string  = 'exboard';
-
-       //FOLDER_INI_FILENAME:   string = 'Folder.ini';
-       //FOLDER_INDEX_FILENAME: string = 'Folder.idx';
-       //SUBJECT_FILENAME:                     string  = 'subject.txt';
-       //PATH_DELIM:                                           string  = '\';
-
-
 type
        TSelection = record
                StartPos, EndPos: Integer;
@@ -681,6 +672,7 @@ end;
 function TEditorForm.Check: Boolean;
 const
        REQUIRED: string = '\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
+       ERROR: string = '\83G\83\89\81[';
 var
        Msg: string;
        rc: Integer;
@@ -697,15 +689,15 @@ begin
                        (Board.LastGetTime = ZERO_DATE)) then begin
                Msg := '\83T\81[\83o\82Ì\8e\9e\8d\8f\82ª\95ª\82©\82ç\82È\82¢\82½\82ß\81A\91\97\90M\8fo\97\88\82Ü\82¹\82ñ'#13#10
                                 + '\83X\83\8c\83b\83h\82ð\8dX\90V\81i\8eæ\93¾\81j\8cã\81A15\95b\91Ò\82Á\82Ä\82©\82ç\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢';
-               MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+               MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
                Result := False;
        end else if BodyEdit.Text = '' then begin
                Msg := '\96{\95¶' + REQUIRED;
-               MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+               MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
                Result := False;
        end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
                Msg := '\83^\83C\83g\83\8b' + REQUIRED;
-               MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
+               MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
                Result := False;
        end else begin
                if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
@@ -816,6 +808,15 @@ begin
        Indy.Request.UserAgent := GikoSys.GetUserAgent;
        Indy.Request.AcceptEncoding := '';
 end;
+//! \91\97\90M\92\86\8e~\82Ì\82½\82ß\82Ì\83\81\83j\83\85\81[\82Ì\8dÄ\90
+procedure TEditorForm.CancelSend(ABoard: TBoard; ASysMenu: HMENU);
+begin
+       ABoard.SPID := '';
+       ABoard.PON := '';
+       FWork := false;
+       EnableMenuItem(ASysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
+       DrawMenuBar(Handle);
+end;
 
 procedure TEditorForm.Send(ACOOKIE: string; SPID: string; PON: string; FirstWriting: Boolean);
 const
@@ -839,7 +840,6 @@ var
        body : TStringList;
        Remote : String;
        ABoard : TBoard;
-       tmpRawheader: string;
     {Protocol,Host, Path, Document, Port, Bookmark : String;}
 begin
        FAbort := False;
@@ -851,7 +851,7 @@ begin
                Board := FThreadItem.ParentBoard;
 
 
-    tmpRawheader := '';
+//    tmpRawheader := '';
        InitIdHTTP(Indy);
        if FThreadItem = nil then begin
                URL := FBoard.GetSendURL;
@@ -909,176 +909,148 @@ begin
                try
                        FDebugStrReceive := '';
                        FDebugStrSend := '';
-                       GetSendData(Source);
-                       IdAntiFreeze.Active := True;
-                       try
-                               Indy.Post(URL, Source, TextStream);
-                       finally
-                               IdAntiFreeze.Active := False;
-                       end;
-                       ResponseText := TextStream.DataString;
 
-                       ResultType := GetResultType(ResponseText);
-
-                       //MsgResult\8f\89\8aú\89»
-                       MsgResult := IDNO;
-                       //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
-                        if GikoSys.Setting.LocalTrapAtt then begin
-                                if LFusianaGet(Namae) then begin
-                                       MsgResult := MsgBox(
-                                                               Handle, MSG_FUSIANA, '\8fî\95ñ',
+                       if (FirstWriting) then begin
+                               //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
+                               if GikoSys.Setting.LocalTrapAtt then begin
+                                       if LFusianaGet(Namae) then begin
+                                               MsgResult := MsgBox( Handle, MSG_FUSIANA, '\8fî\95ñ',
                                                        MB_YESNO or MB_ICONQUESTION);
                                                if MsgResult = IDNO  then begin
-                                                       Board.SPID := '';
-                                                       Board.PON := '';
-                                                       FWork := false;
-                                                       EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
-                                                       DrawMenuBar(Handle);
+                                                       CancelSend( Board, SysMenu );
                                                        Exit;
-                                                                               end;
-                                                               end;
+                                               end;
+                                       end;
                                        if ((Namae = '\8eR\8dè\8fÂ') or (Namae = 'fusianasan')) then begin
-                                               MsgResult := MsgBox(
-                                                               Handle, MSG_FUSIANA, '\8fî\95ñ',
-                                                       MB_YESNO or MB_ICONQUESTION);
+                                               MsgResult := MsgBox(Handle, MSG_FUSIANA, '\8fî\95ñ',
+                                               MB_YESNO or MB_ICONQUESTION);
                                                if MsgResult = IDNO  then begin
-                                                       Board.SPID := '';
-                                                       Board.PON := '';
-                                                       FWork := false;
-                                                       EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
-                                                       DrawMenuBar(Handle);
+                                                       CancelSend( Board, SysMenu );
                                                        Exit;
                                                end;
                                        end;
+                               end;
+
+                               if GikoSys.Setting.RemoteTrapAtt then begin
+                                       if FThreadItem = nil then
+                                               ABoard := FBoard
+                                       else
+                                               ABoard := FThreadItem.ParentBoard;
+
+                                       if ABoard = nil then Exit;
+
+                                       if FileExists(ABoard.GetSETTINGTXTFileName)  then begin
+                                               body := TStringList.Create;
+                                               try
+                                                       body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
+                                                       Remote := GetFusianaName(body, ABoard);
+                                               finally
+                                                       body.Free;
+                                               end;
+                                       end else begin
+                                       //Setting.txt\82ª\82È\82©\82Á\82½\82ç\8eæ\93¾
+                                       //\8eI\82É\95\89\89×\82ª\82©\82©\82è\82»\82¤...
+                                       //if not FileExists(ABoard.GetSETTINGTXTFileName) then begin
+                                               GetSETTINGTXTAction.Execute;
+                                               body := TStringList.Create;
+                                               try
+                                                       if FileExists(ABoard.GetSETTINGTXTFileName) then begin
+                                                               body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
+                                                               Remote := GetFusianaName(body, ABoard);
+                                                       end;
+                                               finally
+                                                       body.Free;
                                                end;
+                                       end;
 
-                                               if GikoSys.Setting.RemoteTrapAtt then begin
-                                                       if FThreadItem = nil then
-                                                               ABoard := FBoard
-                                                       else
-                                                               ABoard := FThreadItem.ParentBoard;
-
-                                                       if ABoard = nil then Exit;
-
-                                                               if FileExists(ABoard.GetSETTINGTXTFileName)  then begin
-                                                                               body := TStringList.Create;
-                                                                               try
-                                                                                               body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
-                                                                                               Remote := GetFusianaName(body, ABoard);
-                                                                               finally
-                                                                                               body.Free;
-                                                                               end;
-                                                               end;
-
-                                                               //Setting.txt\82ª\82È\82©\82Á\82½\82ç\8eæ\93¾
-                                                               //\8eI\82É\95\89\89×\82ª\82©\82©\82è\82»\82¤...
-                                                               if not FileExists(ABoard.GetSETTINGTXTFileName) then begin
-                                                                               //GetSETTINGTXTAction\82ð\8cÄ\82Ñ\8fo\82·\82ÆIndy\82ª\8f\89\8aú\89»\82³\82ê\82é\82Ì\82Å\81A
-                                                                               //\82±\82±\82ÅCookie\82ð\95Û\91\82µ\82È\82­\82Ä\82Í\82¢\82¯\82È\82¢
-                                                                               tmpRawheader := Indy.Response.RawHeaders.Text;
-                                                                               GetSETTINGTXTAction.Execute;
-                                                                               body := TStringList.Create;
-                                                                               try
-                                                                                               if FileExists(ABoard.GetSETTINGTXTFileName) then begin
-                                                                                                               body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
-                                                                                                               Remote := GetFusianaName(body, ABoard);
-                                                                                               end;
-                                                                               finally
-                                                                                               body.Free;
-                                                                               end;
-                                                               end;
-
-                                                               if Remote = 'fusianasan' then begin
+                                       if Remote = 'fusianasan' then begin
                                                MsgResult := MsgBox(
-                                                               Handle, MSG_FUSIANA, '\8fî\95ñ',
+                                                       Handle, MSG_FUSIANA, '\8fî\95ñ',
                                                        MB_YESNO or MB_ICONQUESTION);
                                                if MsgResult = IDNO  then begin
-                                                       Board.SPID := '';
-                                                       Board.PON := '';
-                                                       FWork := false;
-                                                       EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
-                                                       DrawMenuBar(Handle);
+                                                       CancelSend( Board, SysMenu );
                                                        Exit;
                                                end;
-                                                                               end;
-                                                               end;
-
-                                       if ResultType = grtOK then begin
-                                               if (GikoSys.Setting.UseSamba) and  (Timer1.Enabled) then
-                                                       WriteSambaTime(FHost, Now());
-                                                                               State := gdsComplete;
-                                                               end else if ResultType = grtCookie then begin
-                                       //\83\8b\81[\83v\96h\8e~
-                                       if not FirstWriting then
-                                               raise Exception.Create('');
-                                        MsgResult := MsgBox(
-                                                Handle,
-                                                '\81E\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81A\95Û\91\81A\88ø\97p\81A\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
-                                                '\81E\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10#13#10 +
-                                                '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
-                                                '\8fî\95ñ',
-                                                MB_YESNO or MB_ICONQUESTION);
-                                       if MsgResult = IDYES then begin
-                                               if (GikoSys.Setting.RemoteTrapAtt) and (tmpRawheader <> '') then begin
-                                                       GetCookie(tmpRawheader, Board);
-                                                       end else begin
-                                                               GetCookie(Indy.Response.RawHeaders.Text, Board);
-                                               end;
-                                               if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
-                                                       raise Exception.Create('');
-                                               //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
-                                                       Send(Board.Cookie, Board.SPID, Board.PON, False);
-                                               Exit;
-                                       end else begin
-                                               Board.SPID := '';
-                                               Board.PON := '';
-                                               FWork := False;
-                                               EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
-                                               DrawMenuBar(Handle);
-                                               Exit;
-                                       end;
-                               end else if ResultType = grtCheck then begin
-                                       //\83\8b\81[\83v\96h\8e~
-                                       if not FirstWriting then
-                                               raise Exception.Create('');
-
-                                       MsgResult := MsgBox(
-                                               Handle,
-                                               '\8f\91\82«\8d\9e\82Ý\82É\8aÖ\82µ\82Ä\82Í\97l\81X\82È\83\8d\83O\8fî\95ñ\82ª\8bL\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B' + #13#10 +
-                                               '\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10 +
-                                               '\8cö\8f\98\97Ç\91­\82É\94½\82µ\82½\82è\81A\91¼\90l\82É\96À\98f\82ð\82©\82¯\82é\8f\91\82«\8d\9e\82Ý\82Í\8dT\82¦\82Ä\89º\82³\82¢\81B' + #13#10 +
-                                               '\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81E\95Û\91\81E\88ø\97p\81E\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
-                                               #13#10 +
-                                               '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
-                                               '\8am\94F',
-                                               MB_YESNO or MB_ICONQUESTION);
-
-                                       if MsgResult = IDYES then begin
-                                                if (GikoSys.Setting.RemoteTrapAtt) and (tmpRawheader <> '') then begin
-                                                       GetCookie(tmpRawheader, Board);
-                                       end else begin
-                                               GetCookie(Indy.Response.RawHeaders.Text, Board);
-                                        end;
+                                       end;
+                               end;
+                       end;
+
+                       GetSendData(Source);
+                       IdAntiFreeze.Active := True;
+                       try
+                               Indy.Post(URL, Source, TextStream);
+                       finally
+                               IdAntiFreeze.Active := False;
+                       end;
+                       ResponseText := TextStream.DataString;
+
+                       ResultType := GetResultType(ResponseText);
+
 
-                                        if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
-                                                raise Exception.Create('');
-                                               Send(Board.Cookie, Board.SPID, Board.PON, False);
-                                               Exit;
-                                       end else begin
-                                               EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
-                                               DrawMenuBar(Handle);
-                                               Board.SPID := '';
-                                               Board.PON := '';
-                                               FWork := false;
-                                               Exit;
-                                       end;
-                               end else begin
-                                        if (GikoSys.Setting.UseSamba)  and  (Timer1.Enabled) then
-                                               WriteSambaTime(FHost, Now());
-                                        State := gdsError;
-                                        raise Exception.Create('');
-                               end;
+                       if ResultType = grtOK then begin
+                               if (GikoSys.Setting.UseSamba) and  (Timer1.Enabled) then
+                                       WriteSambaTime(FHost, Now());
 
+                               State := gdsComplete;
+                       end else if ResultType = grtCookie then begin
+                               //\83\8b\81[\83v\96h\8e~
+                               if not FirstWriting then
+                                       raise Exception.Create('');
+
+                               MsgResult := MsgBox( Handle,
+                                                               '\81E\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81A\95Û\91\81A\88ø\97p\81A\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
+                                                               '\81E\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10#13#10 +
+                                                               '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
+                                                               '\8fî\95ñ',
+                                                               MB_YESNO or MB_ICONQUESTION);
+
+                               if MsgResult = IDYES then begin
+                                       GetCookie(Indy.Response.RawHeaders.Text, Board);
+
+                                       if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
+                                               raise Exception.Create('');
+
+                                       //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
+                                       Send(Board.Cookie, Board.SPID, Board.PON, False);
+                                       Exit;
+                               end else begin
+                                       CancelSend( Board, SysMenu );
+                                       Exit;
+                               end;
+                       end else if ResultType = grtCheck then begin
+                               //\83\8b\81[\83v\96h\8e~
+                               if not FirstWriting then
+                                       raise Exception.Create('');
+
+                               MsgResult := MsgBox( Handle,
+                                               '\8f\91\82«\8d\9e\82Ý\82É\8aÖ\82µ\82Ä\82Í\97l\81X\82È\83\8d\83O\8fî\95ñ\82ª\8bL\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B' + #13#10 +
+                                               '\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10 +
+                                               '\8cö\8f\98\97Ç\91­\82É\94½\82µ\82½\82è\81A\91¼\90l\82É\96À\98f\82ð\82©\82¯\82é\8f\91\82«\8d\9e\82Ý\82Í\8dT\82¦\82Ä\89º\82³\82¢\81B' + #13#10 +
+                                               '\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81E\95Û\91\81E\88ø\97p\81E\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
+                                               #13#10 +
+                                               '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
+                                               '\8am\94F',
+                                               MB_YESNO or MB_ICONQUESTION);
+
+                               if MsgResult = IDYES then begin
+                                       GetCookie(Indy.Response.RawHeaders.Text, Board);
+
+                                       if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
+                                               raise Exception.Create('');
+
+                                       Send(Board.Cookie, Board.SPID, Board.PON, False);
+                                       Exit;
+                               end else begin
+                                       CancelSend( Board, SysMenu );
+                                       Exit;
+                               end;
+                       end else begin
+                               if (GikoSys.Setting.UseSamba)  and  (Timer1.Enabled) then
+                                       WriteSambaTime(FHost, Now());
+
+                               State := gdsError;
+                               raise Exception.Create('');
+                       end;
                except
                        on E: EIdConnectException do begin
                                State := gdsError;
@@ -1260,6 +1232,8 @@ begin
 end;
 
 procedure TEditorForm.SendActionExecute(Sender: TObject);
+const
+       TITLE_SAMBA : string = 'Samba24\8cx\8d\90';
 var
        Board: TBoard;
        rc: Integer;
@@ -1347,7 +1321,7 @@ begin
                                        rc := GikoUtil.MsgBox(Handle,
                                                                'Samba24\82Ì\8bK\92è\92l\96¢\96\9e\82Ì\95b\90\94\82µ\82©\8co\89ß\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B'#13#10
                                                                + '\91\97\90M\82ð\92\86\8e~\82µ\82Ü\82·\82©\81H' + #13#10
-                                                               + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', 'Samba24\8cx\8d\90',
+                                                               + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', TITLE_SAMBA,
                                                                MB_YESNO or MB_ICONQUESTION);
                                        if rc = IDYES then begin
                                                FWork := false;
@@ -1356,7 +1330,7 @@ begin
                                         if rc = IDNO then begin
                                                 rc2 := GikoUtil.MsgBox(Handle,
                                                                        '\96{\93\96\82É\91\97\90M\82µ\82Ü\82·\82©\81H',
-                                                                       'Sumba24\8cx\8d\90',
+                                                                       TITLE_SAMBA,
                                                                        MB_YESNO or MB_ICONQUESTION);
                                                 if rc2 = IDNO then begin
                                                         FWork := False;