Develop and Download Open Source Software

Browse CVS Repository

Diff of /gikonavigoeson/gikonavi/Giko.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.638 by h677, Tue Jun 19 15:43:14 2007 UTC revision 1.639 by h677, Sun Jul 29 03:40:06 2007 UTC
# Line 686  type Line 686  type
686          procedure SameBoardThreadSubItemOnClick(Sender: TObject);          procedure SameBoardThreadSubItemOnClick(Sender: TObject);
687          //! ポップアップブラウザ作成          //! ポップアップブラウザ作成
688          procedure CreateResPopupBrowser;          procedure CreateResPopupBrowser;
689            //! D&Dを受け取る
690            procedure WMDropFiles(var Msg: TWMDropFiles); Message WM_DropFiles;
691            //! ファイルチェック
692            function isValidFile(FileName: String) : boolean;
693          protected          protected
694                  procedure CreateParams(var Params: TCreateParams); override;                  procedure CreateParams(var Params: TCreateParams); override;
695                  procedure WndProc(var Message: TMessage); override;                  procedure WndProc(var Message: TMessage); override;
# Line 1312  begin Line 1316  begin
1316    
1317      //置換設定ファイルの読み込み      //置換設定ファイルの読み込み
1318      ReplaceDM.LoadFromFile(GikoSys.GetReplaceFileName);      ReplaceDM.LoadFromFile(GikoSys.GetReplaceFileName);
1319        // D&Dを受け取る
1320        DragAcceptFiles(Self.Handle, True);
1321  end;  end;
1322    
1323  // CoolBar の設定を変数に保存  // CoolBar の設定を変数に保存
# Line 1467  begin Line 1473  begin
1473                          GikoDM.TabsOpenAction.Execute;                          GikoDM.TabsOpenAction.Execute;
1474              GikoDM.TabsOpenAction.Tag := 0;              GikoDM.TabsOpenAction.Tag := 0;
1475              if (GikoSys.Setting.LastCloseTabURL <> '') then begin              if (GikoSys.Setting.LastCloseTabURL <> '') then begin
1476                    PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( FActiveContent.Browser ), 0 );
1477                    if ( FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
1478                            while (FActiveContent.Browser.ReadyState <> READYSTATE_COMPLETE) and
1479                                    (FActiveContent.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1480                                    Application.ProcessMessages;
1481                        end;
1482                            end;
1483                  item := BBSsFindThreadFromURL( GikoSys.Setting.LastCloseTabURL );                  item := BBSsFindThreadFromURL( GikoSys.Setting.LastCloseTabURL );
1484                  if (item <> nil) and (item.IsLogFile) then begin                  if (item <> nil) and (item.IsLogFile) then begin
1485                      OpenThreadItem(item, item.URL);                      OpenThreadItem(item, item.URL);
# Line 2740  var Line 2753  var
2753  begin  begin
2754          Thread := inThread;          Thread := inThread;
2755          idx := BrowserTab.TabIndex;          idx := BrowserTab.TabIndex;
2756          if (FActiveContent <> nil) and          if  (not FStartUp) and
2757            (FActiveContent <> nil) and
2758                  (FActiveContent.Thread <> Thread.Thread) and                  (FActiveContent.Thread <> Thread.Thread) and
2759                  (FActiveContent.Browser <> nil) and                  (FActiveContent.Browser <> nil) and
2760                  (Assigned(FActiveContent.Browser.Document)) then begin                  (Assigned(FActiveContent.Browser.Document)) then begin
# Line 7582  begin Line 7596  begin
7596          FResPopupBrowser := TResPopupBrowser.Create(BrowserPanel);          FResPopupBrowser := TResPopupBrowser.Create(BrowserPanel);
7597      end;      end;
7598  end;  end;
7599    //! 外からのD&D処理
7600    procedure TGikoForm.WMDropFiles(var Msg: TWMDropFiles);
7601    var
7602        FileName: Array[0..MAX_PATH] of Char;
7603        Cnt, K: Integer;
7604        Board: TBoard;
7605        LogFolder: String;
7606        datList: TStringList;
7607    begin
7608        // 表示しているの板のとき以外は拒否
7609        if GetActiveList is TBoard then begin
7610            Board := TBoard(GetActiveList);
7611            if MsgBox(Handle, Board.Title
7612                + ' 板に入れていいですか?', 'ギコナビ', MB_YESNO or MB_ICONQUESTION) = IDYES       then begin
7613                // 板の時は、ログフォルダにコピーしてはぐれログ対応と同じ処理?
7614                datList := TStringList.Create;
7615                try
7616                    Cnt := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, SizeOf(FileName));
7617                    for K := 0 to Cnt - 1 do begin
7618                        DragQueryFile(Msg.Drop, K, FileName, SizeOf(FileName));
7619                        {FileNameにdropされたファイル名が入っているので、ここで何らかの処理をする。たとえば次の行}
7620                        // ファイルのチェック
7621                        if (isValidFile(FileName)) then begin
7622                            LogFolder := ExtractFilePath(Board.FilePath);
7623                            if (FileExists( LogFolder + ExtractFileName(FileName))) then begin
7624                                GikoUtil.MsgBox(Handle, LogFolder + 'に' + ExtractFileName(FileName) + 'が既に存在します。', 'エラー', MB_ICONSTOP or MB_OK);
7625                            end else begin
7626                                if (not DirectoryExists(LogFolder)) then begin
7627                                    if (not GikoSys.ForceDirectoriesEx(LogFolder) ) then begin
7628                                        GikoUtil.MsgBox(Handle, LogFolder + 'の生成に失敗しました。', 'エラー', MB_ICONSTOP or MB_OK);
7629                                    end;
7630                                end;
7631                                if (not Windows.CopyFile(FileName,  PChar(LogFolder + ExtractFileName(FileName)), true)) then begin
7632                                    GikoUtil.MsgBox(Handle, FileName + 'のコピーに失敗しました。', 'エラー', MB_ICONSTOP or MB_OK);
7633                                end else begin
7634                                    datList.Add(ExtractFileName(FileName));
7635                                end;
7636                            end;
7637                        end;
7638                    end;
7639                    DragFinish(Msg.Drop);
7640                    if (datList.Count > 0) then begin
7641                        GikoSys.AddOutofIndexDat(Board, datList, False);
7642                        ShowMessage(IntToStr(datList.Count) + '個のdatファイルがコピーされました。' );
7643                            if GikoForm.TreeView.Visible then
7644                                    GikoForm.TreeView.Refresh;
7645                                if GikoForm.ListView.Visible then
7646                                    GikoForm.ListView.Refresh;
7647                    end else begin
7648                        ShowMessage('一つもコピーされませんでした。' );
7649                    end;
7650                finally
7651                    datList.Free;
7652                end;
7653    
7654            end;
7655        end else begin
7656            ShowMessage('板を表示してください。');
7657        end;
7658    end;
7659    //! ファイルチェック
7660    function TGikoForm.isValidFile(FileName: String) : boolean;
7661    var
7662        tmp: String;
7663            unixtime: Int64;
7664        dt: TDateTime;
7665    begin
7666        Result := True;
7667        // 存在するか、拡張子dat、ファイル名
7668        if ( not FileExists(FileName) ) then begin
7669            Result := False;
7670            GikoUtil.MsgBox(Handle, FileName + 'は存在しません。', 'エラー', MB_ICONSTOP or MB_OK);
7671        end else if (ExtractFileExt(ExtractFileName(FileName)) <> '.dat' ) then begin
7672            Result := False;
7673            GikoUtil.MsgBox(Handle, ExtractFileName(FileName) + 'の拡張子が".dat"でありません。', 'エラー', MB_ICONSTOP or MB_OK);
7674        end else begin
7675            // ログファイルの拡張子をはずしたものがスレ作成日時
7676            try
7677                dt := GikoSys.GetCreateDateFromName(FileName);
7678                if ((UnixToDateTime(ZERO_DATE) + OffsetFromUTC) = dt) then begin
7679                    Result := False;
7680                    GikoUtil.MsgBox(Handle, ExtractFileName(FileName) + 'のファイル名が不正です。', 'エラー', MB_ICONSTOP or MB_OK);
7681                end;
7682            except
7683                Result := False;
7684                GikoUtil.MsgBox(Handle, ExtractFileName(FileName) + 'のファイル名が不正です。', 'エラー', MB_ICONSTOP or MB_OK);
7685            end;
7686        end;
7687    end;
7688    
7689  initialization  initialization
7690                                  OleInitialize(nil);                                  OleInitialize(nil);

Legend:
Removed from v.1.638  
changed lines
  Added in v.1.639

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26