OSDN Git Service

マウスジェスチャーの見直し
[gikonavigoeson/gikonavi.git] / Giko.pas
index f7661ec..165dd09 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -692,17 +692,16 @@ type
         procedure SameBoardThreadSubItemOnClick(Sender: TObject);
         //! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
         procedure CreateResPopupBrowser;
-        //! D&D\82ð\8eó\82¯\8eæ\82é
-        procedure WMDropFiles(var Msg: TWMDropFiles); Message WM_DropFiles;
         //! \83t\83@\83C\83\8b\83`\83F\83b\83N
         function isValidFile(FileName: String) : boolean;
+        //! ListView\82ÌD&D\8eó\82¯\8eæ\82è
+        procedure AcceptDropFiles(var Msg: TMsg);
        protected
                procedure CreateParams(var Params: TCreateParams); override;
                procedure WndProc(var Message: TMessage); override;
                procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;
                procedure WMSettingChange(var Message: TWMWinIniChange); message WM_SETTINGCHANGE;
                procedure WMCopyData(var Message: TWMCopyData); message WM_COPYDATA;
-
        public
                { Public \90é\8c¾ }
                LastRoundTime: TDateTime;
@@ -1053,6 +1052,7 @@ begin
                BrowserTab.Font.Style := [fsBold];
        if GikoSys.Setting.BrowserTabFontItalic then
                BrowserTab.Font.Style := GikoForm.BrowserTab.Font.Style + [fsItalic];
+
        BrowserTab.DoubleBuffered := True;
        FDragWFirst := false;
        SetContent(BrowserNullTab);                                                                                                     //\83u\83\89\83E\83U\82ð\8bó\94\92\95\\8e¦
@@ -1290,22 +1290,14 @@ begin
        dummy1.Caption  := ItemReservPMenu.Caption;
        dummy1.Hint     := ItemReservPMenu.Hint;
 
+    // \83}\83E\83X\83W\83F\83X\83`\83\83\81[
+    MouseGesture := TMouseGesture.Create;
+
 {$IFDEF SPAM_FILTER_ENABLED}
        // \83X\83p\83\80\83t\83B\83\8b\83^\8aw\8fK\97\9a\97ð
        GikoSys.Bayesian.LoadFromFile( GikoSys.Setting.GetSpamFilterFileName );
 {$ENDIF}
 
-       // \83}\83E\83X\83W\83F\83X\83`\83\83\81[
-       MouseGesture := TMouseGesture.Create;
-       GikoSys.Setting.Gestures.LoadGesture(
-               GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
-       MouseGesture.Margin := GikoSys.Setting.Gestures.Margin;
-       MouseGesture.OnGestureStart := OnGestureStart;
-       MouseGesture.OnGestureMove := OnGestureMove;
-       MouseGesture.OnGestureEnd := OnGestureEnd;
-       if GikoSys.Setting.GestureEnabled then
-               MouseGesture.SetHook( Handle );
-
        //2ch\8c¾\8cê\93Ç\82Ý\8fo\82µ
        GikoSys.SetGikoMessage;
 
@@ -1329,7 +1321,7 @@ begin
     ResPopupClearTimer.Interval := GikoSys.Setting.RespopupWait;
 
     // D&D\82ð\8eó\82¯\8eæ\82é
-    DragAcceptFiles(Self.Handle, True);
+    DragAcceptFiles(ListView.Handle, True);
 
     // \8f\89\8aú\89»\82É\8e¸\94s\82µ\82½\83\82\83W\83\85\81[\83\8b\83`\83F\83b\83N
     if (FavoriteDM.AbEnd) then begin
@@ -1538,18 +1530,24 @@ begin
        if (SearchDialog <> nil) then begin
                if (SearchDialog.Visible) then begin
                        SearchDialog.Close;
-                       try
-                               SearchDialog.Release;
-                       except
-                       end;
-                       SearchDialog := nil;
                end;
+        try
+            SearchDialog.Release;
+        except
+        end;
+        SearchDialog := nil;
        end;
 
        //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\95Â\82\82é
     GikoDM.CloseAllEditorAction.Execute;
 
        Application.UnhookMainWindow(Hook);
+    //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8fI\97¹\82Ì\91O\82É\83_\83E\83\93\83\8d\81[\83h\83X\83\8c\83b\83h\82É\90³\8fí\8fI\97¹\82ð\91£\82·
+    try
+        FControlThread.Terminate;
+        FControlThread.WaitFor;
+    except
+    end;
        Application.Terminate;
 end;
 
@@ -1561,10 +1559,14 @@ var
 begin
        // \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\95ú
        try
+        if GikoSys.Setting.GestureEnabled then begin
+               MouseGesture.OnGestureStart := nil;
+                   MouseGesture.OnGestureMove := nil;
+                   MouseGesture.OnGestureEnd := nil;
+        end;
         MouseGesture.Clear;
                MouseGesture.UnHook;
         MouseGesture.Free;
-        MouseGesture := nil;
        except
        end;
        try
@@ -1628,7 +1630,7 @@ begin
                FavoriteDM.Clear;
        except
        end;
-       LockWindowUpdate(Self.Handle);
+       //LockWindowUpdate(Self.Handle);
        try
                //\83^\83u\83N\83\8d\81[\83Y
                tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
@@ -1700,13 +1702,8 @@ begin
         end;
 
        try
-               try
-                       FControlThread.Terminate;
-                       FControlThread.WaitFor;
-               except
-               end;
-       finally
-               FControlThread.Free;
+        FControlThread.Free;
+       except
        end;
     // \83v\83\89\83O\83C\83\93\82É\82æ\82Á\82Ä\92Ç\89Á\82³\82ê\82½\83\81\83j\83\85\81[\82ð\8aJ\95ú\82·\82é
     for i := GikoForm.PlugInMenu.Count - 1 downto 0 do begin
@@ -1751,7 +1748,7 @@ begin
                end;
        except
        end;
-       LockWindowUpdate(0);
+       //LockWindowUpdate(0);
 end;
 
 // \8ae\8f\8a\82É\82 \82é\83L\83\83\83r\83l\83b\83g\81E BBS \83\81\83j\83\85\81[\82ð\83Z\83b\83g\81^\8dX\90V
@@ -2015,7 +2012,7 @@ begin
                PreviewTimer.Interval := GikoSys.Setting.PreviewWait;
                PreviewTimer.Enabled := True;
        end else if (Pos('about:blank', Text2) = 1) or (Pos('http://', Text2) = 1) or (Pos('mailto:', Text2) = 1) then begin
-               if Pos('mailto:', Text2) = 1 then begin
+               if (Pos('mailto:', Text2) = 1) and (GikoSys.Setting.RespopupMailTo) then begin
                        s := StringReplace(Text2, 'mailto:', '', [rfIgnoreCase]);
                        //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g3\82Ì466\8e\81\82É\8a´\8eÓ
                        GetCursorPos(p);
@@ -2446,6 +2443,8 @@ begin
 end;
 procedure TGikoForm.DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
 begin
+    if csDestroying in Self.ComponentState then
+        Exit;
        AddMessageList(Msg, nil, Icon);
 end;
 // *************************************************************************
@@ -2460,6 +2459,8 @@ var
        Res : TResRec;
 begin
        try
+        if csDestroying in Self.ComponentState then
+               Exit;
                if Item.DownType = gdtBoard then
                        ATitle := Item.Board.Title
                else
@@ -2601,6 +2602,9 @@ procedure TGikoForm.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWork
 begin
 //     SetProgressValue(Number, 0, AWorkCountMax);
 //     ProgressBar.Visible := True;
+    if csDestroying in Self.ComponentState then
+        Exit;
+
        ProgressBar.Position := 0;
        ProgressBar.Max := AWorkCountMax;
        FDownloadTitle := AWorkTitle;
@@ -2610,6 +2614,8 @@ end;
 
 procedure TGikoForm.WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
 begin
+    if csDestroying in Self.ComponentState then
+        Exit;
        ProgressBar.Position := 0;
        if FDownloadMax <> 0 then
                StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ª\8a®\97¹\82µ\82Ü\82µ\82½';
@@ -2617,6 +2623,8 @@ end;
 
 procedure TGikoForm.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
 begin
+    if csDestroying in Self.ComponentState then
+        Exit;
        ProgressBar.Position := AWorkCount;
 //     SetProgressValue(Number, AWorkCount);
        StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\92\86 (' + IntToStr(AWorkCount) + '/' + IntToStr(FDownloadMax) + ')';
@@ -4950,7 +4958,7 @@ begin
                s := CustomStringReplace(Range.text, '\81@', ' ');//\91S\8ap\8bó\94\92\82ð\94¼\8ap\8bó\94\92\82É
                s := ZenToHan(Trim(s));
                if GikoSys.IsNumeric(s) then begin
-                       Num := StrToInt64(s);
+                       Num := StrToInt64Def(s, -1);
                        ThreadItem := GetActiveContent(true);
                        if (ThreadItem <> nil) and (Num <= ThreadItem.Count)
                 and (Num > 0)then begin
@@ -6189,13 +6197,16 @@ begin
        if FDragWFirst = true then
                FDragWFirst := false;
 
-    if GikoSys.Setting.ListOrientation = gloHorizontal then begin
-        if GikoSys.Setting.ListWidthState = glsMin then begin
-            GikoDM.BrowserMaxAndFocusAction.Execute;
-        end;
-    end else begin
-        if GikoSys.Setting.ListHeightState = glsMin then begin
-            GikoDM.BrowserMaxAndFocusAction.Execute;
+    // \83}\83E\83X\82Ì\92\86\83{\83^\83\93\82Å\95Â\82\82½\82Æ\82«\82É\8dÅ\91å\89»\82µ\82Ä\82µ\82Ü\82¤\82Ì\82ð\96h\82®\81@
+    if Button <> mbMiddle then begin
+        if GikoSys.Setting.ListOrientation = gloHorizontal then begin
+            if GikoSys.Setting.ListWidthState = glsMin then begin
+                GikoDM.BrowserMaxAndFocusAction.Execute;
+            end;
+        end else begin
+            if GikoSys.Setting.ListHeightState = glsMin then begin
+                GikoDM.BrowserMaxAndFocusAction.Execute;
+            end;
         end;
     end;
 end;
@@ -7402,7 +7413,13 @@ begin
                                end;
                        end;
                end;
-       end;
+       end else begin
+        // Explorer\82ÌD&D\82ð\8eó\82¯\82é\82Æ\82Ì\94ñ\83A\83N\83e\83B\83u
+        if Msg.message = WM_DROPFILES then begin
+            AcceptDropFiles(Msg);
+            Handled := True;
+        end;
+    end;
 end;
 // *************************************************************************
 //! \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\83A\83N\83e\83B\83u\82Å\82È\82­\82È\82Á\82½\82Æ\82«\82Ì\83C\83x\83\93\83g
@@ -7723,14 +7740,15 @@ begin
         FResPopupBrowser := TResPopupBrowser.Create(BrowserPanel);
     end;
 end;
-//! \8aO\82©\82ç\82ÌD&D\8f\88\97\9d
-procedure TGikoForm.WMDropFiles(var Msg: TWMDropFiles);
+//! ListView\82ÌD&D\8eó\82¯\8eæ\82è
+procedure TGikoForm.AcceptDropFiles(var Msg: TMsg);
 var
     FileName: Array[0..MAX_PATH] of Char;
     Cnt, K: Integer;
     Board: TBoard;
     LogFolder: String;
     datList: TStringList;
+    p: TPoint;
 begin
     // \95\\8e¦\82µ\82Ä\82¢\82é\82Ì\94Â\82Ì\82Æ\82«\88È\8aO\82Í\8b\91\94Û
     if GetActiveList is TBoard then begin
@@ -7740,10 +7758,10 @@ begin
             // \94Â\82Ì\8e\9e\82Í\81A\83\8d\83O\83t\83H\83\8b\83_\82É\83R\83s\81[\82µ\82Ä\82Í\82®\82ê\83\8d\83O\91Î\89\9e\82Æ\93¯\82\8f\88\97\9d\81H
             datList := TStringList.Create;
             try
-                Cnt := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, SizeOf(FileName));
+                Cnt := DragQueryFile(Msg.WParam, $FFFFFFFF, FileName, SizeOf(FileName));
                 for K := 0 to Cnt - 1 do begin
-                    DragQueryFile(Msg.Drop, K, FileName, SizeOf(FileName));
-                    {FileName\82Édrop\82³\82ê\82½\83t\83@\83C\83\8b\96¼\82ª\93ü\82Á\82Ä\82¢\82é\82Ì\82Å\81A\82±\82±\82Å\89½\82ç\82©\82Ì\8f\88\97\9d\82ð\82·\82é\81B\82½\82Æ\82¦\82Î\8e\9f\82Ì\8ds}
+                    DragQueryFile(Msg.WParam, K, FileName, SizeOf(FileName));
+                    // FileName\82Édrop\82³\82ê\82½\83t\83@\83C\83\8b\96¼\82ª\93ü\82Á\82Ä\82¢\82é\82Ì\82Å\81A\82±\82±\82Å\89½\82ç\82©\82Ì\8f\88\97\9d\82ð\82·\82é\81B\82½\82Æ\82¦\82Î\8e\9f\82Ì\8ds
                     // \83t\83@\83C\83\8b\82Ì\83`\83F\83b\83N
                     if (isValidFile(FileName)) then begin
                         LogFolder := ExtractFilePath(Board.FilePath);
@@ -7763,7 +7781,7 @@ begin
                         end;
                     end;
                 end;
-                DragFinish(Msg.Drop);
+                DragFinish(Msg.WParam);
                 if (datList.Count > 0) then begin
                     GikoSys.AddOutofIndexDat(Board, datList, False);
                     ShowMessage(IntToStr(datList.Count) + '\8cÂ\82Ìdat\83t\83@\83C\83\8b\82ª\83R\83s\81[\82³\82ê\82Ü\82µ\82½\81B' );
@@ -7783,6 +7801,7 @@ begin
         ShowMessage('\94Â\82ð\95\\8e¦\82µ\82Ä\82­\82¾\82³\82¢\81B');
     end;
 end;
+
 //! \83t\83@\83C\83\8b\83`\83F\83b\83N
 function TGikoForm.isValidFile(FileName: String) : boolean;
 var
@@ -7826,4 +7845,5 @@ initialization
 finalization
                                OleUninitialize;
 
+
 end.