OSDN Git Service

スレ一覧の絞込みでCTRL+DELで個別に削除できるように修正
[gikonavigoeson/gikonavi.git] / Giko.pas
index 0cdfa8a..dcb1a01 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -16,16 +16,18 @@ uses
        ToolWin, Buttons, IdComponent, UrlMon, Tabs, IdGlobal, StrUtils,
        CommCtrl, Dialogs, GikoSystem, Setting, BoardGroup, ThreadControl, ItemDownload,
        Editor, RoundData, GikoPanel, Favorite, HTMLDocumentEvent,
-       HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager,
+       {HintWindow,} GikoCoolBar, GikoListView, Search, ExternalBoardManager,
        ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,
-       IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord;
+       IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem,
+    ShellAPI,Preview, HistoryList, ResPopupBrowser, ExtPreviewDatamodule;
 
 const
        NGWORDNAME_PANEL = 3;
        THREADSIZE_PANEL = 2;
-       
+    USER_RESPOPUPCLEAR         = WM_USER + 2005;       ///< wParam : TWebBrowser
+       
 type
-       TGikoTreeType = (gttNone, gtt2ch, gttHistory, gttFavorite);
+
        TToolBarSettingSenderType = (tssNone, tssMain, tssList, tssBrowser);
        TMinimizeType = (mtNone, mtMinimizing, mtMinimized);
        TResizeType = (rtNone, rtResizing);
@@ -191,10 +193,6 @@ type
                ListToolBar: TToolBar;
                BrowserCoolBar: TGikoCoolBar;
                BrowserToolBar: TToolBar;
-               ToolButton3: TToolButton;
-               ToolButton9: TToolButton;
-               ToolButton11: TToolButton;
-               ToolButton5: TToolButton;
                ListNameToolBar: TToolBar;
                ListNameLabel: TLabel;
                FolderImage: TImage;
@@ -283,7 +281,7 @@ type
                SelectItemNameCopyAction1: TMenuItem;
                B6: TMenuItem;
                T9: TMenuItem;
-               C2: TMenuItem;
+    NameCopyPMenu: TMenuItem;
                SelectComboBox: TComboBox;
                MainCoolBarPopupMenu: TPopupMenu;
                StdToolBarVisiblePMenu: TMenuItem;
@@ -309,7 +307,6 @@ type
                F4: TMenuItem;
                N48: TMenuItem;
                T14: TMenuItem;
-               ToolButton16: TToolButton;
                N50: TMenuItem;
                A11: TMenuItem;
                S5: TMenuItem;
@@ -345,7 +342,6 @@ type
                FavoriteTreeLogDeletePopupMenu: TMenuItem;
                N59: TMenuItem;
                FavoriteTreeNameURLCopyPopupMenu: TMenuItem;
-               ToolButton20: TToolButton;
                N60: TMenuItem;
                ExportFavoriteFileAction1: TMenuItem;
                N6: TMenuItem;
@@ -398,12 +394,31 @@ type
     N73: TMenuItem;
     SelectComboBoxPanel: TPanel;
     SelectComboBoxSplitter: TImage;
-       ToolButton1: TToolButton;
     N74: TMenuItem;
     WikiFAQ: TMenuItem;
     GikoApplicationEvents: TApplicationEvents;
     N22: TMenuItem;
     N42: TMenuItem;
+    DAT2: TMenuItem;
+    N75: TMenuItem;
+    DAT3: TMenuItem;
+    N76: TMenuItem;
+    FavoriteTreeItemNameCopyPopupMenu: TMenuItem;
+    N77: TMenuItem;
+    N78: TMenuItem;
+    SaveThreadFile: TMenuItem;
+    N79: TMenuItem;
+    HTML1: TMenuItem;
+    DAT4: TMenuItem;
+    N80: TMenuItem;
+    SameBoardThreadItem: TMenuItem;
+    N81: TMenuItem;
+    N82: TMenuItem;
+    IDNG1: TMenuItem;
+    IDNG2: TMenuItem;
+    ResPopupClearTimer: TTimer;
+    TaskTrayPopupMenu: TPopupMenu;
+    Exit1: TMenuItem;
                                procedure FormCreate(Sender: TObject);
                procedure FormDestroy(Sender: TObject);
                procedure BrowserStatusTextChange(Sender: TObject;
@@ -503,12 +518,6 @@ type
                        State: TDragState; var Accept: Boolean);
                procedure FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
                        Y: Integer);
-               procedure ListCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
-                       var Handled: Boolean);
-               procedure MainCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
-                       var Handled: Boolean);
-               procedure BrowserCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
-                       var Handled: Boolean);
                procedure FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
     procedure BrowserTabContextPopup(Sender: TObject; MousePos: TPoint;
       var Handled: Boolean);
@@ -543,13 +552,16 @@ type
     procedure GikoApplicationEventsException(Sender: TObject; E: Exception);
     procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
       Shift: TShiftState; X, Y: Integer);
+    procedure GetResURLMenuClick(Sender: TObject);
+    procedure MainCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
+      var Handled: Boolean);
+    procedure ResPopupClearTimerTimer(Sender: TObject);
        private
                { Private \90é\8c¾ }
                FEnabledCloseButton: Boolean;
                FClickNode: TTreeNode;
                FHttpState: Boolean;
-               FHint: TResPopup;
-               FPreviewBrowser: TWebBrowser;
+               FPreviewBrowser: TPreviewBrowser;
                FPreviewURL: string;
                FBrowserSizeHeight: Integer;
                FBrowserSizeWidth: Integer;
@@ -560,7 +572,7 @@ type
                FActiveList: TObject;
                FActiveContent: TBrowserRecord; //
                FActiveBBS : TBBS;
-               FHistoryList: TList;                                    //\83q\83X\83g\83\8a\83\8a\83X\83g
+               FHistoryList: THistoryList;                                     //\83q\83X\83g\83\8a\83\8a\83X\83g
                FTreeType: TGikoTreeType;
                FWorkCount: Integer;
                FNameCookie: string;
@@ -592,6 +604,7 @@ type
                FOrigenCaption: String;                         //\82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83A\83C\83e\83\80\95Ò\8fW\8e\9e\82Ì\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ
                FPreviewBrowserRect: TRect;                     ///< \83v\83\8c\83r\83\85\81[\82Ì\95\\8e¦\88Ê\92u\82ð\8bL\89¯\82·\82é
                FActionListGroupIndexes: array of Integer;      ///<GikoDM\8fã\82Ì\83A\83N\83V\83\87\83\93\83\8a\83X\83g\82Ì\8ae\83A\83N\83V\83\87\83\93\82É\90Ý\92è\82³\82ê\82½GroupIndex\82ð\95Û\91\82·\82é\94z\97ñ
+        FResPopupBrowser: TResPopupBrowser;
                procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
                procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
                procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
@@ -607,7 +620,6 @@ type
                procedure FavoriteClick(Sender: TObject); overload;
                procedure FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
                function OnDocumentContextMenu(Sender: TObject): WordBool;
-               procedure ShowTextPopup;
                function GetWidthAllToolButton(ToolBar: TToolBar): Integer;
                procedure MenuBarChevronMenu;
                procedure LinkBarChevronMenu;
@@ -641,8 +653,6 @@ type
                procedure TreeDoubleClick( Node : TTreeNode );
                /// \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
                procedure SetBBSMenu;
-               /// \83^\83u\8eæ\93¾
-               function GetTabURLs(AStringList: TStringList) : Boolean;
                /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
                procedure       ListColumnPopupMenuOnClick( Sender : TObject );
                //! \8di\82è\8d\9e\82Ý\95\8e\9a\97ñ\90Ý\92è
@@ -659,18 +669,40 @@ type
                procedure GetGroupIndex(ActionList: TActionList);
                //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
                procedure SetGroupIndex(ActionList: TActionList);
+               //! \8ew\92è\82³\82ê\82½\83X\83\8c\83b\83h\82ð\8aJ\82­(\83\8d\83O\82ª\96³\82¢\82Æ\82« or \8ew\92èJUMP\82Ü\82Å\91«\82è\82È\82¢\82Æ\82«\82ÍDL\82·\82é)
+               procedure OpenThreadItem(Thread: TThreadItem; URL: String);
+               //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
+               procedure RefreshListView(Thread: TThreadItem);
+               //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
+               procedure ClearThreadRengeAction;
+        //! \83^\83X\83N\83g\83\8c\83C\82Ì\83A\83C\83R\83\93\8dí\8f\9c\81\95\83t\83H\81[\83\80\95\\8e¦
+        procedure UnStoredTaskTray;
+        //! \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
+        procedure ShowEditors(nCmdShow: Integer);
+        //! \82à\82Á\82Æ\82à\8cÃ\82¢Browser\82Ì\8aJ\95ú
+        procedure ReleaseOldestBrowser;
+        //! \83A\83N\83e\83B\83u\82È\83^\83u\82Æ\93¯\82\94Â\82Ì\8aJ\82¢\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83\81\83j\83\85\81[\83A\83C\83e\83\80\82É\92Ç\89Á
+        procedure AddMenuSameBoardThread;
+        //!  \83A\83N\83e\83B\83u\82È\83^\83u\82Æ\93¯\82\94Â\82Ì\8aJ\82¢\82Ä\82¢\82é\83X\83\8c\83b\83h\83N\83\8a\83b\83N\83C\83x\83\93\83g
+        procedure SameBoardThreadSubItemOnClick(Sender: TObject);
+        //! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
+        procedure CreateResPopupBrowser;
+        //! \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;
                BrowserNullTab: TBrowserRecord;
                FControlThread: TThreadControl;
+        FIconData : TNotifyIconData;
                procedure MoveToURL(const inURL: string);
                function InsertBrowserTab(ThreadItem: TThreadItem; ActiveTab: Boolean = True) : TBrowserRecord;
                procedure ReloadBBS;
@@ -697,20 +729,15 @@ type
                property ActiveBBS : TBBS read FActiveBBS write FActiveBBS;
                property WorkCount: Integer read FWorkCount write FWorkCount;
                procedure SetContent(inThread: TBrowserRecord);
-               function GetActiveContent: TThreadItem;
+               function GetActiveContent(popup :Boolean = false): TThreadItem;
                function GetActiveList: TObject;
 
                procedure SetListViewType(AViewType: TGikoViewType); overload;
                procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;
                procedure PlaySound(SoundEventName: string);
-               function AddHistory( FavItem: TFavoriteThreadItem ): Boolean;
-               procedure ClearHistory;
-               procedure       SaveHistory;
-               procedure       LoadHistory;
                procedure ShowBBSTree( inBBS : TBBS );
                procedure ShowBBSTreeOld( inBBS : TBBS );
                procedure ShowHistoryTree;
-               procedure SetHistoryTreeNode;
                procedure AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
                procedure SetBrowserTabState;
                procedure SetToolBarPopup;
@@ -733,6 +760,8 @@ type
                procedure IndividualAbonID(Atype : Integer);
                //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
                procedure IndividualAbon(Atag, Atype : Integer);
+        //\93¯\88êID\82ðNG\83\8f\81[\83h\82É\93o\98^
+        procedure AddIDtoNGWord(invisible : boolean);
                //\83u\83\89\83E\83U\82Ì\8dÄ\95`\89æ true:\91S\82Ä\82Ì\83^\83u false:\83A\83N\83e\83B\83u\82È\83^\83u\82Ì\82Ý
                procedure RepaintAllTabsBrowser();
                //\83\8a\83\93\83N\83o\81[\90Ý\92è
@@ -744,11 +773,16 @@ type
                procedure DownloadList(Board: TBoard; ForceDownload: Boolean = False);
                //\97\9a\97ð\82©\82ç\8dí\8f\9c
                procedure DeleteHistory( threadItem: TThreadItem );
-               //\83^\83u\82ð\8dí\8f\9c
+               //\83^\83u\82ð\8dí\8f\9c \83X\83\8c\83b\83h\8ew\92è
                procedure DeleteTab(ThreadItem: TThreadItem); overload;
+               //\83^\83u\82ð\8dí\8f\9c \83u\83\89\83E\83U\83\8c\83R\81[\83h\81i\83^\83u\81j\8ew\92è
                procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
+        // \83^\83u\8dí\8f\9c\81i\8eÀ\91\95\95\94\81j
+        procedure DeleteTab(index, selectIndex: Integer); overload;
                //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
-               procedure BrowserMovement(const AName: string);
+               procedure BrowserMovement(const AName: string); overload;
+               //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
+               procedure BrowserMovement(scroll: Integer); overload;
                //Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
                function GetMainForm(): TComponent;
                procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
@@ -760,18 +794,8 @@ type
                procedure OnGestureEnd(Sender: TObject);
                /// \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
                procedure ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
-               //\83X\83N\83\8a\81[\83\93\8fã\82ÉEditorForm\82ª\82¢\82é\82©
-               function EditorFormExists(): boolean;
-               //\83X\83N\83\8a\81[\83\93\8fã\82É\82¢\82é\82·\82×\82Ä\82ÌEditorForm\82©\82ç\96¼\91O\97\9a\97ð\82ð\8dí\8f\9c\82·\82é
-               procedure AllEditroFormNameTextClearClear();
-               //\83X\83N\83\8a\81[\83\93\8fã\82É\82¢\82é\82·\82×\82Ä\82ÌEditorForm\82©\82ç\83\81\81[\83\8b\97\9a\97ð\82ð\8dí\8f\9c\82·\82é
-               procedure AllEditroFormMailTextClearClear();
                //ListView\82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é
                procedure SelectListItem(List: TList);
-               /// \83^\83u\95Û\91
-               function SaveTabURLs : Boolean;
-               /// \83^\83u\93Ç\82Ý\8fo\82µ
-               function LoadTabURLs : Boolean;
                //\8ew\92è\82µ\82½\83\8c\83X\82ð\83R\83s\81[\82·\82é
                procedure KonoresCopy(Number: Integer; ReplaceTag : Boolean);
                //
@@ -788,6 +812,13 @@ type
                function WebBrowserClick(Sender: TObject): WordBool;
                //! \83c\81[\83\8b\83o\81[\82É\83X\83\8c\8di\8d\9e\82Ý\83R\83\93\83{\83{\83b\83N\83X\82ð\90Ý\92è\82·\82é
                procedure SetSelectComboBox();
+
+        //! \83^\83X\83N\83g\83\8c\83C\82É\8ai\94[\82µ\82½\83A\83C\83R\83\93\82ð\83N\83\8a\83b\83N\82µ\82½\82Æ\82«\82Ì\8f\88\97\9d
+        procedure TaskTrayIconMessage(var Msg : TMsg); message WM_USER + 2010;
+        //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
+        procedure StoredTaskTray;
+        //! \93¯ID\83\8c\83X\83A\83\93\83J\81[\95\\8e¦
+        procedure ShowSameIDAncher(const AID: String);
        published
                property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
        end;
@@ -820,13 +851,13 @@ implementation
 
 uses
        GikoUtil, IndividualAbon, Math, Kotehan, KeySetting,
-       YofUtils, ShellAPI, ToolBarUtil, ToolBarSetting,
+       YofUtils, ToolBarUtil, ToolBarSetting,
        GikoXMLDoc, RoundName, IniFiles, FavoriteAdd,
-       FavoriteArrange, AddressHistory, Preview, Gesture,
+       FavoriteArrange, AddressHistory, Gesture,
        About, Option, Round, Splash, Sort, ListSelect, Imm,
        NewBoard, MojuUtils, Clipbrd, GikoBayesian,Y_TextConverter,
        HTMLCreate, ListViewUtils, GikoDataModule, GikoMessage,
-  InputAssistDataModule;
+  InputAssistDataModule, Types, ReplaceDataModule;
 
 const
        BLANK_HTML: string = 'about:blank';
@@ -835,14 +866,13 @@ const
        DandD_THRESHOLD = 5;    //D&D\82Ìè\87\92l\81ipixcel)
        //\83v\83\8c\83r\83\85\81[\83t\83@\83C\83\8b\96¼
        HTML_FILE_NAME  = 'temp_preview.html';
-       ITEM_ICON_THREADLOG1            = 6;            //\83X\83\8c\83A\83C\83R\83\93\81i\83\8d\83O\82 \82è\81j
-       ITEM_ICON_THREADLOG2            = 7;            //\83X\83\8c\83A\83C\83R\83\93\81i\83\8d\83O\82 \82è\81j
        //\83\81\83b\83Z\81[\83WID
        USER_TREECLICK                                  = WM_USER + 2000;
        USER_RESIZED            = WM_USER + 2001;
        USER_MINIMIZED                                  = WM_USER + 2002;
        USER_SETLINKBAR                                 = WM_USER + 2003;
        USER_DOCUMENTCOMPLETE           = WM_USER + 2004;       ///< wParam : TWebBrowser
+    USER_TASKTRAY               = WM_USER + 2010;
 {$R *.DFM}
 
 procedure TGikoForm.CreateParams(var Params: TCreateParams);
@@ -876,6 +906,8 @@ begin
        Writeln('============================================================');
 {$ENDIF}
 //try
+       Sort.SetSortDate(Now());
+
        FTreeType := gttNone;
        // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô
        FStartUp := true;
@@ -886,7 +918,9 @@ begin
        //\82±\82ê\88È\8cãSet\81`\82Å\8dÄ\90Ý\92è\82·\82é\82Ü\82Å\81AAction\82ÌChecked\82ð\82¢\82\82é\82Æ\82«\82Í\92\8d\88Ó\81I
        GetGroupIndex(GikoDM.GikoFormActionList);
        FSearchDialog := nil;
+    FResPopupBrowser := nil;
        CreateBrowsers(BROWSER_COUNT);
+    FIconData.uID := 0;
 
        //\83\81\83j\83\85\81[\83t\83H\83\93\83g
        SetMenuFont;
@@ -994,6 +1028,16 @@ begin
                        GikoDM.NewItemAction.Checked := True;
                        ViewType := gvtNew;
                end;
+       gtrLive:
+               begin
+                       GikoDM.LiveItemAction.Checked := True;
+                       ViewType := gvtLive;
+               end;
+       gtrArch:
+               begin
+                       GikoDM.ArchiveItemAction.Checked := True;
+                       ViewType := gvtArch;
+               end;
        end;
 
 
@@ -1005,6 +1049,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¦
@@ -1107,10 +1152,11 @@ begin
 
 
        // \83q\83X\83g\83\8a\83\8a\83X\83g(LoadHistory \82æ\82è\82à\90æ\82É\8ds\82¤\82±\82Æ)
-       FHistoryList := TList.Create;
+       FHistoryList := THistoryList.Create;
 
        // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
-       LoadHistory;
+       FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
+        TreeView, FTreeType);
 
        //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
        FavoriteDM.SetFavTreeView(FavoriteTreeView);
@@ -1208,9 +1254,6 @@ begin
        //\8dÅ\8fI\8f\84\89ñ\8e\9e\8aÔ
 //     FLastRoundTime := 0;
 
-       //ResHint
-       FHint := TResPopup.Create(Self);
-
        ListView.OnData := TListViewUtils.ListViewData;
 
        // \8dÅ\8cã\82É\91I\91ð\82³\82ê\82½\83L\83\83\83r\83l\83b\83g\82Ì\95\9c\8c³
@@ -1244,25 +1287,14 @@ begin
        dummy1.Caption  := ItemReservPMenu.Caption;
        dummy1.Hint     := ItemReservPMenu.Hint;
 
-       //Samba24\82Ì\83t\83@\83C\83\8b\83`\83F\83b\83N
-       GikoSys.SambaFileExists();
+    // \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;
 
@@ -1278,6 +1310,23 @@ begin
 
        //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\8f\89\8aú\89»
        InputAssistDM.Init(GikoSys.GetInputAssistFileName);
+
+    //\92u\8a·\90Ý\92è\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
+    ReplaceDM.LoadFromFile(GikoSys.GetReplaceFileName);
+
+    //\83\8c\83X\83|\83b\83v\83A\83b\83v\8fÁ\8b\8e\83^\83C\83}\81[
+    ResPopupClearTimer.Interval := GikoSys.Setting.RespopupWait;
+
+    // D&D\82ð\8eó\82¯\8eæ\82é
+    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
+        GikoUtil.MsgBox(Self.Handle, '\82¨\8bC\82É\93ü\82è\82Ì\8f\89\8aú\89»\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B\83M\83R\83i\83r\82ð\8fI\97¹\82µ\82Ü\82·\81B',
+            '\8f\89\8aú\89»\88Ù\8fí');
+        Self.Close;
+    end;
+
 end;
 
 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
@@ -1397,6 +1446,8 @@ begin
 end;
 //
 procedure TGikoForm.FormShow(Sender: TObject);
+var
+       item        : TThreadItem;
 begin
        if FStartUp then begin
                ShowWindow(Application.Handle, SW_HIDE);
@@ -1427,7 +1478,23 @@ begin
 
                //FormCrete\82©\82ç\88Ú\93®\81B
                if GikoSys.Setting.TabAutoLoadSave then begin
-                       GikoDM.TabAutoLoadAction.Execute;
+            GikoDM.TabsOpenAction.Tag := 1;
+                       GikoDM.TabsOpenAction.Execute;
+            GikoDM.TabsOpenAction.Tag := 0;
+            if (GikoSys.Setting.LastCloseTabURL <> '') then begin
+                PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( FActiveContent.Browser ), 0 );
+                if ( FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
+                       while (FActiveContent.Browser.ReadyState <> READYSTATE_COMPLETE) and
+                               (FActiveContent.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
+                               Application.ProcessMessages;
+                    end;
+                       end;
+                item := BBSsFindThreadFromURL( GikoSys.Setting.LastCloseTabURL );
+                if (item <> nil) and (item.IsLogFile) then begin
+                    OpenThreadItem(item, item.URL);
+                end;
+                GikoSys.Setting.LastCloseTabURL := '';
+            end;
                end;
 
         //ActionList\82ÌGroupIndex\82ð\8c³\82É\96ß\82·
@@ -1441,35 +1508,64 @@ procedure TGikoForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
 begin
 //     if GikoForm.WindowState <> wsMinimized then
 //             SaveCoolBarSettings;
+       CanClose := True;
        if ( GikoSys.Setting.ShowDialogForEnd ) and
                        (MessageDlg('\83M\83R\83i\83r\82ð\8fI\97¹\82µ\82Ä\82æ\82ë\82µ\82¢\82Å\82·\82©\81H', mtConfirmation,[mbOk, mbCancel], 0) = mrCancel ) then begin
                CanClose := false;
                        Exit;
-       end else begin
-               CanClose := True;
-               if GikoSys.Setting.TabAutoLoadSave then begin
-                       GikoDM.TabAutoSaveAction.Execute;
-               end;
        end;
-    {    //2ch\8c¾\8cȩ̂²ÙFree
-               if GikoSys.Setting.Gengo <> nil then begin
-                               GikoSys.Setting.Gengo.Free;
+
+    GikoSys.Setting.LastCloseTabURL := '';
+       if GikoSys.Setting.TabAutoLoadSave then begin
+               GikoDM.TabsSaveAction.Execute;
+        if (GetActiveContent <> nil) and
+            (GetActiveContent.IsLogFile) then begin
+            GikoSys.Setting.LastCloseTabURL := GetActiveContent.URL;
+        end;
+       end;
+
+       if (SearchDialog <> nil) then begin
+               if (SearchDialog.Visible) then begin
+                       SearchDialog.Close;
+               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·
+    FControlThread.Terminate;
        Application.Terminate;
 end;
 
 procedure TGikoForm.FormDestroy(Sender: TObject);
 var
        i                               : Integer;
-//     CoolSet: TCoolSet;
        wp                      : TWindowPlacement;
        tmpBool : Boolean;
+    WindowPlacement: TWindowPlacement;
 begin
+    // \83^\83X\83N\83g\83\8c\83C\82Ì\83A\83C\83R\83\93\8dí\8f\9c
+    if (FIconData.uID <> 0) then begin
+        Shell_NotifyIcon(NIM_DELETE, @FIconData);
+    end;
+
        // \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;
        except
        end;
        try
@@ -1477,6 +1573,9 @@ begin
        except
        end;
        try
+        WindowPlacement.length := SizeOf(TWindowPlacement);
+        GetWindowPlacement(Self.Handle, @WindowPlacement);
+
                //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
                wp.length := sizeof(wp);
                GetWindowPlacement(Handle, @wp);
@@ -1484,8 +1583,8 @@ begin
                GikoSys.Setting.WindowLeft := wp.rcNormalPosition.Left;
                GikoSys.Setting.WindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
                GikoSys.Setting.WindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
-               GikoSys.Setting.WindowMax := WindowState = wsMaximized;
-
+               GikoSys.Setting.WindowMax := (WindowState = wsMaximized) or
+                                        (WindowPlacement.flags = WPF_RESTORETOMAXIMIZED);
                GikoSys.Setting.ListStyle := ListView.ViewStyle;
                GikoSys.Setting.CabinetVisible := GikoDM.CabinetVisibleAction.Checked;
                GikoSys.Setting.CabinetWidth := CabinetPanel.Width;
@@ -1526,11 +1625,14 @@ begin
        //\82¨\8bC\82É\93ü\82è\95Û\91
        try
                //FavoriteDM\82Í\8e©\93®\90\90¬\83t\83H\81[\83\80\82È\82Ì\82Å\81A\89ð\95ú\82Í\8e©\93®\93I\82É\82³\82ê\82é
-               FavoriteDM.WriteFavorite;
+        // \8f\89\8aú\89»\88Ù\8fí\8e\9e\82©\82ç\82Ì\8fI\97¹\82Å\82Í\95Û\91\82µ\82È\82¢
+        if not (FavoriteDM.AbEnd) then begin
+               FavoriteDM.WriteFavorite;
+        end;
                FavoriteDM.Clear;
        except
        end;
-       LockWindowUpdate(Self.Handle);
+       //LockWindowUpdate(Self.Handle);
        try
                //\83^\83u\83N\83\8d\81[\83Y
                tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
@@ -1541,6 +1643,11 @@ begin
        end;
        try
                for i := FBrowsers.Count - 1 downto 0 do begin
+            GikoSys.ShowRefCount('browser' + IntToStr(i), TWebBrowser(FBrowsers[i]).ControlInterface);
+            GikoSys.ShowRefCount('document' + IntToStr(i), TWebBrowser(FBrowsers[i]).ControlInterface.Document);
+               end;
+
+               for i := FBrowsers.Count - 1 downto 0 do begin
                        TWebBrowser(FBrowsers[i]).Free;
                end;
                FBrowsers.Clear;
@@ -1575,12 +1682,12 @@ begin
 
        //\83q\83X\83g\83\8a\83\8a\83X\83g\95Û\91
        try
-               SaveHistory;
+               FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
        except
        end;
        try
                try
-                       ClearHistory;
+                       FHistoryList.Clear;
                except
                end;
        finally
@@ -1602,14 +1709,21 @@ begin
         end;
 
        try
-               try
-                       FControlThread.Terminate;
-                       FControlThread.WaitFor;
-               except
-               end;
-       finally
-               FControlThread.Free;
+        try
+            FControlThread.DownloadAbort;
+            FControlThread.Terminate;
+            FControlThread.WaitFor;
+        except
+        end;
+    finally
+        FControlThread.Free;
+       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
+               GikoForm.PlugInMenu.items[i].Free;
        end;
+    GikoForm.PlugInMenu.Clear;
+
 
        // TBBS \82Í\95Û\8e\9d\82µ\82Ä\82¢\82é TCategory, TBoard, TThreadItem \82·\82×\82Ä\82ð\8aJ\95ú\82·\82é
        // TBoard, TThreadItem \82Ì\83f\83X\83g\83\89\83N\83^\82Í\83v\83\89\83O\83C\83\93\82É\94j\8aü\82ð\93`\82¦\82é\82Ì\82Å
@@ -1632,20 +1746,22 @@ begin
                if FEvent <> nil then
                        FEvent.Free;
 
-               //Hint\94j\8aü
-               if FHint <> nil then begin
-                       FHint.ReleaseHandle;
-                       FHint.Free;
-                       FHint := nil;
-               end;
+        try
+            if FResPopupBrowser <> nil then  begin
+                TOleControl(FResPopupBrowser).Parent := nil;
+                FResPopupBrowser.Free;
+            end;
+
+        except
+        end;
                //Preview\94j\8aü
-               if TPreviewBrowser <> nil then begin
+               if FPreviewBrowser <> nil then begin
                        FPreviewBrowser.Free;
                        FPreviewBrowser := nil;
                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
@@ -1720,8 +1836,8 @@ begin
 
        //\97\9a\97ð\82Ì\95Û\91\82Æ\94j\8aü
        try
-               SaveHistory;
-               ClearHistory;
+               FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
+               FHistoryList.Clear;
        except
        end;
 
@@ -1772,7 +1888,8 @@ begin
        ShowBBSTree( BBSs[ 0 ] );
 
        // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
-       LoadHistory;
+    FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
+        TreeView, FTreeType);
 
        //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
        FavoriteDM.ReadFavorite;
@@ -1784,11 +1901,13 @@ begin
        RoundList.LoadRoundThreadFile;
 
        LockWindowUpdate(0);
-       //
-       GikoDM.TabsOpenAction.Execute;
 end;
 
-
+{!
+\todo \89½\8cÌ IE 7 \82Å\82Í about:.. \82É\82È\82é\82Ì\82©
+      (IE 7 \82ª about:.. \82ð\92Ç\89Á\82µ\82Ä\82¢\82é\82Ì\82©\81A\83M\83R\83i\83r\82ª\92Ç\89Á\82µ\82Ä\82¢\82é\82Ì\82©)
+      \92²\8d¸\82·\82é\82±\82Æ
+}
 procedure TGikoForm.BrowserStatusTextChange(Sender: TObject; const Text: WideString);
 var
        p: TPoint;
@@ -1808,23 +1927,41 @@ var
        e: IHTMLElement;
        Ext: string;
        PathRec: TPathRec;
-begin
+    Text2: string;
+    cResPopup: TResPopupBrowser;
+    senderBrowser :TWebBrowser;
+    doc: IHTMLDocument2;
+begin
+    // \83M\83R\83i\83r\82Í\83\8c\83X\83A\83\93\83J\81[\82ª about:blank.. \82Å\8en\82Ü\82é\82±\82Æ\82ð\8aú\91Ò\82µ\82Ä\82¢\82é\82ª
+    // IE 7 \82Å\82Í about:blank.. \82Å\82Í\82È\82­ about:.. \82É\82È\82é\82Ì\82Å\81A\92u\8a·\82·\82é(\93\8a\82°\82â\82è)
+    if Pos('about:..', Text) = 1 then
+        Text2 := 'about:blank..' + Copy( Text, Length('about:..')+1, Length(Text) )
+    else
+        Text2 := Text;
+
        if not( TObject(Sender) is TWebBrowser )then
                Exit;
+
+    senderBrowser := TWebBrowser(Sender);
+    doc := senderBrowser.ControlInterface.Document as IHTMLDocument2;
+
        try
                try
-                       if (TWebBrowser(Sender) <> nil) and (not TWebBrowser(Sender).Busy) and (Assigned(TWebBrowser(Sender).Document)) then begin
-                               if LowerCase(OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset) <> 'shift_jis' then begin
-                                       OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset := 'shift_jis';
+                       if ((not senderBrowser.Busy) and Assigned(doc)) then begin
+                               if LowerCase(doc.charset) <> 'shift_jis' then begin
+                                       doc.charset := 'shift_jis';
                                end;
                        end;
                except
                end;
        finally
        end;
+
        if PreviewTimer.Enabled then
                PreviewTimer.Enabled := False;
+
        Application.CancelHint;
+
        try
                if GetActiveContent <> nil then
                        ActiveFileName := ChangeFileExt(ExtractFileName(GetActiveContent.FileName), '')
@@ -1835,25 +1972,62 @@ begin
                Exit;
        end;
 
-       StatusBar.Panels[1].Text := Text;
+    // \91O\89ñ\82Æ\93¯\82\8fê\8d\87\8fI\97¹
+    if (StatusBar.Panels[1].Text = Text2) then begin
+        if Text2 = '' then begin
+            if FResPopupBrowser <> nil then begin
+                if not(Sender is TResPopupBrowser) then
+                    FResPopupBrowser.Clear
+                else begin
+                    TResPopupBrowser(Sender).ChildClear;
+                end;
+            end;
+        end;
+        Exit;
+    end;
+       StatusBar.Panels[1].Text := Text2;
+
 
-       if FHint <> nil then begin
-               FHint.ReleaseHandle;
-               FHint.ClearAllRes;
-       end;
        if FPreviewBrowser <> nil then
                ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
 
-       if not GikoSys.Setting.UnActivePopup then
-               if not GikoForm.Active then
-                       Exit;
+    if FResPopupBrowser <> nil then begin
+        if not(Sender is TResPopupBrowser) then begin
+            if (FResPopupBrowser.Visible) then begin
+                if ResPopupClearTimer.Interval > 0 then begin
+                    ResPopupClearTimer.Enabled := True;
+                    ResPopupClearTimer.Tag := 0;
+                end else begin
+                    FResPopupBrowser.Clear;
+                end;
+            end;
+        end else begin
+            if ResPopupClearTimer.Interval > 0 then begin
+                ResPopupClearTimer.Enabled := True;
+                ResPopupClearTimer.Tag := 1;
+            end else begin
+                TResPopupBrowser(Sender).ChildClear;
+            end;
+        end;
+    end;
+    cResPopup := nil;
+    
+    if not(Sender is TResPopupBrowser) then
+       if not GikoSys.Setting.UnActivePopup then
+               if not GikoForm.Active then
+                       Exit;
+
+
 
 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10
 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10-15
-
+    // \91¼\82Ì\83A\83v\83\8a\82Å\8f\88\97\9d\82·\82éURL\82©\8am\94F
+    if (ExtPreviewDM.PreviewURL(Text2)) then begin
+        Exit;
+    end;
        s := '';
-       Ext := AnsiLowerCase(ExtractFileExt(Text));
-       if (Pos('http://', Text) = 1) and (GikoSys.Setting.PreviewVisible) and
+       Ext := AnsiLowerCase(ExtractFileExt(Text2));
+       if (Pos('http://', Text2) = 1) and (GikoSys.Setting.PreviewVisible) and
                        ((Ext = '.jpg') or (Ext = '.jpeg') or (Ext = '.gif') or (Ext = '.png')) then begin
                if FPreviewBrowser = nil then begin
                        FPreviewBrowser := TPreviewBrowser.Create(Self);
@@ -1861,34 +2035,54 @@ begin
                        TOleControl(FPreviewBrowser).Parent := nil;
                end;
                FPreviewBrowser.Navigate(BLANK_HTML);//\91O\89ñ\82Ì\83v\83\8c\83r\83\85\81[\89æ\91\9c\8fÁ\8b\8e\97p
-               FPreviewURL := Text;
+               FPreviewURL := Text2;
                PreviewTimer.Interval := GikoSys.Setting.PreviewWait;
                PreviewTimer.Enabled := True;
-       end else if (Pos('about:blank', Text) = 1) or (Pos('http://', Text) = 1) or (Pos('mailto:', Text) = 1) then begin
-               if Pos('mailto:', Text) = 1 then begin
-                       s := StringReplace(Text, 'mailto:', '', [rfIgnoreCase]);
+       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) 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);
-                       p.x := p.x - TWebBrowser(Sender).ClientOrigin.x;
-                       p.y := p.y - TWebBrowser(Sender).ClientOrigin.y;
-                       e := IHTMLDocument2(TWebBrowser(Sender).Document).elementFromPoint(p.x, p.y);
+                       p.x := p.x - senderBrowser.ClientOrigin.x;
+                       p.y := p.y - senderBrowser.ClientOrigin.y;
+                       e := doc.elementFromPoint(p.x, p.y);
                        if (Assigned(e)) then begin
-                               tmp2 := ZenToHan(e.Get_outerText);
+                CreateResPopupBrowser;
+
+                if not(Sender is TResPopupBrowser) then begin
+                    if (FResPopupBrowser.Visible) then begin
+                        FResPopupBrowser.Clear;
+                    end;
+                end else begin
+                    TResPopupBrowser(Sender).ChildClear;
+                end;
+
+                cResPopup := FResPopupBrowser.CreateNewBrowser;
+                               tmp2 := Trim(ZenToHan(e.Get_outerText));
                                if (GikoSys.IsNumeric(tmp2)) then begin
                                        //\82\93\82Í\83\8c\83X\94Ô\8d\86\82Á\82Û\82¢\82Á\82·\81B
-                                       wkIntSt := StrToInt(tmp2);
-                                       wkIntTo := StrToInt(tmp2);
-                                               //s := GetThreadText(wkBBS, wkKey, wkIntSt, wkIntTo, False, False);
-                                       FHint.PopupType := gptThread;
-                                       HTMLCreater.SetResPopupText(FHint, GetActiveContent, wkIntSt, wkIntTo, False, False);
+                                       wkIntSt := StrToInt64(tmp2);
+                                       wkIntTo := StrToInt64(tmp2);
+                    cResPopup.PopupType := gptThread;
+                                       HTMLCreater.SetResPopupText(cResPopup, GetActiveContent(true), wkIntSt, wkIntTo, False, False);
                                end else begin
-                                       FHint.PopupType := gptRaw;
-                                       FHint.Caption := s;
+                    cResPopup.PopupType := gptRaw;
+                    cResPopup.Title := s;
                                end;
                        end;
                end else begin
-                       threadItem := GetActiveContent;
-                       URL := THTMLCreate.GetRespopupURL(Text, threadItem.URL);
+            CreateResPopupBrowser;
+
+            if not(Sender is TResPopupBrowser) then begin
+                if (FResPopupBrowser.Visible) then begin
+                    FResPopupBrowser.Clear;
+                end;
+            end else begin
+                TResPopupBrowser(Sender).ChildClear;
+            end;
+
+                       threadItem := GetActiveContent(true);
+                       URL := THTMLCreate.GetRespopupURL(Text2, threadItem.URL);
                        PathRec := Gikosys.Parse2chURL2(URL);
                        if (PathRec.FNoParam) then begin
                                PathRec.FSt := 1;
@@ -1939,19 +2133,27 @@ begin
                                                wkIntSt := 1;
                                                wkIntTo := 1;
                                        end;
-                                       FHint.PopupType := gptThread;
-                                       HTMLCreater.SetResPopupText(FHint, threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
+                    cResPopup := FResPopupBrowser.CreateNewBrowser;
+                    cResPopup.PopupType := gptThread;
+                                       HTMLCreater.SetResPopupText(cResPopup, threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
                                end;
                        end;
                end;
+        if (cResPopup <> nil) then begin
+            ResPopupClearTimer.Enabled := False;
 
-               if FHint.PopupType = gptRaw then begin
-                       if FHint.Caption <> '' then
-                               ShowTextPopup;
-               end else begin
-                       if (FHint.ResCount <> 0) or (FHint.Title <> '') then
-                               ShowTextPopup;
-               end;
+            if cResPopup.PopupType = gptRaw then begin
+                if cResPopup.Title <> '' then begin
+                    cResPopup.TitlePopup;
+                end;
+            end else begin
+                if cResPopup.RawDocument <> '' then begin
+                    cResPopup.Popup;
+                end else if cResPopup.Title <> '' then begin
+                    cResPopup.TitlePopup;
+                end;
+            end;
+        end;
        end;
 end;
 
@@ -2070,6 +2272,7 @@ var
        ARect: TRect;
 begin
        DefaultDraw := True;
+// \82È\82º\82©\96³\8fð\8c\8f\82ÅExit\82µ\82Ä\82¢\82é
        Exit;
        DefaultDraw := False;
        if (cdsSelected in State) or (cdsHot in State) then begin
@@ -2109,7 +2312,9 @@ var
 const
        kMenuName: string = 'menu:';
 begin
-
+{$IFDEF DEBUG}
+       Writeln(URL);
+{$ENDIF}
        if Pos(kMenuName, URL) <> 0 then begin
                sNo := Copy( URL, Pos( kMenuName, URL ) + Length( kMenuName ), Length( URL ) );
                
@@ -2117,10 +2322,19 @@ begin
 
                Cancel := True;
                GetCursorpos(p);
+        KokoPopupMenu.PopupComponent := nil;
+        if (Sender is TComponent) then
+            KokoPopupMenu.PopupComponent := TComponent(Sender);
                KokoPopupMenu.Tag := StrToInt(sNo);
                KokoPopupMenu.Popup(p.x, p.y);
        end else if Pos('mailto', LowerCase(URL)) <> 0 then begin
                Cancel := not GikoSys.Setting.OpenMailer;
+
+        //@\82Æ.\82ð\8aÜ\82Ü\82È\82¢URL\82Í\83\81\81[\83\8b\83A\83h\83\8c\83X\82Æ\82Ý\82È\82³\82È\82¢
+        //\8eå\82Éage\81Asage\91Î\8dô
+        if (Pos('@', URL) = 0) or (Pos('.', URL) = 0) then begin
+            Cancel := True;
+        end;
        end;
 
 end;
@@ -2262,6 +2476,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;
 // *************************************************************************
@@ -2273,10 +2489,11 @@ var
        s: string;
        boardPlugIn : TBoardPlugIn;
        i: Integer;
-       browserRec      : TBrowserRecord;
        Res : TResRec;
 begin
        try
+        if csDestroying in Self.ComponentState then
+               Exit;
                if Item.DownType = gdtBoard then
                        ATitle := Item.Board.Title
                else
@@ -2297,11 +2514,13 @@ begin
                                                GikoSys.Setting.BoardSortIndex := 0;
                                                GikoSys.Setting.BoardSortOrder := True;
                                        end;
+                                       Sort.SetSortDate(Now());
                                        SetActiveList(Item.Board);
                                end;
                                Item.Board.Modified := True;
                                Item.Board.IsThreadDatRead := True;
                                PlaySound('New');
+                               ListView.Refresh;
                        end else if Item.DownType = gdtThread then begin
                                //\83X\83\8c
                                Item.SaveItemFile;
@@ -2325,15 +2544,12 @@ begin
                                end;
                                if GikoSys.Setting.BrowserTabVisible then begin
                                        if GetActiveContent = Item.ThreadItem then
-                                               browserRec := InsertBrowserTab(Item.ThreadItem)
+                                               InsertBrowserTab(Item.ThreadItem)
                                        else if (ListView.Selected <> nil ) and ( TObject(ListView.Selected.Data) is TThreadItem ) and ( Item.ThreadItem = TThreadItem(ListView.Selected.Data)) then
-                                               browserRec := InsertBrowserTab(Item.ThreadItem, True)
+                                               InsertBrowserTab(Item.ThreadItem, True)
                                        else
-                                               browserRec := InsertBrowserTab(Item.ThreadItem, False);
-                                       if browserRec.Thread = BrowserNullTab.Thread then begin
-                                               browserRec.Movement := BrowserNullTab.Movement;
-                                               BrowserNullTab.Movement := '';
-                                       end;
+                                               InsertBrowserTab(Item.ThreadItem, False);
+
                                end else begin
                                        if (GetActiveContent = Item.ThreadItem) or (FActiveContent = nil) or(FActiveContent.Browser = BrowserNullTab.Browser) then
                                                                                                InsertBrowserTab(Item.ThreadItem);
@@ -2355,9 +2571,11 @@ begin
 
                                //\8f\84\89ñ\82 \82è\82Ì\8fê\8d\87\81\95\82P\82O\82O\82O\92´\82Í\8f\84\89ñ\8dí\8f\9c
                                if (Item.ThreadItem.Round) and (Item.ThreadItem.Count > 1000) then begin
-                                       Item.ThreadItem.Round := False;
-                                       //Item.ThreadItem.RoundName := '';
-                                       AddMessageList('\81\9a1000\94­\8c¾\82ð\92´\82¦\82½\82Ì\82Å\8f\84\89ñ\82ð\8dí\8f\9c\82µ\82Ü\82µ\82½ - [' + Item.ThreadItem.Title + ']', nil, gmiOK);
+                    // 2ch\88È\8aO\82Í\81A1000\82ª\8dÅ\8d\82\82©\95s\96¾\82È\82Ì\82Å\81A2ch\8cÀ\92è\82É\82·\82é
+                    if (Item.ThreadItem.ParentBoard.Is2ch) then begin
+                                       Item.ThreadItem.Round := False;
+                                       AddMessageList('\81\9a1000\94­\8c¾\82ð\92´\82¦\82½\82Ì\82Å\8f\84\89ñ\82ð\8dí\8f\9c\82µ\82Ü\82µ\82½ - [' + Item.ThreadItem.Title + ']', nil, gmiOK);
+                    end;
                                end;
                                TreeView.Refresh;
                                //ListView\82Å\82±\82Ì\83X\83\8c\82ª\8aÜ\82Ü\82ê\82é\94Â\82ð\95\\8e¦\82µ\82Ä\82¢\82é\82Æ\82«\82Ì\8dX\90V\8f\88\97\9d
@@ -2370,11 +2588,14 @@ begin
                                                gvtAll: ListView.Items.Count := TBoard(ActiveList).Count;
                                                gvtLog: ListView.Items.Count := TBoard(ActiveList).LogThreadCount;
                                                gvtNew: ListView.Items.Count := TBoard(ActiveList).NewThreadCount;
+                                               gvtArch: ListView.Items.Count := TBoard(ActiveList).ArchiveThreadCount;
+                                               gvtLive: ListView.Items.Count := TBoard(ActiveList).LiveThreadCount;
                                                gvtUser: ListView.Items.Count := TBoard(ActiveList).UserThreadCount;
                                        end;
                                end;
+                               RefreshListView(Item.ThreadItem);
                        end;
-                       ListView.Refresh;
+
                end else if Item.State = gdsNotModify then begin
                        //\95Ï\8dX\83i\83V
 {                      if (Item.DownType = gdtThread) and (AddHistory(Item.ThreadItem)) then begin
@@ -2416,6 +2637,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;
@@ -2425,6 +2649,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½';
@@ -2432,6 +2658,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) + ')';
@@ -2458,6 +2686,19 @@ begin
        end;
 end;
 
+//! \82à\82Á\82Æ\82à\8cÃ\82¢Browser\82Ì\8aJ\95ú
+procedure TGikoForm.ReleaseOldestBrowser;
+var
+    i: Integer;
+begin
+    for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
+        if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser =
+                TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
+            ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
+            break;
+        end;
+    end;
+end;
 
 function TGikoForm.InsertBrowserTab(
        ThreadItem      : TThreadItem;
@@ -2467,6 +2708,7 @@ var
        i, j, idx               : Integer;
        favItem                 : TFavoriteThreadItem;
        newBrowser      : TBrowserRecord;
+    ins : Integer;
 begin
 
        Result := nil;
@@ -2482,7 +2724,7 @@ begin
                                FBrowsers.Move(BROWSER_COUNT - 1, 0);
                end;
                favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title );
-               if not AddHistory( favItem ) then
+               if not FHistoryList.AddHistory( favItem, TreeView, FTreeType ) then
                        favItem.Free;
 
                for i := 0 to BrowserTab.Tabs.Count - 1 do begin
@@ -2490,12 +2732,8 @@ begin
                                if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
                                        Result := TBrowserRecord( BrowserTab.Tabs.Objects[i] );
                                        if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = nil then begin
-                                               for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
-                                                       if TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
-                                                               ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
-                                                               break;
-                                                       end;
-                                               end;
+                        //\88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
+                        ReleaseOldestBrowser;
                                                TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
                                                TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
                                                FBrowsers.Move(BROWSER_COUNT - 1, 0);
@@ -2510,21 +2748,15 @@ begin
                        end;
                end;
                idx := BrowserTab.TabIndex;
-               if GikoSys.Setting.BrowserTabAppend = gtaFirst then begin
-                       newBrowser := TBrowserRecord.Create;
-                       for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
-                               if TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
-                                       ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
-                                       break;
-                               end;
-                       end;
-                       newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
-                       FBrowsers.Move(BROWSER_COUNT - 1, 0);
-                       //newBrowser.Browser.Navigate(BLANK_HTML);
-                       newBrowser.thread := ThreadItem;
-                       newBrowser.Repaint := true;
-//                     newBrowser.OnlyHundred := GikoSys.OnlyAHundredRes;
+        newBrowser := TBrowserRecord.Create;
+        // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
+        ReleaseOldestBrowser;
+        newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
+        FBrowsers.Move(BROWSER_COUNT - 1, 0);
+        newBrowser.thread := ThreadItem;
+        newBrowser.Repaint := true;
 
+               if GikoSys.Setting.BrowserTabAppend = gtaFirst then begin
                        BrowserTab.Tabs.InsertObject(0, GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
                        if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
                                DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 1 ] ) );
@@ -2534,22 +2766,7 @@ begin
                        if ActiveTab then begin
                                BrowserTab.TabIndex := 0;
                        end;
-
-               end else begin
-                       newBrowser := TBrowserRecord.Create;
-                       for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
-                               if TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
-                                       ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
-                                       break;
-                               end;
-                       end;
-                       newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
-                       FBrowsers.Move(BROWSER_COUNT - 1, 0);
-                       //newBrowser.Browser.Navigate(BLANK_HTML);
-                       newBrowser.thread := ThreadItem;
-//                     newBrowser.OnlyHundred := GikoSys.OnlyAHundredRes;
-                       newBrowser.Repaint := true;
-
+               end else if GikoSys.Setting.BrowserTabAppend = gtaLast then begin
                        i := BrowserTab.Tabs.AddObject(GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
                        if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
                                DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 0 ] ) );
@@ -2562,7 +2779,40 @@ begin
                                else
                                        BrowserTab.TabIndex := i;
                        end;
-               end;
+               end else begin
+            // \83^\83u\88Ê\92u\82ð\8eæ\93¾
+            ins := -1;
+            for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
+            if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser =
+                    TWebBrowser(FBrowsers[1]) then begin
+                    ins := i;
+                    break;
+                end;
+            end;
+            if GikoSys.Setting.BrowserTabAppend = gtaRight then begin
+                Inc(ins);
+                   end;
+            // \83^\83u\82ª\96³\82¢\82Æ\82«\82È\82Ç\91Î\8dô
+            if (ins < 0) then begin
+                ins := 0;
+            end;
+                       BrowserTab.Tabs.InsertObject(ins, GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
+                       if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
+                if GikoSys.Setting.BrowserTabAppend = gtaRight then begin
+                               DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 0 ] ) );
+                end else begin
+                    DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 1 ] ) );
+                end;
+                       end;
+                       //end;
+                       BrowserTab.Repaint;
+                       if ActiveTab then begin
+                               if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 0) then
+                                       BrowserTab.TabIndex := 0
+                               else
+                                       BrowserTab.TabIndex := ins;
+                       end;
+        end;
                Result := newBrowser;
                if(ActiveTab) or (idx = -1) then begin
                        BrowserTab.OnChange(nil);
@@ -2572,9 +2822,9 @@ begin
                        BrowserNullTab := TBrowserRecord.Create;
                        BrowserNullTab.Browser := Browser;
                end;
-               if BrowserNullTab.thread <> ThreadItem then begin
-               BrowserNullTab.Movement := '';
-               end;
+//             if BrowserNullTab.thread <> ThreadItem then begin
+//                     BrowserNullTab.Movement := '';
+//             end;
                BrowserNullTab.thread := ThreadItem;
                Result := BrowserNullTab;
                BrowserTab.TabIndex := -1;
@@ -2591,9 +2841,8 @@ var
        BBSID: string;
        FileName: string;
        sTitle: string;
-       doc:  Variant;
+       doc: OleVariant;
        s: string;
-       i: Integer;
        idx: Integer;
        ThreadItem: TThreadItem;
        Thread: TBrowserRecord;
@@ -2602,18 +2851,18 @@ var
 begin
        Thread := inThread;
        idx := BrowserTab.TabIndex;
-       if (FActiveContent <> nil) and
+       if  (not FStartUp) and
+        (FActiveContent <> nil) and
                (FActiveContent.Thread <> Thread.Thread) and
                (FActiveContent.Browser <> nil) and
-               (Assigned(FActiveContent.Browser.Document)) then begin
-               try
-               try
-                       Sleep(1);
-                       FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document).Body).ScrollTop;
-               except
-                       on E: Exception do
-                               MsgBox(Handle, E.Message, 'SetContent[<-ScrollTop]', 0);
-               end;
+               (Assigned(FActiveContent.Browser.ControlInterface.Document)) then begin
+        try
+            try
+                FActiveContent.Thread.ScrollTop := FActiveContent.Browser.OleObject.Document.Body.ScrollTop;
+            except
+            on E: Exception do
+                MsgBox(Handle, E.Message, 'SetContent[<-ScrollTop]', 0);
+        end;
                finally
                end;
        end;
@@ -2631,12 +2880,8 @@ begin
        end     else if Thread.Browser = nil then begin
                if FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then
                        FBrowsers.Move(BROWSER_COUNT - 1, 0);
-               for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
-                       if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
-                               ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
-                               break;
-                       end;
-               end;
+        // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
+        ReleaseOldestBrowser;
                Thread.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
                FBrowsers.Move(BROWSER_COUNT - 1, 0);
        end;
@@ -2644,6 +2889,12 @@ begin
        ThreadTitle := Thread.Thread.Title;
        ThreadPTitle := Thread.Thread.ParentBoard.Title;
        //ThreadScrollTop := Thread.Thread.ScrollTop;
+    if Thread.Thread.IsLogFile then  begin
+        if not FileExists(Thread.Thread.GetThreadFileName) then begin
+            Thread.Thread.DeleteLogFile;
+        end;
+    end;
+
        ThreadIsLog := Thread.Thread.IsLogFile;
        ThreadItem := Thread.Thread;
        ThreadNewArraical :=  Thread.Thread.NewArrival;
@@ -2663,10 +2914,9 @@ begin
                                ShowWindow(FActiveContent.Browser.Handle, SW_HIDE);
                end;
                ShowWindow(Thread.Browser.Handle, SW_SHOW);
-               if (not Assigned(Thread.Browser.Document)) then begin
+               if (not Assigned(Thread.Browser.ControlInterface.Document)) then begin
                        Thread.Browser.Navigate('about:blank');
                end;
-
                while (Thread.Browser.ReadyState <> READYSTATE_COMPLETE) and
                                (Thread.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
                        Application.ProcessMessages;
@@ -2675,25 +2925,44 @@ begin
                        end;
                end;
 
+               if (Thread <> nil) and (ThreadItem <>nil) then begin
+                       BrowserBoardNameLabel.Caption := ThreadPTitle;
+                       ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
+                       BrowserNameLabel.Caption := ThreadTitle;
+                       ItemImage.Picture := nil;
+                       if ThreadIsLog then
+                               if ThreadNewArraical then
+                                       ItemImageList.GetBitmap(2, ItemImage.Picture.Bitmap)
+                               else
+                                       ItemImageList.GetBitmap(0, ItemImage.Picture.Bitmap)
+                       else
+                               ItemImageList.GetBitmap(1, ItemImage.Picture.Bitmap);
+
+                       ItemImage.Left := BrowserBoardNameLabel.Left + BrowserBoardNameLabel.Width + 8;
+                       BrowserNameLabel.Left := ItemImage.Left + 20;
+
+               end;
                //ActiveContent\81@\82Ì\8dX\90V
                FActiveContent := Thread;
 
                if not ThreadIsLog then begin
                        Self.Caption := GikoDataModule.CAPTION_NAME ;
-            //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\8fÁ\8b\8e
+                       //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\8fÁ\8b\8e
                        StatusBar.Panels[THREADSIZE_PANEL].Text := '';
                        try
+                               Thread.Browser.BringToFront;
                                s := '<HTML><BODY><CENTER>\82±\82Ì\83X\83\8c\83b\83h\82Í\8eæ\93¾\82µ\82Ä\82¢\82Ü\82¹\82ñ</CENTER></BODY></HTML>';
-                               doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
+                               doc := Thread.Browser.OleObject.Document;
                                doc.open;
                                doc.charset := 'Shift_JIS';
                                doc.Write(s);
                                doc.Close;
                        finally
+                               
                        end;
                end else begin
                        Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + ThreadTitle + ']';
-            //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
+                       //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
                        StatusBar.Panels[THREADSIZE_PANEL].Text := Format('%6.2f kB', [ThreadItem.Size / 1024]);
                        StatusBar.Panels[THREADSIZE_PANEL].Width :=
                                Max(StatusBar.Canvas.TextWidth(StatusBar.Panels[THREADSIZE_PANEL].Text), 70);
@@ -2703,59 +2972,30 @@ begin
                                Thread.Repaint := false;
 
                                Thread.Browser.OnStatusTextChange := nil;
-                               doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
-
-                               //GikoSys.CreateHTML2(doc, ThreadItem, sTitle);
-                               HTMLCreater.CreateHTML2(doc, ThreadItem, sTitle);
+                               LockWindowUpdate(Thread.Browser.ParentWindow);
+                               HTMLCreater.CreateHTML2(Thread.Browser, ThreadItem, sTitle);
                                Thread.Browser.OnStatusTextChange := BrowserStatusTextChange;
-
-                               if ThreadItem = nil then begin
-                                       FActiveContent := nil;
-                                       BrowserTab.Repaint;
-                                       Exit;
-                               end;
                                PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( Thread.Browser ), 0 );
-                       end else begin
-                               // JUMP\82ð\8ew\92è\82³\82ê\82Ä\82¢\82½\82çJUMP\82·\82é
-                               if (Thread.Movement <> '') then begin
-                                       Thread.Move(Thread.Movement);
-                                       Thread.Movement := '';
-                               end;
                        end;
                end;
-               if (Thread <> nil) and (ThreadItem <>nil) then begin
-                       BrowserBoardNameLabel.Caption := ThreadPTitle;
-                       ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
-                       BrowserNameLabel.Caption := ThreadTitle;
-                       ItemImage.Picture := nil;
-                       if ThreadIsLog then
-                               if ThreadNewArraical then
-                                       ItemImageList.GetBitmap(2, ItemImage.Picture.Bitmap)
-                               else
-                                       ItemImageList.GetBitmap(0, ItemImage.Picture.Bitmap)
-                       else
-                               ItemImageList.GetBitmap(1, ItemImage.Picture.Bitmap);
-
-                       ItemImage.Left := BrowserBoardNameLabel.Left + BrowserBoardNameLabel.Width + 8;
-                       BrowserNameLabel.Left := ItemImage.Left + 20;
 
-                       //Thread\82Ì\94Â\82Æ\95\\8e¦\82µ\82Ä\82¢\82é\94Â\82ª\93¯\82\82È\82ç\95`\89æ\82ð\8dX\90V\82·\82é
-                       if (FActiveList is TBoard) and (TBoard(ActiveList) = ThreadItem.ParentBoard) then
-                               ListView.Refresh;
-               end else begin
-                       FActiveContent := nil;
-               end;
+               RefreshListView(ThreadItem);
        finally
                Screen.Cursor := crDefault;
        end;
 end;
 
-function TGikoForm.GetActiveContent: TThreadItem;
+function TGikoForm.GetActiveContent(popup :Boolean = false): TThreadItem;
 begin
        try
-               if FActiveContent <> nil then
-                       Result := FActiveContent.Thread
-               else
+               if FActiveContent <> nil then begin
+                       Result := FActiveContent.Thread;
+            if (popup) and
+                (FResPopupBrowser <> nil) and (FResPopupBrowser.CurrentBrowser.Visible = True) then
+                if (FResPopupBrowser.CurrentBrowser.Thread <> nil) then begin
+                    Result := FResPopupBrowser.CurrentBrowser.Thread;
+                end;
+               end else
                        Result := nil;
        except
                Result := nil;
@@ -2851,7 +3091,10 @@ begin
                        //gvtAll: ListView.Items.Count := Board.Count;
                        gvtLog: Board.LogThreadCount := Board.GetLogThreadCount;
                        gvtNew: Board.NewThreadCount := Board.GetNewThreadCount;
+                       gvtArch: Board.ArchiveThreadCount := Board.GetArchiveThreadCount;
+                       gvtLive: Board.LiveThreadCount := Board.GetLiveThreadCount;
                        gvtUser: Board.UserThreadCount:= Board.GetUserThreadCount;
+
                end;
 
                SetActiveList(Board);
@@ -2883,6 +3126,14 @@ begin
                                ListView.Canvas.Font.Color := clGreen;
                                s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90V\92\85\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
                        end;
+                       gvtArch: begin
+                               ListView.Canvas.Font.Color := clFuchsia;
+                               s := '\82±\82Ì\83r\83\85\81[\82É\82ÍDAT\97\8e\82¿\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
+                       end;
+                       gvtLive: begin
+                               ListView.Canvas.Font.Color := clMaroon;
+                               s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90\91\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
+                       end;
                        gvtUser: begin
                                ListView.Canvas.Font.Color := clNavy;
                                s := '\82±\82Ì\83r\83\85\81[\82É\82Í\83^\83C\83g\83\8b\82ª\81u%s\81v\82ð\8aÜ\82Þ\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
@@ -2968,218 +3219,44 @@ begin
        end;
 end;
 
-function TGikoForm.AddHistory( favItem : TFavoriteThreadItem ): Boolean;
-var
-       i: Integer;
-       Item: TFavoriteThreadItem;
-       Node: TTreeNode;
-begin
-//     Result := False;
-//     if (GetActiveContent = ThreadItem) and
-//                     (ThreadItem.Count <= ThreadItem.Kokomade) then
-//             Exit;
-//     if GetActiveContent = ThreadItem then
-//             Exit;
-
-       Result := True;
-       if FTreeType = gttHistory then
-       TreeView.Selected := nil;
-
-       for i := 0 to FHistoryList.Count - 1 do begin
-               if TObject(FHistoryList[i]) is TFavoriteThreadItem then begin
-                       Item := TFavoriteThreadItem(FHistoryList[i]);
-                       if Item.URL = favItem.URL then begin
-//                             SetContent(ThreadItem);
-                               FHistoryList.Move(i, 0);
-                               if FTreeType = gttHistory then
-                                       if TreeView.Items.GetFirstNode <> TreeView.Items[ i ] then
-                                               TreeView.Items[ i ].MoveTo( TreeView.Items.GetFirstNode, naInsert );
-                                                               Result := false;
-                               Exit;
-                       end;
-               end;
-       end;
-
-       if FHistoryList.Count > 0 then
-               FHistoryList.Insert( 0, favItem )
-       else
-               FHistoryList.Add( favItem );
-//     SetContent(ThreadItem);
-//     while GikoSys.Setting.AddressHistoryCount < FHistoryList.Count do begin
-       while GikoSys.Setting.MaxRecordCount < FHistoryList.Count do begin
-               i := FHistoryList.Count - 1;
-               TObject( FHistoryList.Items[ i ] ).Free;
-               FHistoryList.Delete( i );
-       end;
-
-       if FTreeType = gttHistory then begin
-               Node := TreeView.Items.Add( nil, favItem.Title );
-               Node.MoveTo( TreeView.Items.GetFirstNode, naInsert );
-               {
-               if favItem.NewArrival then begin
-                       Node.ImageIndex := ITEM_ICON_THREADNEW1;
-                       Node.SelectedIndex := ITEM_ICON_THREADNEW2;
-               end else begin
-                       Node.ImageIndex := ITEM_ICON_THREADLOG1;
-                       Node.SelectedIndex := ITEM_ICON_THREADLOG2;
-               end;
-               }
-               // \95\89\89×\82ð\82©\82¯\82½\82­\82È\82¢\82Ì\82Å NewArrival \82Ì\83`\83F\83b\83N\82ð\8ds\82í\82È\82¢
-               // \81¦favItem.Item \83v\83\8d\83p\83e\83B\82Í dat \82Ì\93Ç\82Ý\8d\9e\82Ý\82ð\95K\97v\82Æ\82·\82é
-               Node.ImageIndex := ITEM_ICON_THREADLOG1;
-               Node.SelectedIndex := ITEM_ICON_THREADLOG2;
-               Node.Data := favItem;
-               //while GikoSys.Setting.AddressHistoryCount < TreeView.Items.Count do begin
-               while GikoSys.Setting.MaxRecordCount < TreeView.Items.Count do begin
-                       i := TreeView.Items.Count - 1;
-                       TreeView.Items.Item[ i ].Delete;
-               end;
-       end;
-end;
-
+//\97\9a\97ð\82©\82ç\8dí\8f\9c
 procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );
-var
-       i: Integer;
 begin
-       for i := 0 to FHistoryList.Count - 1 do begin
-               if threadItem.URL = TFavoriteThreadItem( FHistoryList.Items[i] ).URL then begin
-                       TFavoriteThreadItem( FHistoryList.Items[ i ] ).Free;
-                       FHistoryList.Delete(i);
-            FHistoryList.Capacity := FHistoryList.Count;
-                       Break;
-               end;
-       end;
+    FHistoryList.DeleteHistory( threadItem, TreeView, TreeType );
 end;
 
-procedure TGikoForm.ClearHistory;
+procedure TGikoForm.ShowBBSTreeOld(
+       inBBS : TBBS
+);
 var
-       i : Integer;
+       i, b            : Integer;
+       item            : TMenuItem;
 begin
-       //FHistoryList.Clear;
-
        try
-               for i := FHistoryList.Count - 1 downto 0 do begin
-                       if TObject(FHistoryList[ i ]) is TFavoriteThreadItem then
-               TFavoriteThreadItem(FHistoryList[ i ]).Free
-            else if TObject(FHistoryList[ i ]) is TFavoriteBoardItem then
-                TFavoriteBoardItem(FHistoryList[ i ]).Free;
-
-                       //FHistoryList.Delete(i);
-        end;
-       except
-       end;
-
-       FHistoryList.Clear;
-    FHistoryList.Capacity := FHistoryList.Count;
+               FavoriteTreeView.Visible := False;
+               FavoriteToolBar.Hide;
+               TreeView.Visible := True;
 
-end;
+               b := CabinetSelectPopupMenu.Items.Count - 1;
+               for i := 0 to b do begin
+                       item := CabinetSelectPopupMenu.Items[ i ];
+                       if item is TBBSMenuItem then begin
+                               if TBBSMenuItem( item ).Data = inBBS then begin
+                                       item.Checked := True;
+                                       // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
+                                       CabinetMenu.Items[ i ].Checked := True;
+                                       GikoSys.Setting.CabinetIndex := i;
+                                       Continue;
+                               end;
+                       end;
+                       item.Checked := False;
+                       // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
+                       CabinetMenu.Items[ i ].Checked := False;
+               end;
+               CabinetSelectToolButton.Caption := inBBS.Title;
 
-procedure TGikoForm.SaveHistory;
-var
-       i, bound        : Integer;
-       saveList        : TstringList;
-begin
-
-       saveList := TStringList.Create;
-       try
-               FHistoryList.Pack;
-        FHistoryList.Capacity := FHistoryList.Count;
-               saveList.Add('<?xml version="1.0" encoding="Shift_JIS" standalone="yes"?>');
-               saveList.Add('<address>');
-               bound := FHistoryList.Count - 1;
-               for i := bound downto 0 do begin
-                       // title \82Í\8d¡\82Ì\82Æ\82±\82ë\8eg\82Á\82Ä\82¢\82È\82¢
-                       saveList.Add(
-                               '<history url="' + HtmlEncode( TFavoriteThreadItem( FHistoryList[ i ] ).URL ) + '"' +
-                               ' title="' + HtmlEncode( TFavoriteThreadItem( FHistoryList[ i ] ).Title ) + '"/>');
-               end;
-               saveList.Add('</address>');
-               saveList.SaveToFile( GikoSys.GetConfigDir + 'History.xml' );
-       finally
-               saveList.Free;
-       end;
-
-end;
-
-procedure TGikoForm.LoadHistory;
-var
-       i, bound                : Integer;
-       fileName                : string;
-       XMLDoc                  : IXMLDocument;
-       XMLNode                 : IXMLNode;
-       HistoryNode     : IXMLNode;
-       s                                               : string;
-       favItem                 : TFavoriteThreadItem;
-begin
-
-       fileName := GikoSys.GetConfigDir + 'History.xml';
-
-       if FileExists( fileName ) then begin
-               try
-            XMLDoc := IXMLDocument.Create;
-                       //XMLDoc := LoadXMLDocument(FileName);
-            LoadXMLDocument(FileName, XMLDoc);
-                       try
-                               XMLNode := XMLDoc.DocumentElement;
-
-                               if XMLNode.NodeName = 'address' then begin
-                                       bound := XMLNode.ChildNodes.Count - 1;
-                                       for i := 0 to bound do begin
-                                               HistoryNode := XMLNode.ChildNodes[i];
-                                               if HistoryNode.NodeName = 'history' then begin
-                                                       //if FReadCount >= sl.Count then begin
-                                                               s := Trim(HistoryNode.Attributes['url']);
-                                                               if s <> '' then begin
-                                                                       favItem := TFavoriteThreadItem.Create(
-                                                                               s, HistoryNode.Attributes[ 'title' ] );
-                                                                       if not AddHistory( favItem ) then
-                                       favItem.Free;
-                                                               end;
-                                                       //end;
-                                               end;
-                                       end;
-                               end;
-                       finally
-                               XMLDoc.Free;
-                       end;
-               except
-               end;
-       end;
-
-end;
-
-procedure TGikoForm.ShowBBSTreeOld(
-       inBBS : TBBS
-);
-var
-       i, b            : Integer;
-       item            : TMenuItem;
-begin
-       try
-               FavoriteTreeView.Visible := False;
-               FavoriteToolBar.Hide;
-               TreeView.Visible := True;
-
-               b := CabinetSelectPopupMenu.Items.Count - 1;
-               for i := 0 to b do begin
-                       item := CabinetSelectPopupMenu.Items[ i ];
-                       if item is TBBSMenuItem then begin
-                               if TBBSMenuItem( item ).Data = inBBS then begin
-                                       item.Checked := True;
-                                       // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
-                                       CabinetMenu.Items[ i ].Checked := True;
-                                       GikoSys.Setting.CabinetIndex := i;
-                                       Continue;
-                               end;
-                       end;
-                       item.Checked := False;
-                       // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
-                       CabinetMenu.Items[ i ].Checked := False;
-               end;
-               CabinetSelectToolButton.Caption := inBBS.Title;
-
-               GikoDM.CabinetHistoryAction.Checked := False;
-               GikoDM.CabinetFavoriteAction.Checked := False;
+               GikoDM.CabinetHistoryAction.Checked := False;
+               GikoDM.CabinetFavoriteAction.Checked := False;
 
                if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS) then begin
                        FTreeType := gtt2ch;
@@ -3307,43 +3384,11 @@ begin
                FTreeType := gttHistory;
                HistoryToolBar.Show;
                FavoriteToolBar.Hide;
-               SetHistoryTreeNode;
+        FHistoryList.SetTreeNode( TreeView );
                CabinetSelectToolButton.Caption := '\97\9a\97ð\83\8a\83X\83g';
        end;
 end;
 
-procedure TGikoForm.SetHistoryTreeNode;
-var
-       i: Integer;
-       Node: TTreeNode;
-       Item: TFavoriteThreadItem;
-begin
-       TreeView.Items.BeginUpdate;
-       try
-               TreeView.Items.Clear;
-               for i := 0 to FHistoryList.Count - 1 do begin
-                       Item := TFavoriteThreadItem(FHistoryList[i]);
-                       Node := TreeView.Items.Add(nil, Item.Title);
-                       {
-                       if Item.Item.NewArrival then begin
-                               Node.ImageIndex := ITEM_ICON_THREADNEW1;
-                               Node.SelectedIndex := ITEM_ICON_THREADNEW2;
-                       end else begin
-                               Node.ImageIndex := ITEM_ICON_THREADLOG1;
-                               Node.SelectedIndex := ITEM_ICON_THREADLOG2;
-                       end;
-                       }
-                       // \95\89\89×\82ð\82©\82¯\82½\82­\82È\82¢\82Ì\82Å NewArrival \82Ì\83`\83F\83b\83N\82ð\8ds\82í\82È\82¢
-                       // \81¦Item.Item \83v\83\8d\83p\83e\83B\82Í dat \82Ì\93Ç\82Ý\8d\9e\82Ý\82ð\95K\97v\82Æ\82·\82é
-                       Node.ImageIndex := ITEM_ICON_THREADLOG1;
-                       Node.SelectedIndex := ITEM_ICON_THREADLOG2;
-                       Node.Data := Item;
-               end;
-       finally
-               TreeView.Items.EndUpdate;
-       end;
-end;
-
 procedure TGikoForm.SelectTreeNode(Item: TObject; CallEvent: Boolean);
 var
        ChangeEvent: TTVChangedEvent;
@@ -3392,7 +3437,6 @@ begin
        end else begin
                if Item <> FActiveList then begin
                        ActiveListColumnSave;
-
                        if (Item is TBBS) or (Item is TCategory) then begin
                                ListView.Columns.Clear;
                                SetActiveList( Item );
@@ -3406,6 +3450,7 @@ begin
                                                Screen.Cursor := crDefault;
                                        end;
                                end;
+                               Sort.SetSortDate(Now());
                                SetActiveList( Item );
                        end;
                end;
@@ -3541,7 +3586,14 @@ begin
                FActiveContent.Move(AName);
        end;
 end;
-
+//\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
+procedure TGikoForm.BrowserMovement(scroll: Integer);
+begin
+       if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
+               and (FActiveContent <> nil) then begin
+               FActiveContent.Move(scroll);
+       end;
+end;
 procedure TGikoForm.TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
 begin
        if TObject(Node.Data) is TBBS then begin
@@ -3607,139 +3659,91 @@ end;
 
 procedure TGikoForm.DeleteTab(BrowserRecord: TBrowserRecord);
 var
-       i, j, idx: Integer;
-       doc: Variant;
+       i: Integer;
 begin
-       idx := BrowserTab.TabIndex;
        FTabHintIndex := -1;
        for i := 0 to BrowserTab.Tabs.Count - 1 do begin
                if TBrowserRecord(BrowserTab.Tabs.Objects[i]) = BrowserRecord then begin
-                       try
-                               if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
-                                       doc := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser.Document;
-                                       TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := doc.Body.ScrollTop;
-                               end;
-                       except
-                               TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := 0;
-                       end;
-                       if( FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[i]) ) then
-                               FActiveContent := nil;
-                       if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
-                               j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser);
-                               if j <> -1 then
-                                       FBrowsers.Move(j, BROWSER_COUNT - 1);
-                       end;
-                       BrowserTab.Tabs.BeginUpdate;
-                       try
-                               TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
-                               if ( BrowserTab.Tabs.Count - 1 = i ) and
-                                       ( BrowserTab.TabRect(i).Left
-                                               <= BrowserTab.DisplayRect.Left ) then begin
-                                       BrowserTab.ScrollTabs(-1);
-                               end;
-                               BrowserTab.Tabs.Delete(i);
-                               if idx > i then begin
-                                       BrowserTab.TabIndex := idx - 1;
-                               end else begin
-                                       if BrowserTab.Tabs.Count -1 >= idx then
-                                               BrowserTab.TabIndex := idx
-                                       else
-                                               BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
-                               end;
-                       finally
-                               BrowserTab.Tabs.EndUpdate;
-                       end;
-                       if BrowserTab.Tabs.Count = 0 then begin
-                               BrowserNullTab.Thread := nil;
-                       end;
-                       if(BrowserTab.TabIndex <> -1) and
-                               ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
-                               for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
-                                       if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
-                                                = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
-                                       begin
-                                               ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
-                                               break;
-                                       end;
-                               end;
-                               TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
-                                        :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
-                               TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
-                               FBrowsers.Move(BROWSER_COUNT - 1, 0);
-                       end;
-                       if( FActiveContent = nil) then
-                               BrowserTab.OnChange(nil);
-                       Exit;
+            DeleteTab(i, BrowserTab.TabIndex);
+                       Break;
                end;
        end;
 end;
 procedure TGikoForm.DeleteTab(ThreadItem: TThreadItem);
 var
-       i, j, idx: Integer;
-       doc: Variant;
+       i: Integer;
 begin
-       idx := BrowserTab.TabIndex;
        FTabHintIndex := -1;
        for i := 0 to BrowserTab.Tabs.Count - 1 do begin
                if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
-                       try
-                               if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
-                                       doc := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser.Document;
-                                       TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := doc.Body.ScrollTop;
-
-                               end;
-                       except
-                               TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := 0;
-                       end;
-                       if(FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[i])) then
-                               FActiveContent := nil;
-                       if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
-                               j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser);
-                               if j <> -1 then
-                                       FBrowsers.Move(j, BROWSER_COUNT - 1);
-                       end;
-                       BrowserTab.Tabs.BeginUpdate;
-                       try
-                               TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
-                               if ( BrowserTab.Tabs.Count - 1 = i ) and
-                                       ( BrowserTab.TabRect(i).Left
-                                               <= BrowserTab.DisplayRect.Left ) then begin
-                                       BrowserTab.ScrollTabs(-1);
-                               end;
-                               BrowserTab.Tabs.Delete(i);
-                               if idx > i then begin
-                                       BrowserTab.TabIndex := idx - 1;
-                               end else begin
-                                       if BrowserTab.Tabs.Count -1 >= idx then
-                                               BrowserTab.TabIndex := idx
-                                       else
-                                               BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
-                               end;
-                       finally
-                               BrowserTab.Tabs.EndUpdate;
-                       end;
-                       if(BrowserTab.TabIndex <> -1) and
-                               ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
-                               for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
-                                       if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
-                                                = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
-                                       begin
-                                               ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
-                                               break;
-                                       end;
-                               end;
-                               TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
-                                        :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
-                               TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
-                               FBrowsers.Move(BROWSER_COUNT - 1, 0);
-                       end;
-
-                       if( FActiveContent = nil) then
-                               BrowserTab.OnChange(nil);
-                       Exit;
+            DeleteTab(i, BrowserTab.TabIndex);
+                       Break;
                end;
        end;
 end;
+procedure TGikoForm.DeleteTab(index, selectIndex: Integer);
+var
+    browserRec : TBrowserRecord;
+    doc: OleVariant;
+    j: Integer;
+begin
+    browserRec := TBrowserRecord(BrowserTab.Tabs.Objects[index]);
+    try
+        if browserRec.Browser <> nil then begin
+            doc := browserRec.Browser.OleObject.Document;
+            browserRec.Thread.ScrollTop := doc.Body.ScrollTop;
+        end;
+    except
+        browserRec.Thread.ScrollTop := 0;
+    end;
+
+    if(FActiveContent = browserRec) then
+        FActiveContent := nil;
+    if browserRec.Browser <> nil then begin
+        j := FBrowsers.IndexOf(browserRec.Browser);
+        if j <> -1 then
+            FBrowsers.Move(j, BROWSER_COUNT - 1);
+    end;
+
+    BrowserTab.Tabs.BeginUpdate;
+    try
+        GikoSys.Setting.LastCloseTabURL := browserRec.Thread.URL;
+        browserRec.Free;
+        if ( BrowserTab.Tabs.Count - 1 = index ) and
+            ( BrowserTab.TabRect(index).Left
+                <= BrowserTab.DisplayRect.Left ) then begin
+            BrowserTab.ScrollTabs(-1);
+        end;
+        BrowserTab.Tabs.Delete(index);
+        if selectIndex > index then begin
+            BrowserTab.TabIndex := selectIndex - 1;
+        end else begin
+            if BrowserTab.Tabs.Count -1 >= selectIndex then
+                BrowserTab.TabIndex := selectIndex
+            else
+                BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
+        end;
+    finally
+        BrowserTab.Tabs.EndUpdate;
+    end;
+    if BrowserTab.Tabs.Count = 0 then begin
+        BrowserNullTab.Thread := nil;
+    end;
+
+    if(BrowserTab.TabIndex <> -1) and
+        ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
+        // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
+        ReleaseOldestBrowser;
+
+        TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
+             :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
+        TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
+        FBrowsers.Move(BROWSER_COUNT - 1, 0);
+    end;
+
+    if( FActiveContent = nil) then
+        BrowserTab.OnChange(nil);
+end;
 function TGikoForm.Hook(var Message: TMessage): Boolean;
 begin
        //\83T\83u\83t\83H\81[\83\80\82ª\83\81\83C\83\93\83\81\83j\83\85\81[\82ð\8e\9d\82½\82È\82¢\82Æ\82«\82É\81A\83\81\83C\83\93\83t\83H\81[\83\80\82Ì
@@ -3754,24 +3758,28 @@ begin
 end;
 
 procedure TGikoForm.ListPopupMenuPopup(Sender: TObject);
-begin
-       ItemRoundPMenu.Visible := (GetActiveList is TBoard);
-       ItemReservPMenu.Visible := (GetActiveList is TBoard);
-       LPMSep01.Visible := (GetActiveList is TBoard);
-       ListRoundPMenu.Visible := (GetActiveList is TCategory);// or (GetActiveList is TBoard);
-       ListReservPMenu.Visible := (GetActiveList is TCategory);// or (GetActiveList is TBoard);
-       LPMSep02.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
-       KidokuPMenu.Visible := (GetActiveList is TBoard);
-       MidokuPMenu.Visible := (GetActiveList is TBoard);
-       UrlCopyPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
-       NameUrlCopyPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
-       AllSelectPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
-       LPMSep05.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
-       DeletePMenu.Visible := (GetActiveList is TBoard);
-       LPMSep06.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
-       BoardFavoriteAddMenu.Visible := (GetActiveList is TCategory);
-       ThreadFavoriteAddMenu.Visible := (GetActiveList is TBoard);
-
+var
+    bBoard, bCategory : Boolean;
+begin
+    bBoard := (GetActiveList is TBoard);
+    bCategory := (GetActiveList is TCategory);
+       ItemRoundPMenu.Visible := bBoard;
+       ItemReservPMenu.Visible := bBoard;
+       LPMSep01.Visible := bBoard;
+       ListRoundPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
+       ListReservPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
+       LPMSep02.Visible := bCategory or bBoard;
+       KidokuPMenu.Visible := bBoard;
+       MidokuPMenu.Visible := bBoard;
+       UrlCopyPMenu.Visible := bCategory or bBoard;
+       NameUrlCopyPMenu.Visible := bCategory or bBoard;
+       AllSelectPMenu.Visible := bCategory or bBoard;
+       LPMSep05.Visible := bCategory or bBoard;
+       DeletePMenu.Visible := bBoard;
+       LPMSep06.Visible := bCategory or bBoard;
+       BoardFavoriteAddMenu.Visible := bCategory;
+       ThreadFavoriteAddMenu.Visible := bBoard;
+    SaveThreadFile.Visible := bBoard;
        AddRoundNameMenu(ItemReservPMenu);
        AddRoundNameMenu(ListReservPMenu);
 end;
@@ -3873,72 +3881,102 @@ var
        wkIntTo: Integer;
     BNum, BRes: string;
     threadItem: TThreadItem;
+    aElement : IHTMLElement;
+    senderBrowser : TWebBrowser;
+    doc : IHTMLDocument2;
 begin
-
+{$IFDEF DEBUG}
+       Writeln(IntToStr(Integer(ppDisp)));
+{$ENDIF}
        Cancel := True;
-       if (IHTMLDocument2(TWebBrowser(Sender).Document).activeElement <> nil) then begin
-               Text := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerText;
-               Html := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerHTML;
-               if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
-                       or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
-                       if GikoSys.Setting.ResAnchorJamp then begin
-                               Text := ZenToHan(Trim(Text));
-
-                               if(AnsiPos('>>', Text) = 1) then begin
-                                       //Text := Copy(Text, 3, Length(Text) - 2);
-                                       Delete(Text, 1, 2);
-                               end else begin
-                                       //Text := Copy(Text, 2, Length(Text) - 1);
-                                       Delete(Text, 1, 1);
-                               end;
 
-                               if AnsiPos('-', Text) <> 0 then begin
-                                       wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
-                                       Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
-                                       wkIntTo := StrToIntDef(Text, 0);
-                                       if wkIntTo < wkIntSt then
-                                               wkIntSt := wkIntTo;
-                               end else begin
-                                       wkIntSt := StrToIntDef(Text, 0);
-                               end;
+       if not( TObject(Sender) is TWebBrowser )then
+               Exit;
 
-                               if wkIntSt <> 0 then begin
-                                       FActiveContent.IDAnchorPopup('');
-                                       BrowserMovement(IntToStr(wkIntSt));
-                               end;
+    senderBrowser := TWebBrowser(Sender);
+    doc := senderBrowser.ControlInterface.Document as IHTMLDocument2;
+       if not Assigned(doc) then
+               Exit;
+
+       aElement := doc.activeElement;
+       if not Assigned(aElement) then
+               Exit;
+
+       Text := aElement.Get_outerText;
+       Html := aElement.Get_outerHTML;
 
+       if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
+               or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
+               if GikoSys.Setting.ResAnchorJamp then begin
 
+                       Text := ZenToHan(Trim(Text));
+
+                       if(AnsiPos('>>', Text) = 1) then begin
+                               //Text := Copy(Text, 3, Length(Text) - 2);
+                               Delete(Text, 1, 2);
+                       end else begin
+                               //Text := Copy(Text, 2, Length(Text) - 1);
+                               Delete(Text, 1, 1);
                        end;
-               end else begin
-            ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
-
-                       URL := GikoSys.GetHRefText(Html);
-                       URL := GikoSys.HTMLDecode(URL);
-            if AnsiPos('BE:', URL) = 1 then begin
-                               BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
-                               BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
-                threadItem := FActiveContent.Thread;
-                if threadItem = nil then Exit;
-                URL := BE_PHP_URL + BNum + '&u=d'
-                       + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
+
+                       if AnsiPos('-', Text) <> 0 then begin
+                               wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
+                               Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
+                               wkIntTo := StrToIntDef(Text, 0);
+                               if wkIntTo < wkIntSt then
+                                       wkIntSt := wkIntTo;
+                       end else begin
+                               wkIntSt := StrToIntDef(Text, 0);
+                       end;
+
+                       if wkIntSt <> 0 then begin
+               FActiveContent.IDAnchorPopup('');
+                MoveHisotryManager.pushItem(FActiveContent);
+                if (Sender is TResPopupBrowser) then begin
+                    TResPopupBrowser(Sender).ChildClear;
+                    OpenThreadItem(
+                        GetActiveContent(true),
+                        GetActiveContent(true).URL + '&st=' +
+                             IntToStr(wkIntSt) + '&to=' + IntToStr(wkIntSt));
+                end else begin
+                                       BrowserMovement(IntToStr(wkIntSt));
+                end;
             end;
+               end;
+       end else begin
+        ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
+
+               URL := GikoSys.GetHRefText(Html);
+               URL := GikoSys.HTMLDecode(URL);
+        if AnsiPos('BE:', URL) = 1 then begin
+                       BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
+                       BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
+            threadItem := FActiveContent.Thread;
+            if threadItem = nil then Exit;
+            URL := BE_PHP_URL + BNum + '&u=d'
+               + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
+        end;
 
-                       if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
-                               ( AnsiPos('ftp://', URL) = 1) then begin
-                               //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
-                               if GikoSys.Setting.LinkAddAddressBar then begin
-                                       idx := AddressComboBox.Items.IndexOf(URL);
-                                       if idx = -1 then begin
-                                               AddressComboBox.Items.Insert(0, URL);
-                                               if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
-                                                       AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
-                                       end else begin
-                                               AddressComboBox.Items.Delete(idx);
-                                               AddressComboBox.Items.Insert(0, URL);
-                                       end;
+               if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
+                       ( AnsiPos('ftp://', URL) = 1) then begin
+                       //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
+                       if GikoSys.Setting.LinkAddAddressBar then begin
+                               idx := AddressComboBox.Items.IndexOf(URL);
+                               if idx = -1 then begin
+                                       AddressComboBox.Items.Insert(0, URL);
+                                       if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
+                                               AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
+                               end else begin
+                                       AddressComboBox.Items.Delete(idx);
+                                       AddressComboBox.Items.Insert(0, URL);
                                end;
-                               MoveToURL( URL );
                        end;
+            if (Sender is TResPopupBrowser) then begin
+                TResPopupBrowser(Sender).ChildClear
+            end;
+
+            MoveHisotryManager.pushItem(FActiveContent);
+                       MoveToURL( URL );
                end;
        end;
 
@@ -3994,7 +4032,7 @@ end;
 
 procedure TGikoForm.BrowserTabChange(Sender: TObject);
 var
-       i, j: Integer;
+       j: Integer;
        idx: Integer;
 begin
        BrowserTab.Tabs.BeginUpdate;
@@ -4017,12 +4055,9 @@ begin
                                                (FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
                                                FBrowsers.Move(BROWSER_COUNT - 1, 0);
 
-                                       for i := 0 to BrowserTab.Tabs.Count - 1 do begin
-                                               if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
-                                                       ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
-                                                       break;
-                                               end;
-                                       end;
+                    // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
+                    ReleaseOldestBrowser;
+
                                        TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
                                        TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Repaint := true;
                                        FBrowsers.Move(BROWSER_COUNT - 1, 0);
@@ -4135,6 +4170,7 @@ procedure TGikoForm.BrowserTabDragDrop(Sender, Source: TObject; X,
 var
        idx: Integer;
 begin
+    FDragWFirst := False;
        idx := BrowserTab.IndexOfTabAt(X, Y);
        if idx <> -1 then
                BrowserTab.Tabs.Move(BrowserTab.TabIndex, idx);
@@ -4149,14 +4185,11 @@ begin
 
        TabIdx := BrowserTab.IndexOfTabAt(x, y);
 
-       if ( ssLeft in Shift ) and ( BrowserTab.Style = tsTabs ) then begin
-               if FDragWFirst = false then begin
-                       FDragWFirst := true;
-               end else begin
+       if ( ssLeft in Shift ) then begin
+        if (FDragWFirst) then begin
                        BrowserTab.EndDrag(false);
                        BrowserTab.BeginDrag(false, DandD_THRESHOLD);
-                       FDragWFirst := false;
-               end;
+        end;
        end else begin
                BrowserTab.EndDrag(false);
                FDragWFirst := false;
@@ -4180,13 +4213,11 @@ end;
 procedure TGikoForm.BrowserDocumentComplete(Sender: TObject;
        const pDisp: IDispatch; var URL: OleVariant);
 var
-       FDispHtmlDocument: DispHTMLDocument;
        BrowserRecord :TBrowserRecord;
        i :Integer;
-       doc                                     : Variant;
+       doc     : IHTMLDocument2;
        threadItem      : TThreadItem;
 begin
-//     AddMessageList('DocumentComplete', nil, gmiWhat);
        if TObject(Sender) is TWebBrowser then begin
                BrowserRecord := nil;
                if TWebBrowser(Sender) <> Browser then begin
@@ -4199,17 +4230,15 @@ begin
                        if BrowserRecord <> nil then begin
                                if BrowserRecord.Event <> nil then
                                        BrowserRecord.Event.Free;
-                               FDispHtmlDocument := Idispatch(OleVariant(BrowserRecord.Browser.ControlInterface).Document) as DispHTMLDocument;
-                               BrowserRecord.Event := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
+                               BrowserRecord.Event := THTMLDocumentEventSink.Create(Self, BrowserRecord.Browser.ControlInterface.Document, HTMLDocumentEvents2);
                                BrowserRecord.Event.OnContextMenu := OnDocumentContextMenu;
                                BrowserRecord.Event.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
                        end;
                end else begin
                        if GetActiveContent <> nil then begin
-                               FDispHtmlDocument := Idispatch(OleVariant(Browser.ControlInterface).Document) as DispHTMLDocument;
                                if FEvent <> nil then
                                        FEvent.Free;
-                               FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
+                               FEvent := THTMLDocumentEventSink.Create(Self, Browser.ControlInterface.Document, HTMLDocumentEvents2);
                                FEvent.OnContextMenu := OnDocumentContextMenu;
                                FEvent.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
                        end else begin
@@ -4218,23 +4247,24 @@ begin
                                        FEvent := nil;
                                end;
                        end;
-                       
+
                end;
 
                if (BrowserRecord <> nil) and
                         Assigned( BrowserRecord.Thread ) then begin
                        threadItem := BrowserRecord.Thread;
 
-                       if (BrowserRecord <> nil) and (Length( BrowserRecord.Movement ) > 0) then begin
+                       if (threadItem.JumpAddress > 0) then begin
                                if threadItem.UnRead then begin
                                        threadItem.UnRead := False;
                                        TreeView.Refresh;
-                                       ListView.Refresh;
+                                       RefreshListView(threadItem);
                                end;
                                // \83X\83N\83\8d\81[\83\8b\90æ\82ª\8eæ\93¾\8aO\82Ì\83\8c\83X\82Ì\8e\9e\82Í\8fI\92[\82É\88Ú\93®
-                               if (StrToIntDef(BrowserRecord.Movement, 0) <= BrowserRecord.Thread.Count) then begin
-                                       BrowserRecord.Move(BrowserRecord.Movement);
-                                       BrowserRecord.Movement := '';
+                               //if (StrToIntDef(BrowserRecord.Movement, 0) <= BrowserRecord.Thread.Count) then begin
+                               if (threadItem.JumpAddress <= BrowserRecord.Thread.Count) then begin
+                                       BrowserRecord.Move(IntToStr(threadItem.JumpAddress));
+                                       threadItem.JumpAddress := 0;
                                end else begin
                                        BrowserRecord.Move(IntToStr(BrowserRecord.Thread.Count));
                                end;
@@ -4243,11 +4273,11 @@ begin
                                threadItem.UnRead := False;
                                TreeView.Refresh;
                                BrowserRecord.Move('new');
-                               ListView.Refresh;
+                               RefreshListView(threadItem);
                        end else if threadItem.ScrollTop <> 0 then begin
                                try
-                                       doc := Idispatch( OleVariant( BrowserRecord.Browser.ControlInterface ).Document ) as IHTMLDocument2;
-                                       doc.Body.ScrollTop := threadItem.ScrollTop;
+                                       doc := BrowserRecord.Browser.ControlInterface.Document as IHTMLDocument2;
+                                       (doc.body as IHTMLElement2).ScrollTop := threadItem.ScrollTop;
                                except
                                        on E: Exception do
                                                MsgBox(Handle, E.Message, 'SetContent[ScrollTop<-]', 0);
@@ -4255,6 +4285,7 @@ begin
                        end;
                end;
        end;
+       LockWindowUpdate(0);
 end;
 
 procedure TGikoForm.RoundNamePopupMenuPopup(Sender: TObject);
@@ -4380,7 +4411,6 @@ begin
        MenuToolBar.Buttons[0].AutoSize := True;
        MainCoolBar.AutoSize := False;
        MainCoolBar.AutoSize := True;
-
        GikoSys.MenuFont(ListCoolBar.Font);
        GikoSys.MenuFont(BrowserCoolBar.Font);
 //     MenuToolBar.Font.Color := clMenuText;
@@ -4439,6 +4469,9 @@ begin
 end;
 
 procedure TGikoForm.ShowFavoriteAddDialog( Item : TObject );
+const
+       MsgAdd : String = '\8aù\82É\82¨\8bC\82É\93ü\82è\82É\93o\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B\82»\82ê\82Å\82à\92Ç\89Á\82µ\82Ü\82·\82©\81H';
+       TitleAdd: String =  '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á';
 var
        Dlg                     : TFavoriteAddDialog;
        ItemURL : string;
@@ -4458,7 +4491,7 @@ begin
                        Data := Node.Data;
                        if TObject( Data ) is TFavoriteBoardItem then begin
                                if ItemURL = TFavoriteBoardItem( Data ).URL then begin
-                                       if Application.MessageBox( '\8aù\82É\82¨\8bC\82É\93ü\82è\82É\93o\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B\82»\82ê\82Å\82à\92Ç\89Á\82µ\82Ü\82·\82©\81H', '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á', MB_YESNO ) = IDNO then
+                                       if Application.MessageBox(PChar(MsgAdd) , PChar(TitleAdd), MB_YESNO ) = IDNO then
                                                Exit;
                                        Break;
                                end;
@@ -4478,7 +4511,7 @@ begin
                        Data := Node.Data;
                        if TObject( Data ) is TFavoriteThreadItem then begin
                                if ItemURL = TFavoriteThreadItem( Data ).URL then begin
-                                       if Application.MessageBox( '\8aù\82É\82¨\8bC\82É\93ü\82è\82É\93o\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B\82»\82ê\82Å\82à\92Ç\89Á\82µ\82Ü\82·\82©\81H', '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á', MB_YESNO ) = IDNO then
+                                       if Application.MessageBox( PChar(MsgAdd), PChar(TitleAdd), MB_YESNO ) = IDNO then
                                                Exit;
                                        Break;
                                end;
@@ -4563,6 +4596,48 @@ begin
        TopPanel.Height := Max(MainCoolBar.Height, AnimePanel.Height);
 
 end;
+//! \8ew\92è\82³\82ê\82½\83X\83\8c\83b\83h\82ð\8aJ\82­(\83\8d\83O\82ª\96³\82¢\82Æ\82« or \8ew\92èJUMP\82Ü\82Å\91«\82è\82È\82¢\82Æ\82«\82ÍDL\82·\82é)
+procedure TGikoForm.OpenThreadItem(Thread: TThreadItem; URL: String);
+var
+       stRes, edRes : Int64;
+       browserRec : TBrowserRecord;
+       threadNumber : String;
+       doc : IHTMLDocument2;
+begin
+       stRes := 0;
+       edRes := 0;
+       Thread.JumpAddress := 0;
+       // \83^\83u\82ð\90\90¬
+       browserRec := InsertBrowserTab(Thread);
+       if (browserRec <> nil) then begin
+               // JUMP\82·\82×\82«\83\8c\83X\94Ô\8d\86\82ª\82 \82é\82©\83`\83F\83b\83N\82·\82é
+               threadNumber := ChangeFileExt(Thread.FileName, '');
+               GikoSys.GetPopupResNumber( URL, stRes, edRes );
+               // \83X\83\8c\82Ì\94Ô\8d\86\82ð\83\8c\83X\94Ô\82Æ\8cë\82Á\82Ä\94F\8e¯\82µ\82Ä\82¢\82é\82Ì\82ð\83N\83\8a\83A
+               if (StrToInt64(threadNumber) = stRes) then begin
+                       if not (AnsiEndsText(threadNumber + '/' + threadNumber, URL))
+                               and (Pos('&st=' + threadNumber , URL) = 0) then begin
+                               stRes := 0;
+                       end;
+               end;
+               if ( stRes > 0 ) then begin
+                       Thread.JumpAddress := stRes;
+               end;
+               // \83\8d\83O\82ð\8e\9d\82Á\82Ä\82¢\82È\82¢\82© JUMP\82·\82×\82«\83\8c\83X\94Ô\8d\86\82Ü\82Å\8eæ\93¾\82µ\82Ä\82¢\82È\82¢\82Æ\82«\82ÍDL\82·\82é
+               if (not Thread.IsLogFile) or (stRes > Thread.Count) then begin
+                       DownloadContent(Thread);
+               end else if (not browserRec.Repaint) and (stRes > 0) then begin
+                       browserRec.Move(IntToStr(stRes));
+                       Thread.JumpAddress := 0;
+                       try
+                doc := browserRec.Browser.ControlInterface.Document as IHTMLDocument2;
+                if Assigned(doc) then
+                               Thread.ScrollTop := (doc.body as IHTMLElement2).ScrollTop;
+                       except
+                       end;
+               end;
+       end;
+end;
 
 procedure TGikoForm.MoveToURL(const inURL: string);
 var
@@ -4575,13 +4650,8 @@ var
        i, bi                                   : Integer;
        boardURL                        : string;
        tmpThread                       : TThreadItem;
-//     category                        : TCategory;
-//     categoryNode    : TTreeNode;
-//     boardNode                       : TTreeNode;
        shiftDown                       : Boolean;
        ctrlDown                        : Boolean;
-       stRes, edRes    : Int64;
-       browserRec              : TBrowserRecord;
 begin
 
        GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
@@ -4637,36 +4707,11 @@ begin
                                                                        if TBoard(ActiveList) = Board then
                                                                                ListView.Items.Count := ListView.Items.Count + 1;
                                                                end;
-                                                               GikoSys.GetPopupResNumber( inURL, stRes, edRes );
-                                                               browserRec := InsertBrowserTab( ThreadItem );
-                                                               if (browserRec <> nil) and (stRes > 0) then
-                                                                       browserRec.Movement := IntToStr( stRes );
-                                                               DownloadContent( ThreadItem );
-                                                               Exit;
                                                        end else begin
                                                                tmpThread.Free;
-                                                               GikoSys.GetPopupResNumber( inURL, stRes, edRes );
-                                                               browserRec := InsertBrowserTab( ThreadItem );
-                                                               if ThreadItem.IsLogFile then begin
-                                                                       if (browserRec <> nil) and (stRes > 0) then begin
-                                                                               browserRec.Movement := IntToStr( stRes );
-                                                                               if (stRes > ThreadItem.Count) then begin
-                                                                                       DownloadContent( ThreadItem );
-                                                                               end else begin
-                                                                                       try
-                                                                                               browserRec.Move(browserRec.Movement);
-                                                                                       except
-                                                                                       end;
-                                                                                       browserRec.Movement := '';
-                                                                               end;
-                                                                       end;
-                                                               end else begin
-                                                                       if (browserRec <> nil) and (stRes > 0) then
-                                                                               browserRec.Movement := IntToStr( stRes );
-                                                                       DownloadContent( ThreadItem );
-                                                               end;
-                                                               Exit;
                                                        end;
+                                                       OpenThreadItem(ThreadItem, inURL);
+                                                       Exit;
                                                end;
                                        end;
 
@@ -4693,15 +4738,6 @@ begin
        if (Length( Trim(BBSKey) ) > 0) and (Length( Trim(BBSID) ) > 0) then begin
                boardURL := GikoSys.Get2chThreadURL2BoardURL( inURL );
                Board := BBSsFindBoardFromURL( boardURL );
-               //if Board = nil then
-               //      Board := BBSsFindBoardFromBBSID( BBSID );
-               { \82±\82Ì\95\94\95ª\82àBBS\82\93FindBoardFromURL\82É\8e\9d\82½\82¹\82½\81@20050523
-               if Board = nil then begin
-                       // \81¦\8dì\82Á\82Ä\82à\92Ç\89Á\82·\82é\82Æ\82±\82ë\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82­\95Û\97¯
-                       //\81@\89ß\8b\8e\83\8d\83O\91q\8cÉ\82©\82ç\81A\83_\83E\83\\82µ\82½\83X\83\8c\82ª\94­\8c©\82Å\82«\82È\82¢\82Ì\82Å\82±\82±\82Å\92T\82·\82æ\82¤\82É\82·\82é (2004/01/22)
-                       Board := BBSs[ 0 ].FindBBSID( BBSID );
-               end;
-               }
                if Board = nil then begin
                         // \93ü\82é\82×\82«\94Â\82ª\8c©\82Â\82©\82ç\82È\82©\82Á\82½\82Ì\82Å\81A\95\81\92Ê\82Ì\83u\83\89\83E\83U\82Å\8aJ\82­
                         GikoSys.OpenBrowser(inURL, gbtUserApp);
@@ -4726,61 +4762,26 @@ begin
                if ThreadItem = nil then begin
                        ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
                end;
-               if ThreadItem = nil then begin
-                       //shift -> \90Ý\92è\83u\83\89\83E\83U\81i\96³\82¯\82ê\82ÎIE\81j
-                       //ctrl  -> IE
-                       {shiftDown      := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
-                       ctrlDown        := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
-                       if shiftDown then
-                               GikoSys.OpenBrowser(URL1, gbtUserApp)
-                       else if ctrlDown then
-                               GikoSys.OpenBrowser(URL1, gbtIE)
-                       else begin
-                       }
-                       ThreadItem := TThreadItem.Create( nil, Board, URL );
-                       ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
-                       if AnsiPos(Host, Board.URL) = 0 then
-                               ThreadItem.DownloadHost := Host
-                       else
-                               ThreadItem.DownloadHost := '';
-                       Board.Insert(0, ThreadItem);
-                       if ActiveList is TBoard then begin
-                               if TBoard(ActiveList) = Board then
-                                       ListView.Items.Count := ListView.Items.Count + 1;
-                       end;
-                       GikoSys.GetPopupResNumber( inURL, stRes, edRes );
-                       browserRec := InsertBrowserTab(ThreadItem);
-                       if (browserRec <> nil) and (stRes > 0) then
-                               browserRec.Movement := IntToStr( stRes );
-                       DownloadContent(ThreadItem);
-                       {end;}
-               end else begin
-                       if ThreadItem.IsLogFile then begin
-                               GikoSys.GetPopupResNumber( inURL, stRes, edRes );
-                               browserRec := InsertBrowserTab(ThreadItem);
-                               if (browserRec <> nil) and (stRes > 0) then begin
-                                       browserRec.Movement := IntToStr( stRes );
-                                       if (stRes > ThreadItem.Count) then begin
-                       DownloadContent(ThreadItem);
-                                       end else begin
-                                               try
-                                                       browserRec.Move(browserRec.Movement);
-                                               except
-                                               end;
-                                               browserRec.Movement := '';
-                                       end;
+               try
+                       // \83X\83\8c\83b\83h\83A\83C\83e\83\80\82ª\82È\82¢\82È\82ç\90\90¬\82·\82é\81B
+                       if ThreadItem = nil then begin
+                               ThreadItem := TThreadItem.Create( nil, Board, URL );
+                               ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
+                               Board.Insert(0, ThreadItem);
+                               if ActiveList is TBoard then begin
+                                       if TBoard(ActiveList) = Board then
+                                               ListView.Items.Count := ListView.Items.Count + 1;
                                end;
-                       end else begin
+                       end;
+                       // \83\8d\83O\82È\82µ\83X\83\8c\83b\83h\82Ì\82Æ\82«\82Í\81A\83z\83X\83g\96¼\82Ì\83`\83F\83b\83N\82ð\82·\82é
+                       if (not ThreadItem.IsLogFile) then begin
                                if AnsiPos(Host, Board.URL) = 0 then
                                        ThreadItem.DownloadHost := Host
                                else
                                        ThreadItem.DownloadHost := '';
-                               GikoSys.GetPopupResNumber( inURL, stRes, edRes );
-                               browserRec := InsertBrowserTab(ThreadItem);
-                               if (browserRec <> nil) and (stRes > 0) then
-                                       browserRec.Movement := IntToStr( stRes );
-                               DownloadContent(ThreadItem);
                        end;
+                       OpenThreadItem(ThreadItem, inURL);
+               except
                end;
        end else begin
                Board := BBSsFindBoardFromURL( inURL );
@@ -4790,7 +4791,7 @@ begin
                        if FActiveBBS <> Board.ParentCategory.ParenTBBS then
                                ShowBBSTree( Board.ParentCategory.ParenTBBS );
                        SelectTreeNode( Board, True );
-       end;
+               end;
        end;
 end;
 
@@ -4809,7 +4810,7 @@ end;
 
 procedure TGikoForm.BrowserEnter(Sender: TObject);
 begin
-       Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
+    Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
 end;
 
 procedure TGikoForm.WMCopyData(var Message: TWMCopyData);
@@ -4832,8 +4833,8 @@ end;
 
 procedure TGikoForm.WndProc(var Message: TMessage);
 var
-       senderBrowser   : TWebBrowser;
-       url                                             : OleVariant;
+       senderBrowser : TWebBrowser;
+       url : OleVariant;
 begin
        try
                case Message.Msg of
@@ -4841,14 +4842,21 @@ begin
                        if not (ssAlt in KeyDataToShiftState(TWMChar(Message).KeyData)) then
                                Exit;
                WM_SYSCOMMAND:
-                       if Message.WParam = SC_MINIMIZE then
+                       if Message.WParam = SC_MINIMIZE then begin
                                OnMinimize;
+                PostMessage(Handle, USER_MINIMIZED, 0, 0);
+            end;
                USER_TREECLICK:
                        TreeClick( TreeView.Selected );
                USER_RESIZED:
                        OnResized;
                USER_MINIMIZED:
-                       OnMinimized;
+            begin
+                if (GikoSys.Setting.StoredTaskTray) then begin
+                    StoredTaskTray;
+                end;
+                OnMinimized;
+            end;
                USER_SETLINKBAR:
                        SetLinkBar;
                USER_DOCUMENTCOMPLETE:
@@ -4857,6 +4865,13 @@ begin
                                senderBrowser := TWebBrowser( Message.WParam );
                                BrowserDocumentComplete( senderBrowser, senderBrowser.Parent, url );
                        end;
+        USER_RESPOPUPCLEAR:
+            if (TObject(Message.WParam) is TResPopupBrowser) then begin
+                try
+                               TResPopupBrowser( Message.WParam ).Clear;
+                except
+                end;
+                       end;
                end;
 
                inherited;
@@ -4912,141 +4927,51 @@ procedure TGikoForm.PreviewTimerTimer(Sender: TObject);
 var
        p: TPoint;
        ARect: TRect;
-       sl: TStringList;
-       html: string;
-       HtmlFileName: string;
-
-       NavURL: OleVariant;
-       Flags: OleVariant;
-       TargetFrameName: OleVariant;
-       PostData: OleVariant;
-       Headers: OleVariant;
-       WindowHeight: Integer;
-       WindowWidth: Integer;
-
-//     Style: Longint;
-       Referer: string;
-       Protocol, Host, Path, Document, Port, Bookmark: string;
 begin
        PreviewTimer.Enabled := False;
 
        GetCursorpos(p);
 
-       case GikoSys.Setting.PreviewSize of
-               gpsXSmall: begin
-                       WindowWidth := 128;
-                       WindowHeight := 96;
-               end;
-               gpsSmall: begin
-                       WindowWidth := 256;
-                       WindowHeight := 192;
-               end;
-               gpsLarge: begin
-                       WindowWidth := 512;
-                       WindowHeight := 384;
-               end;
-               gpsXLarge: begin
-                       WindowWidth := 640;
-                       WindowHeight := 480;
-               end;
-               else begin      //gpsMedium
-                       WindowWidth := 384;
-                       WindowHeight := 288;
-               end;
-       end;
-
-       ARect := Rect(0, 0, WindowWidth, WindowHeight);
-
-       case GikoSys.Setting.PopupPosition of
-               gppRightTop:            OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -     15);
-               gppRight:                       OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
-               gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
-               gppTop:                                 OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -  15);
-               gppCenter:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
-               gppBottom:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
-               gppLeftTop:                     OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -  15);
-               gppLeft:                                OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
-               gppLeftBottom:  OffsetRect(ARect, p.x + 15, p.y + 15);          //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g\82P\82Ì453\8e\81\82É\8a´\8eÓ
-       end;
-
-       html := '<html><head>'#13#10
-                               + '<SCRIPT>'#13#10
-                               + 'function init() {'#13#10
-                               + '     if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
-                               + '     } else {'#13#10
-                               + '             var dh, ih;'#13#10
-                               + '             dh = document.body.clientWidth / document.body.clientHeight;'#13#10
-                               + '             ih = Image1.width / Image1.height;'#13#10
-                               + '             if (document.body.clientWidth < document.body.clientHeight) {'#13#10
-                               + '                     if (ih > dh)'#13#10
-                               + '                             Image1.width = document.body.clientWidth;'#13#10
-                               + '                     else'#13#10
-                               + '                             Image1.height = document.body.clientHeight;'#13#10
-                               + '             } else {'#13#10
-                               + '                     if (ih < dh)'#13#10
-                               + '                             Image1.height = document.body.clientHeight;'#13#10
-                               + '                     else'#13#10
-                               + '                             Image1.width = document.body.clientWidth;'#13#10
-                               + '             }'#13#10
-                               + '     }'#13#10
-                               + '     Message.style.display = "none";'#13#10
-                               + '}'#13#10
-                               + '</SCRIPT>'#13#10
-                               + '</head>'#13#10
-                               + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
-                               + '<div align="center" id="Message">\83v\83\8c\83r\83\85\81[\8dì\90¬\92\86</div>'#13#10
-                               + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
-                               + '</body></html>';
-       sl := TStringList.Create;
-       try
-               try
-                       HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
-                       sl.Text := AnsiReplaceStr(html, '%ImageURL%', FPreviewURL);
-                       sl.SaveToFile(HtmlFileName);
-               finally
-                       sl.Free;
-               end;
-       except
-       end;
+    ARect := FPreviewBrowser.GetWindowRect(p);
+
+    FPreviewBrowser.PreviewImage(FPreviewURL);
+
+       if ARect.Bottom > Screen.DesktopHeight then begin
+        OffsetRect(ARect, 0, -(ARect.Bottom - Screen.DesktopHeight));
+    end;
+       if (ARect.Right > Screen.DesktopWidth) then begin
+        OffsetRect(ARect, -(ARect.Right - Screen.DesktopWidth), 0);
+    end;
+       if (ARect.Left < Screen.DesktopLeft) then begin
+        OffsetRect(ARect, +(Screen.DesktopLeft - ARect.Left), 0);
+    end;
+       if (ARect.Top < Screen.DesktopTop) then begin
+        OffsetRect(ARect, 0, (Screen.DesktopTop - ARect.Top));
+    end;
+
+       SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST,
+        ARect.Left, ARect.Top,
+        (ARect.Right - ARect.Left), (ARect.Bottom - ARect.Top),
+        SWP_NOACTIVATE or SWP_HIDEWINDOW);
 
-       NavURL := HtmlFileName;
-       Flags := 0;
-       TargetFrameName := '';
-       PostData := '';
-
-       GikoSys.ParseURI(FPreviewURL, Protocol, Host, Path, Document, Port, Bookmark);
-       Referer := Protocol + '://' + Host;
-       if Port <> '' then
-               Referer := Referer + ':' + Port;
-       Referer := Referer + Path;
-       Headers := 'Referer: ' + Referer;
-       FPreviewBrowser.Navigate(NavURL, Flags, TargetFrameName, PostData, Headers);
-       if ARect.Top + WindowHeight > Screen.DesktopHeight then
-               ARect.Top := Screen.DesktopHeight - WindowHeight;
-       if ARect.Left + WindowWidth > Screen.DesktopWidth then
-               ARect.Left := Screen.DesktopWidth - WindowWidth;
-       if ARect.Left < Screen.DesktopLeft then ARect.Left := Screen.DesktopLeft;
-       if ARect.Bottom < Screen.DesktopTop then ARect.Bottom := Screen.DesktopTop;
-
-       SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST, ARect.Left, ARect.Top, WindowWidth, WindowHeight, SWP_NOACTIVATE or SWP_HIDEWINDOW);
        ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);
        FPreviewBrowserRect := ARect;
-//     Style := GetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE);
-//     SetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE, Style xor WS_EX_APPWINDOW);
-
 end;
 
 procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
 var
        Pos : TPoint;
 begin
-
        if PreviewTimer.Enabled then
                PreviewTimer.Enabled := False;
-       if (FHint <> nil) and (IsWindowVisible(FHint.Handle)) then begin
-               FHint.ReleaseHandle;
-               FHint.ClearAllRes;
-       end;
+
+    //Window\8aO\82É\88Ú\93®\82µ\82½\82Æ\82«\82Í\8fÁ\82¦\82é\82æ\82¤\82É\82·\82é\82½\82ß\95\9c\8a\88
+    if (FResPopupBrowser <> nil) and (IsWindowVisible(FResPopupBrowser.Handle)) then begin
+        // \89E\83N\83\8a\83b\83N\82Ì\8e\9e\82Í\8fÁ\82³\82È\82¢\82æ\82¤\82É\8fð\8c\8f\92Ç\89Á
+        if (Message.MouseMsg <> WM_RBUTTONUP) then begin
+            FResPopupBrowser.Clear;
+        end;
+    end;
 
        if (FPreviewBrowser <> nil)
                and (IsWindowVisible(FPreviewBrowser.Handle)) then begin
@@ -5073,7 +4998,7 @@ end;
 
 function TGikoForm.OnDocumentContextMenu(Sender: TObject): WordBool;
 var
-       Doc: IHtmlDocument2;
+       doc: IHtmlDocument2;
        Range: IHTMLTxtRange;
        s: string;
        Num: Integer;
@@ -5081,66 +5006,31 @@ var
 begin
        Result := False;
        FactiveContent.IDAnchorPopup('');
-       Doc := FactiveContent.Browser.Document as IHtmlDocument2;
-       if Assigned(Doc) then begin
-               Range := Doc.selection.createRange as IHTMLTxtRange;
-               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
-
-                       ThreadItem := GetActiveContent;
-                       if ThreadItem <> nil then begin
-                               Num := StrToInt(s);
-                               FHint.PopupType := gptThread;
-                               HTMLCreater.SetResPopupText(FHint, ThreadItem, Num, Num, False, False);
-                               if FHint.ResCount <> 0 then
-                                       ShowTextPopup;
-                               Result := False;
-                       end else
-                               Result := True;
-               end else begin
-                       Result := True;
-               end;
-       end;
-end;
 
-procedure TGikoForm.ShowTextPopup;
-var
-       p: TPoint;
-       ARect: TRect;
-begin
-//     if Trim(s) = '' then
-//             Exit;
-       try
-               FHint.Font.Name := GikoSys.Setting.HintFontName;
-               FHint.Font.Size := GikoSys.Setting.HintFontSize;
-               FHint.Font.Color := GikoSys.Setting.HintFontColor;
-               FHint.Color := GikoSys.Setting.HintBackColor;
-               FHint.HeaderBold := GikoSys.Setting.ResPopupHeaderBold;
-               GetCursorpos(p);
-               if FHint.PopupType = gptRaw then
-                       ARect := FHint.CalcHintRect(Screen.Width, FHint.Caption, nil)
-               else
-                       ARect := FHint.CalcHintRect(Screen.Width, '', nil);
-               case GikoSys.Setting.PopupPosition of
-                       gppRightTop:            OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -     15);
-                       gppRight:                       OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
-                       gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
-                       gppTop:                                 OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -  15);
-                       gppCenter:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
-                       gppBottom:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
-                       gppLeftTop:                     OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -  15);
-                       gppLeft:                                OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
-                       gppLeftBottom:  OffsetRect(ARect, p.x + 15, p.y + 15);          //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g\82P\82Ì453\8e\81\82É\8a´\8eÓ
-               end;
-               //FHint.ActivateHint(ARect, s);
-               if FHint.PopupType = gptRaw then
-                       FHint.ActivateHint(ARect, FHint.Caption)
-               else
-                       FHint.ActivateHint(ARect, '');
-       except
-               FHint.ReleaseHandle;
-               FHint.ClearAllRes;
+       doc := FactiveContent.Browser.ControlInterface.Document as IHtmlDocument2;
+       if not Assigned(doc) then
+        Exit;
+
+       Range := doc.selection.createRange as IHTMLTxtRange;
+       if not Assigned(Range) then
+        Exit;
+
+       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 := StrToInt64Def(s, -1);
+               ThreadItem := GetActiveContent(true);
+               if (ThreadItem <> nil) and (Num <= ThreadItem.Count)
+           and (Num > 0)then begin
+           CreateResPopupBrowser;
+           FResPopupBrowser.CreateNewBrowser.PopupType := gptThread;
+                       HTMLCreater.SetResPopupText(FResPopupBrowser.CreateNewBrowser, ThreadItem, Num, Num, False, False);
+            FResPopupBrowser.Popup;
+               Result := False;
+               end else
+                       Result := True;
+    end else begin
+               Result := True;
        end;
 end;
 
@@ -5153,7 +5043,6 @@ begin
                if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then
                        if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then
                                Exit;
-               ClearHistory;
                FHistoryList.Clear;
                TreeView.Items.Clear;
        end;
@@ -5815,27 +5704,16 @@ end;
 
 procedure TGikoForm.SetSelectWord( const text : string );
 begin
+       // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
+       ClearThreadRengeAction;
 
        if Length( text ) = 0 then
        begin
                GikoDM.AllItemAction.Checked := True;
-               GikoDM.LogItemAction.Checked := False;
-               GikoDM.NewItemAction.Checked := False;
-       end else begin
-               // \83`\83\89\82Â\82­\82Æ\8c\99\82¾\82©\82ç\81A\88ê\89\9e\89\9f\82µ\82Ä\82 \82é\82Æ\82«\82¾\82¯\8f\88\97\9d\82·\82é
-               if GikoDM.AllItemAction.Checked then
-                       GikoDM.AllItemAction.Checked := False;
-               if GikoDM.LogItemAction.Checked then
-                       GikoDM.LogItemAction.Checked := False;
-               if GikoDM.NewItemAction.Checked then
-                       GikoDM.NewItemaction.Checked := False;
-       end;
-
-       if Length( text ) = 0 then
                SetListViewType( gvtAll )
-       else
+       end else begin
                SetListViewType( gvtUser, text, false );
-
+       end;
 end;
 
 procedure TGikoForm.SelectComboBoxChange(Sender: TObject);
@@ -5849,7 +5727,7 @@ procedure TGikoForm.SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
        Shift: TShiftState);
 var
   IMC: HIMC;
-  Len: integer;
+  Len, idx: integer;
   Str: string;
   tmp: string;
 begin
@@ -5871,8 +5749,24 @@ begin
                        end else
                                Str := SelectComboBox.Text + Str;
 
-                       SetSelectWord(Str);
+                       if (Length(Str) > 0) then begin
+                               SetSelectWord(Str);
+                       end;
                end;
+    end else if (Key = Windows.VK_DELETE) and (ssCtrl in Shift) then begin
+        // Ctrl + DEL \82Å\8dí\8f\9c\82·\82é
+        Str := SelectComboBox.Text;
+        idx := GikoSys.Setting.SelectTextList.IndexOf( Str );
+        if idx <> -1 then begin
+            GikoSys.Setting.SelectTextList.Delete( idx );
+        end;
+        idx := SelectComboBox.Items.IndexOf( Str );
+               if idx <> -1 then begin
+            SelectComboBox.Items.Delete( idx );
+        end;
+        SelectComboBox.Text := '';
+        // \8di\8d\9e\82Ý\82ð\89ð\8f\9c\82·\82é\82½\82ß\82É\95Ï\8dX\83C\83x\83\93\83g\82ð\8cÄ\82Ñ\8fo\82·
+        SelectComboBox.OnChange(Sender);
        end else if Length( SelectComboBox.Text ) = 0 then
        begin
                {* SelectComboBox.Text\82ª\8bó\82Å\82à\81A\93ü\97Í\93r\92\86\82ÅEsc\82µ\82½\82Æ\82©
@@ -5880,16 +5774,27 @@ begin
                 * \81i\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢\81j
                 *}
        end else begin
-               // \83`\83\89\82Â\82­\82Æ\8c\99\82¾\82©\82ç\81A\88ê\89\9e\89\9f\82µ\82Ä\82 \82é\82Æ\82«\82¾\82¯\8f\88\97\9d\82·\82é
-               if GikoDM.AllItemAction.Checked then
-                       GikoDM.AllItemAction.Checked := False;
-               if GikoDM.LogItemAction.Checked then
-                       GikoDM.LogItemAction.Checked := False;
-               if GikoDM.NewItemAction.Checked then
-                       GikoDM.NewItemaction.Checked := False;
+        // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
+               ClearThreadRengeAction;
        end;
 
 end;
+//! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
+procedure TGikoForm.ClearThreadRengeAction;
+begin
+       // \83`\83\89\82Â\82­\82Æ\8c\99\82¾\82©\82ç\81A\88ê\89\9e\89\9f\82µ\82Ä\82 \82é\82Æ\82«\82¾\82¯\8f\88\97\9d\82·\82é
+       if GikoDM.AllItemAction.Checked then
+               GikoDM.AllItemAction.Checked := False;
+       if GikoDM.LogItemAction.Checked then
+               GikoDM.LogItemAction.Checked := False;
+       if GikoDM.NewItemAction.Checked then
+               GikoDM.NewItemaction.Checked := False;
+       if GikoDM.LiveItemAction.Checked then
+               GikoDM.LiveItemAction.Checked := False;
+       if GikoDM.ArchiveItemAction.Checked then
+               GikoDM.ArchiveItemAction.Checked := False;
+
+end;
 
 procedure TGikoForm.SelectComboBoxExit(Sender: TObject);
 begin
@@ -6227,26 +6132,29 @@ begin
                FavoriteTreeNameURLCopyPopupMenu.Visible := False;
                FavoriteTreeReloadPopupMenu.Visible := False;
                FavoriteTreeLogDeletePopupMenu.Visible := False;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := False;
        end else if FClickNode.IsFirstNode then begin
                FavoriteTreeBrowseFolderPopupMenu.Visible := True;
                FavoriteTreeDeletePopupMenu.Visible := False;
                FavoriteTreeRenamePopupMenu.Visible := False;
                FavoriteTreeNewFolderPopupMenu.Visible := True;
                FavoriteTreeURLCopyPopupMenu.Visible := False;
-               FavoriteTreeNameCopyPopupMenu.Visible := True;
+               FavoriteTreeNameCopyPopupMenu.Visible := False;
                FavoriteTreeNameURLCopyPopupMenu.Visible := False;
                FavoriteTreeReloadPopupMenu.Visible := False;
                FavoriteTreeLogDeletePopupMenu.Visible := False;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := True;
        end else if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
                FavoriteTreeBrowseFolderPopupMenu.Visible := True;
                FavoriteTreeDeletePopupMenu.Visible := True;
                FavoriteTreeRenamePopupMenu.Visible := False;
                FavoriteTreeNewFolderPopupMenu.Visible := True;
                FavoriteTreeURLCopyPopupMenu.Visible := False;
-               FavoriteTreeNameCopyPopupMenu.Visible := True;
+               FavoriteTreeNameCopyPopupMenu.Visible := False;
                FavoriteTreeNameURLCopyPopupMenu.Visible := False;
                FavoriteTreeReloadPopupMenu.Visible := False;
                FavoriteTreeLogDeletePopupMenu.Visible := False;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := True;
        end else if TObject(FClickNode.Data) is TFavoriteFolder then begin
                FavoriteTreeBrowseFolderPopupMenu.Visible := True;
                FavoriteTreeDeletePopupMenu.Visible := True;
@@ -6257,6 +6165,7 @@ begin
                FavoriteTreeNameURLCopyPopupMenu.Visible := False;
                FavoriteTreeReloadPopupMenu.Visible := False;
                FavoriteTreeLogDeletePopupMenu.Visible := False;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := True;
        end else if TObject(FClickNode.Data) is TFavoriteThreadItem then begin
                FavoriteTreeBrowseFolderPopupMenu.Visible := False;
                FavoriteTreeDeletePopupMenu.Visible := True;
@@ -6267,6 +6176,7 @@ begin
                FavoriteTreeNameURLCopyPopupMenu.Visible := True;
                FavoriteTreeReloadPopupMenu.Visible := True;
                FavoriteTreeLogDeletePopupMenu.Visible := True;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := True;
        end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
                FavoriteTreeBrowseFolderPopupMenu.Visible := False;
                FavoriteTreeDeletePopupMenu.Visible := True;
@@ -6277,6 +6187,7 @@ begin
                FavoriteTreeNameURLCopyPopupMenu.Visible := True;
                FavoriteTreeReloadPopupMenu.Visible := True;
                FavoriteTreeLogDeletePopupMenu.Visible := False;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := True;
        end else begin
                FavoriteTreeBrowseFolderPopupMenu.Visible := False;
                FavoriteTreeDeletePopupMenu.Visible := False;
@@ -6287,6 +6198,7 @@ begin
                FavoriteTreeNameURLCopyPopupMenu.Visible := False;
                FavoriteTreeReloadPopupMenu.Visible := False;
                FavoriteTreeLogDeletePopupMenu.Visible := False;
+               FavoriteTreeItemNameCopyPopupMenu.Visible := False;
        end;
 
 end;
@@ -6355,24 +6267,21 @@ end;
 procedure TGikoForm.BrowserTabMouseUp(Sender: TObject;
        Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
 begin
-       if FDragWFirst <> true then begin
+       if FDragWFirst = true then
                FDragWFirst := false;
-{
-       end else if (abs( X - FMouseDownPos.X ) < Mouse.DragThreshold)
-       and (abs( Y - FMouseDownPos.Y ) < Mouse.DragThreshold) then begin
-(*}
-       end else 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;
+
+    // \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;
 
 procedure TGikoForm.LinkToolBarDragOver(Sender, Source: TObject; X,
@@ -6400,35 +6309,6 @@ begin
 
 end;
 
-procedure TGikoForm.ListCoolBarContextPopup(Sender: TObject;
-       MousePos: TPoint; var Handled: Boolean);
-begin
-
-       FToolBarSettingSender := tssList;
-       MousePos := ListCoolBar.ClientToScreen( MousePos );
-       MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
-
-end;
-
-procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
-       MousePos: TPoint; var Handled: Boolean);
-begin
-
-       FToolBarSettingSender := tssMain;
-       MousePos := MainCoolBar.ClientToScreen( MousePos );
-       MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
-
-end;
-
-procedure TGikoForm.BrowserCoolBarContextPopup(Sender: TObject;
-       MousePos: TPoint; var Handled: Boolean);
-begin
-
-       FToolBarSettingSender := tssBrowser;
-       MousePos := BrowserCoolBar.ClientToScreen( MousePos );
-       MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
-
-end;
 procedure TGikoForm.SetListViewBackGroundColor(value: TColor);
 begin
        if FListViewBackGroundColor <> value then begin
@@ -6485,7 +6365,7 @@ var
        boardPlugIn : TBoardPlugIn;
 begin
        if Number = 0 then Exit;
-       ThreadItem := GetActiveContent;
+       ThreadItem := GetActiveContent(True);
 
        if ThreadItem <> nil then begin
                //if ThreadItem.IsBoardPlugInAvailable then begin
@@ -6545,8 +6425,61 @@ end;
 procedure TGikoForm.BrowserTabPopupMenuPopup(Sender: TObject);
 begin
        AddRoundNameMenu(dummy1);
+    AddMenuSameBoardThread;
+end;
+//! \83A\83N\83e\83B\83u\82È\83^\83u\82Æ\93¯\82\94Â\82Ì\8aJ\82¢\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83\81\83j\83\85\81[\83A\83C\83e\83\80\82É\92Ç\89Á
+procedure TGikoForm.AddMenuSameBoardThread;
+var
+       i: Integer;
+       Item: TMenuItem;
+begin
+    SameBoardThreadItem.Clear;
+    for i := 0 to BrowserTab.Tabs.Count - 1 do begin
+        // \93¯\82\94Â\82©\82Ç\82¤\82©
+        if (FActiveContent.Thread.ParentBoard =
+            TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ParentBoard) then begin
+            // \8e©\95ª\82Í\8aO\82·
+            if FActiveContent.Thread <>
+                TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread then begin
+                Item := TMenuItem.Create(Self);
+                Item.Caption := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.Title;
+                Item.OnClick := SameBoardThreadSubItemOnClick;
+                SameBoardThreadItem.Add(Item);
+            end;
+        end;
+    end;
+    // \89½\82à\96³\82¢\82È\82ç\8eg\97p\82Å\82«\82È\82¢\82æ\82¤\82É\82·\82é
+    SameBoardThreadItem.Enabled := SameBoardThreadItem.Count > 0;
+end;
+//!  \83A\83N\83e\83B\83u\82È\83^\83u\82Æ\93¯\82\94Â\82Ì\8aJ\82¢\82Ä\82¢\82é\83X\83\8c\83b\83h\83N\83\8a\83b\83N\83C\83x\83\93\83g
+procedure TGikoForm.SameBoardThreadSubItemOnClick(Sender: TObject);
+var
+       i, j: Integer;
+       MenuItem: TMenuItem;
+begin
+       if Sender is TMenuItem then begin
+        try
+            j := 0;
+            MenuItem := TMenuItem(Sender);
+            for i := 0 to BrowserTab.Tabs.Count - 1 do begin
+                // \93¯\82\94Â\82©\82Ç\82¤\82©
+                if (FActiveContent.Thread.ParentBoard =
+                    TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ParentBoard) then begin
+                    if FActiveContent.Thread <>
+                        TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread then begin
+                        if (SameBoardThreadItem.Items[j] = MenuItem) then begin
+                            MoveToURL( TBrowserRecord(BrowserTab.Tabs.Objects[i])
+                                .Thread.URL);
+                            Exit;
+                        end;
+                        Inc(j);
+                    end;
+                end;
+            end;
+        except
+        end;
+       end;
 end;
-
 procedure TGikoForm.FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
 begin
        FavoriteDM.URLReplace(oldURLs, newURLs);
@@ -6618,10 +6551,15 @@ end;
 
 /// \8dÅ\8f¬\89»\82³\82ê\82é
 procedure TGikoForm.OnMinimize;
+var
+    doc: IHTMLDocument2;
 begin
        if FActiveContent <> nil then begin
                FIsMinimize := mtMinimizing;
-               FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
+        doc := FActiveContent.Browser.ControlInterface.Document as IHTMLDocument2;
+        if Assigned(doc) then begin
+               FActiveContent.Thread.ScrollTop := (doc.body as IHTMLElement2).ScrollTop;
+        end;
        end;
 end;
 
@@ -6693,6 +6631,7 @@ begin
                                Screen.Cursor := crDefault;
                        end;
                end;
+               Sort.SetSortDate(Now());
                SetActiveList(Node.data);
        end;
 
@@ -6749,7 +6688,10 @@ begin
                TreeDoubleClick( TreeView.Selected );
        end else if Key = VK_RETURN then begin
                TreeClick( TreeView.Selected );
-               TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
+        // \97\9a\97ð\82Ì\8fê\8d\87\81A\8fÁ\82³\82ê\82Ä\82¢\82é\82Ì\82Å\83`\83F\83b\83N\82·\82é
+        if (TreeView.Selected <> nil) then begin
+               TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
+        end;
        end;
 end;
 //! \82¨\8bC\82É\93ü\82è\82ÌMouseDown\83C\83x\83\93\83g
@@ -6767,7 +6709,8 @@ begin
                                (FavoriteTreeView.Selected = FavoriteTreeView.GetNodeAt(X, Y)) then begin
                                //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
                                rect := FavoriteTreeView.Selected.DisplayRect(true);
-                               if ((rect.Left <= X) and (rect.Right >= X)) and
+                               // \83A\83C\83R\83\93\95ª\8d\82É\82¸\82ç\82·
+                               if ((rect.Left - FavoriteTreeView.Indent <= X) and (rect.Right >= X)) and
                                        ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
                                        if ssDouble in Shift then begin
                                                FClickNode := FavoriteTreeView.Selected;
@@ -6812,9 +6755,8 @@ end;
 
 procedure TGikoForm.OnResized;
 var
-       doc                                             : Variant;
+       doc : IHTMLDocument2;
 begin
-
        FOldFormWidth := Width;
        FIsIgnoreResize := rtNone;
 
@@ -6829,8 +6771,8 @@ begin
                begin
                        // \8dÅ\8f¬\89»\82Í\8aù\82É\8a®\97¹\82µ\82Ä\82¢\82é (\82Â\82Ü\82è\83^\83X\83N\83o\81[\82©\82ç\83E\83B\83\93\83h\83E\82ð\95\9c\8c³\92\86)
                        if FActiveContent <> nil then begin
-                               doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
-                               doc.Body.ScrollTop := FActiveContent.Thread.ScrollTop;
+                               doc := FActiveContent.Browser.ControlInterface.Document as IHTMLDocument2;
+                               (doc.body as IHTMLElement2).ScrollTop := FActiveContent.Thread.ScrollTop;
                        end;
                        FIsMinimize := mtNone;
                end;
@@ -6838,70 +6780,97 @@ begin
 
 end;
 // *************************************************************************
-//! \82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83}\83E\83X\83A\83b\83v\83C\83x\83\93\83g
+//! \83X\83\8c\83b\83h\83u\83\89\83E\83U\83N\83\8a\83b\83N\83C\83x\83\93\83g
 // *************************************************************************
 function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
 var
-       p : TPoint;
        e: IHTMLElement;
+    doc : IHTMLDocument2;
+    FOleInPlaceActiveObject: IOleInPlaceActiveObject;
+       p : TPoint;
        AID: string;
        stlist : TStringList;
-       i, count, rc : Integer;
-       body : String;
-    limited : boolean;
-begin
-  result := true;
-  try
-       if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
-               FActiveContent.Browser.SetFocus;
-               try
-                       GetCursorPos(p);
-                       p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
-                       p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
-                       e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
-                       if (Assigned(e)) then begin
-                               if (e.className = 'date') or (e.id = 'date') then begin
-                                       AID := e.innerText;
-                                       if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
-                                               AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
-                       if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
-                               AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
-                        end;
-                                       end else begin
-                                               stlist := TStringList.Create;
-                                               try
-                                                       stList.DelimitedText := AID;
-                                                       AID := '';
-                                                       for i := 0 to stList.Count - 1 do
-                                                               if Length(WideString(stList[i])) = 8 then begin
-                                                                       if GikoSys.NotDateorTimeString(stList[i]) then begin
-                                                                               AID := stList[i];
-                                                                               break;
-                                                                       end;
-                                                               end;
-                                               finally
-                                                       stList.Free;
+    i : Integer;
+begin
+       result := true;
+    if not Assigned(FActiveContent) then
+        Exit;
+    if not Assigned(FActiveContent.Browser) then
+        Exit;
+
+       try
+               FOleInPlaceActiveObject := FActiveContent.Browser.ControlInterface as IOleInPlaceActiveObject;
+               FOleInPlaceActiveObject.OnFrameWindowActivate(True);
+               GetCursorPos(p);
+
+               p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
+               p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
+
+               doc := FActiveContent.Browser.ControlInterface.Document as IHTMLDocument2;
+               if not Assigned(doc) then
+                       Exit;
+
+               e := doc.elementFromPoint(p.x, p.y);
+               if not Assigned(e) then
+                       Exit;
+
+               if (e.className = 'date') or (e.id = 'date') then begin
+                       AID := e.innerText;
+                       if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
+                               AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
+                               if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
+                                       AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
+                               end;
+                       end else begin
+                               stlist := TStringList.Create;
+                               try
+                                       stList.DelimitedText := AID;
+                                       AID := '';
+                                       for i := 0 to stList.Count - 1 do begin
+                                               if Length(WideString(stList[i])) = 8 then begin
+                                                       if GikoSys.NotDateorTimeString(stList[i]) then begin
+                                                               AID := stList[i];
+                                                               break;
+                                                       end;
                                                end;
                                        end;
-                    count := GikoSys.GetSameIDResCount(AID, FActiveContent.Thread);
-                    limited := false;
-                    if count > 20 then begin
-                        rc := GikoUtil.MsgBox(Handle,
-                                '20\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
-                                'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
-                                                               MB_YESNO or MB_ICONQUESTION);
-                        limited := rc <> ID_YES;
-                    end;
-                                       body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
-                                       FActiveContent.IDAnchorPopup(body);
+                               finally
+                                       stList.Free;
                                end;
                        end;
-               except
+            ShowSameIDAncher(AID);
                end;
-  except
-  end;
+       except
+       end;
+end;
+procedure TGikoForm.ShowSameIDAncher(const AID: String);
+const
+    LIMIT = 20;
+var
+       numbers : TStringList;
+    limited : Integer;
+begin
+    numbers := TStringList.Create;
+    try
+
+        GikoSys.GetSameIDRes(AID, FActiveContent.Thread, numbers);
+        limited := LIMIT;
+        if not (GikoSys.Setting.LimitResCountMessage) then begin
+            limited := -1;
+        end else if (numbers.Count > LIMIT) then begin
+            if (GikoUtil.MsgBox(Handle,
+                    IntToStr(LIMIT) + '\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
+                    'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
+                    MB_YESNO or MB_ICONQUESTION) = ID_YES) then begin
+                limited := -1;
+            end
+        end;
+        FActiveContent.IDAnchorPopup(
+            GikoSys.CreateSameIDResAnchor(numbers, FActiveContent.Thread, limited));
+    finally
+        numbers.Free;
+    end;
 end;
-
 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
 begin
@@ -6913,106 +6882,6 @@ begin
                end;
 end;
 
-function TGikoForm.GetTabURLs(AStringList: TStringList) : Boolean;
-var
-  rec : TBrowserRecord;
-  i, bound : Integer;
-begin
-       bound := BrowserTab.Tabs.Count -1;
-       if bound = -1 then begin
-               Result := False;
-               Exit; //for\82É\94ò\82Î\82È\82¢\82Å\91\80\8dì\82ð\94²\82¯\82é
-       end;
-
-       for i := 0 to bound do begin
-               try
-                       rec := TBrowserRecord( BrowserTab.Tabs.Objects[ i ] );
-                       if( rec <> nil) and (rec.Thread <> nil) then
-                               AStringList.Add( rec.Thread.URL );
-               except
-               end;
-       end;
-       Result := True;
-end;
-
-function TGikoForm.SaveTabURLs : Boolean;
-const
-       Filename = 'tab.sav';
-       bFilename = '~tab.sav';
-var
-       SaveStringList: TStringList;
-begin
-       Result := false;
-
-       SaveStringList := TStringList.Create;
-       try
-               if GetTabURLs(SaveStringList) then begin
-                       try
-                               if FileExists( GikoSys.GetAppDir + Filename) then begin
-                                       if FileExists( GikoSys.GetAppDir + bFilename) then
-                                               DeleteFile(GikoSys.GetAppDir + bFilename);
-
-                                       //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
-                                       RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
-                               end;
-                       except
-                       end;
-                       SaveStringList.SaveToFile(GikoSys.GetAppDir + Filename);
-                       Result := true;
-               end;
-       finally
-               SaveStringList.Free;
-       end;
-end;
-
-function TGikoForm.LoadTabURLs : Boolean;
-const
-       TABFILE = 'tab.sav';
-var
-       i, bound    : Integer;
-       item        : TThreadItem;
-       URLs                            : TStringList;
-       GikoTab                 : TGikoTabAppend;
-       fileName                : string;
-begin
-
-       fileName := ExtractFilePath(Application.ExeName) + TABFILE;
-       URLs := TStringList.Create();
-       GikoTab := GikoSys.Setting.BrowserTabAppend;
-       try
-               try
-                       Result := True;
-                       if FileExists(fileName) then begin
-                               URLs.LoadFromFile(fileName);
-                               bound    := URLs.Count - 1;
-                               if bound > -1 then begin
-                                       GikoSys.Setting.BrowserTabAppend := gtpLast;//TGikoTabAppend(1);
-                                       for i := 0 to bound do begin
-                                               item := BBSsFindThreadFromURL( URLs[ i ] );
-                                               if item <> nil then
-                                                       InsertBrowserTab( item, false );
-                                       end;
-                                       //\8dÅ\8f\89\82Ì\82P\96\87\82É\90Ý\92è \83A\83h\83\8c\83X\82Ì\90Ý\92è\82Ì\82½\82ß\82Ì\83J\83\89\8cÄ\82Ñ
-                                       if BrowserTab.Tabs.Count > 0 then begin
-                       BrowserTab.OnChange(nil);
-                                       end;
-                               end else
-                                       Result := False;
-                       end else
-                               Result := False;
-               except
-                       on EFOpenError do begin
-                               ShowMessage('\83^\83u\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ');
-                       end;
-               end;
-       finally
-               GikoSys.Setting.BrowserTabAppend := GikoTab;
-               URLs.Free;
-       end;
-
-end;
-
-
 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
 procedure TGikoForm.ActiveListColumnSave;
 var
@@ -7224,6 +7093,7 @@ var
        Action: TAction;
 begin
        s := MouseGesture.GetGestureStr;
+    MouseGesture.Clear;
        Action := GikoSys.Setting.Gestures.GetGestureAction(s);
        if Action <> nil then
                Action.Execute;
@@ -7276,10 +7146,11 @@ end;
 
 procedure TGikoForm.BrowserPanelResize(Sender: TObject);
 begin
-       if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
-               MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
-       end;
-
+    if (FIsMinimize <> mtMinimizing) then begin
+       if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
+               MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
+       end;
+    end;
 end;
 procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
 var
@@ -7386,15 +7257,22 @@ end;
 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
 var
-       ThreadItem      : TThreadItem;
-       ReadList                : TStringList;
-       wordCount               : TWordCount;
-begin
-       ThreadItem      := GetActiveContent;
-       ReadList                := TStringList.Create;
-       wordCount               := TWordCount.Create;
+    doc : IHTMLDocument2;
+       ThreadItem : TThreadItem;
+       ReadList : TStringList;
+       wordCount : TWordCount;
+begin
+    if not Assigned(FActiveContent) then
+        Exit;
+    doc := FActiveContent.Browser.ControlInterface.Document as IHTMLDocument2;
+    if not Assigned(doc) then
+        Exit;
+
+       ThreadItem := GetActiveContent(True);
+       ReadList := TStringList.Create;
+       wordCount := TWordCount.Create;
        try
-               ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
+               ThreadItem.ScrollTop := (doc.body as IHTMLElement2).ScrollTop;
 {$IFDEF SPAM_FILTER_ENABLED}
                // \83X\83p\83\80\82É\90Ý\92è
                ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
@@ -7412,6 +7290,68 @@ begin
        if ThreadItem <> nil then
                InsertBrowserTab( ThreadItem, True );
 end;
+//\93¯\88êID\82ðNG\83\8f\81[\83h\82É\93o\98^
+procedure TGikoForm.AddIDtoNGWord(invisible : boolean);
+var
+    doc : IHTMLDocument2;
+       ThreadItem : TThreadItem;
+       No : Integer;
+{$IFDEF SPAM_FILTER_ENABLED}
+       body : TStringList;
+       ReadList                : TStringList;
+       wordCount               : TWordCount;
+{$ENDIF}
+    id, dateStr: String;
+begin
+       No := KokoPopupMenu.Tag;
+       if No = 0 then Exit;
+       ThreadItem := GetActiveContent(True);
+       if ThreadItem = nil then Exit;
+
+    id := GikoSys.GetResID(No, ThreadItem);
+    if (id <> '') and (not IsNoValidID(id)) then begin
+        // \83R\83\81\83\93\83g\82Æ\82µ\82Ä\81A\83X\83\8c\83b\83h\96¼\82Æ\8d¡\93ú\82Ì\93ú\95t\82ð\92Ç\89Á
+        DateTimeToString(dateStr, 'yyyymmdd', Now);
+        id := id + #9'>>add ' + dateStr + ',' + ThreadItem.Title;
+        if (GikoSys.FAbon.AddToken(id, invisible)) then begin
+            GikoSys.FAbon.ReLoadFromNGwordFile;
+            FActiveContent.Repaint := True;
+        end;
+    end else begin
+        ShowMessage('ID\82ð\8eæ\93¾\82Å\82«\82Ü\82¹\82ñ\82Å\82µ\82½\81B');
+    end;
+{$IFDEF SPAM_FILTER_ENABLED}
+    body := TStringList.Create;
+    try
+        GikoSys.GetSameIDRes(id, ThreadItem, body);
+        ReadList               := TStringList.Create;
+        wordCount              := TWordCount.Create;
+        try
+            // \83X\83p\83\80\82É\90Ý\92è
+            ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
+            for i := 0 to body.Count - 1 do begin
+                GikoSys.SpamCountWord( ReadList[ i ], wordCount );
+                GikoSys.SpamForget( wordCount, False );        // \83n\83\80\82ð\89ð\8f\9c
+                GikoSys.SpamLearn( wordCount, True );          // \83X\83p\83\80\82É\90Ý\92è
+            end;
+        finally
+            wordCount.Free;
+            ReadList.Free;
+        end;
+    finally
+        body.Free;
+    end;
+{$ENDIF}
+    if (FActiveContent.Repaint) then begin
+        doc := FActiveContent.Browser.ControlInterface.Document as IHTMLDocument2;
+
+        if not Assigned(doc) then
+            Exit;
+        ThreadItem.ScrollTop := (doc.body as IHTMLElement2).ScrollTop;
+        if ThreadItem <> nil then
+            InsertBrowserTab( ThreadItem, True );
+    end;
+end;
 
 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
 procedure TGikoForm.IndividualAbonID(Atype : Integer);
@@ -7424,7 +7364,7 @@ var
 begin
        No := KokoPopupMenu.Tag;
        if No = 0 then Exit;
-       ThreadItem := GetActiveContent;
+       ThreadItem := GetActiveContent(True);
        if ThreadItem = nil then Exit;
        body := TStringList.Create;
        try
@@ -7433,7 +7373,7 @@ begin
                ReadList                := TStringList.Create;
                wordCount               := TWordCount.Create;
                try
-                       ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
+                       ThreadItem.ScrollTop := FActiveContent.Browser.OleObject.Document.Body.ScrollTop;
 {$IFDEF SPAM_FILTER_ENABLED}
                        // \83X\83p\83\80\82É\90Ý\92è
                        ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
@@ -7463,15 +7403,17 @@ end;
 procedure TGikoForm.KokoPopupMenuPopup(Sender: TObject);
 var
        firstElement: IHTMLElement;
-       document: IHTMLDocument2;
+       doc: IHTMLDocument2;
 begin
-       document := FActiveContent.Browser.Document as IHTMLDocument2;
-       if Assigned(document) then
-               firstElement := document.all.item('idSearch', 0) as IHTMLElement;
-               if Assigned(firstElement) then
-                       if firstElement.style.visibility <> 'hidden' then
-                               firstElement.style.visibility := 'hidden';
-
+    try
+       doc := FActiveContent.Browser.ControlInterface.Document as IHTMLDocument2;
+           if Assigned(doc) then
+                   firstElement := doc.all.item('idSearch', 0) as IHTMLElement;
+               if Assigned(firstElement) then
+                       if firstElement.style.visibility <> 'hidden' then
+                               firstElement.style.visibility := 'hidden';
+    except
+    end;
 end;
 
 procedure TGikoForm.RepaintAllTabsBrowser();
@@ -7538,46 +7480,6 @@ begin
                Screen.Cursor := Cursor;
 end;
 // *************************************************************************
-//! \83X\83N\83\8a\81[\83\93\8fã\82ÉEditorForm\82ª\82¢\82é\82©
-// *************************************************************************
-function TGikoForm.EditorFormExists(): boolean;
-var
-       i : Integer;
-begin
-       Result := false;
-       //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\92T\82·
-       for i := 0 to Screen.CustomFormCount - 1 do begin
-               if TObject(Screen.CustomForms[i]) is TEditorForm then begin
-                       Result := true;
-                       Break;
-               end;
-       end;
-end;
-// *************************************************************************
-//! \83X\83N\83\8a\81[\83\93\8fã\82É\82¢\82é\82·\82×\82Ä\82ÌEditorForm\82©\82ç\96¼\91O\82Ì\97\9a\97ð\82ð\8dí\8f\9c\82·\82é
-// *************************************************************************
-procedure TGikoForm.AllEditroFormNameTextClearClear();
-var
-       i : Integer;
-begin
-       for i := 0 to Screen.CustomFormCount - 1 do begin
-               if TObject(Screen.CustomForms[i]) is TEditorForm then
-                       TEditorForm(Screen.CustomForms[i]).NameComboBox.Items.Clear;
-       end;
-end;
-// *************************************************************************
-//! \83X\83N\83\8a\81[\83\93\8fã\82É\82¢\82é\82·\82×\82Ä\82ÌEditorForm\82©\82ç\83\81\81[\83\8b\97\9a\97ð\82ð\8dí\8f\9c\82·\82é
-// *************************************************************************
-procedure TGikoForm.AllEditroFormMailTextClearClear();
-var
-       i : Integer;
-begin
-       for i := 0 to Screen.CustomFormCount - 1 do begin
-               if TObject(Screen.CustomForms[i]) is TEditorForm then
-                       TEditorForm(Screen.CustomForms[i]).MailComboBox.Items.Clear;
-       end;
-end;
-// *************************************************************************
 //! \83L\83\83\83r\83l\83b\83g\82ð\95Â\82\82é\81~\83{\83^\83\93\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
 // *************************************************************************
 procedure TGikoForm.CabinetCloseSpeedButtonClick(Sender: TObject);
@@ -7612,7 +7514,9 @@ begin
                        WM_KEYFIRST..WM_KEYLAST :
                        begin
                                //\83L\81[\83A\83b\83v\82Í\96³\8e\8b\82·\82é\81@KeyDown\82Æ\8d\87\82í\82¹\82Ä\82Q\89ñ\8cÄ\82Î\82ê\82é\82©\82ç
-                               if (Msg.message <> WM_KEYUP) and (Msg.message <> WM_CHAR) then begin
+                               if (Msg.message <> WM_KEYUP)
+                    and (Msg.message <> WM_CHAR)
+                    and (Msg.message <> WM_SYSKEYUP) then begin
                                        wmMsg.Msg := Msg.message;
                                        wmMsg.CharCode := Word(Msg.wParam);
                                        wmMsg.KeyData := Msg.lParam;
@@ -7621,7 +7525,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
@@ -7631,12 +7541,11 @@ begin
        Application.ProcessMessages;
        if not Application.Terminated then begin
                if PreviewTimer.Enabled then
-                       PreviewTimer.Enabled := False;
-               //\83t\83H\81[\83J\83X\82ª\91¼\82Ì\83A\83v\83\8a\82É\95Ï\82í\82Á\82½\82Æ\82«\82É\83q\83\93\83g\82ð\8fÁ\8b\8e
-               if FHint <> nil then begin
-                       FHint.ReleaseHandle;
-                       FHint.ClearAllRes;
-               end;
+               PreviewTimer.Enabled := False;
+               //\83t\83H\81[\83J\83X\82ª\91¼\82Ì\83A\83v\83\8a\82É\95Ï\82í\82Á\82½\82Æ\82«\82É\83|\83b\83v\83A\83b\83v\8fÁ\8b\8e
+        if (FResPopupBrowser <> nil) then
+            FResPopupBrowser.Clear;
+
                //\83v\83\8c\83r\83\85\81[\82ð\89B\82·
                if FPreviewBrowser <> nil then
                        ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
@@ -7685,7 +7594,9 @@ begin
        BrowserNullTab := TBrowserRecord.Create;
        BrowserNullTab.Browser := Browser;
        BrowserNullTab.Browser.Navigate(BLANK_HTML);
+
        FBrowsers := TList.Create;
+
        for i := 0 to count -1 do begin
                FBrowsers.Add(TWebBrowser.Create(BrowserPanel));
                newBrowser := FBrowsers[FBrowsers.Count - 1];
@@ -7693,6 +7604,7 @@ begin
                TOleControl(newBrowser).Align := alNone;
                TOleControl(newBrowser).Left    := 0;
                TOleControl(newBrowser).Top     := 0;
+               newBrowser.RegisterAsDropTarget := False;
                newBrowser.OnDocumentComplete   := BrowserDocumentComplete;
                newBrowser.OnBeforeNavigate2    := BrowserBeforeNavigate2;
                newBrowser.OnEnter                              := BrowserEnter;
@@ -7700,9 +7612,12 @@ begin
                newBrowser.OnStatusTextChange   := BrowserStatusTextChange;
                newBrowser.Navigate(BLANK_HTML);
                ShowWindow(newBrowser.Handle, SW_HIDE);
+        GikoSys.ShowRefCount('Browser' + IntToStr(i), newBrowser.ControlInterface);
+        GikoSys.ShowRefCount('Document' + IntToStr(i), newBrowser.ControlInterface.Document);
        end;
        BrowserNullTab.Browser.BringToFront;
        ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
+
        //\8bN\93®\8e\9e\82É\83^\83u\8e©\93®\95\9c\8c³\82ð\93ü\82ê\82Ä\82¢\82é\82Æ\81A\8bó\83y\81[\83W\97p\82ÌBrowser\82Ì
        //\95`\89æ\82ª\8fI\82í\82Á\82Ä\82¢\82È\82­\82Ä\81A\83N\83\8a\83b\83N\83C\83x\83\93\83g\82Ì\90Ý\92è\93\99\82É\93Ë\93ü\82·\82é\82Ì\82Å
        //\82±\82±\82Å\8fI\82í\82ç\82¹\82Ä\82¨\82­
@@ -7780,7 +7695,8 @@ begin
                                (TreeView.Selected = TreeView.GetNodeAt(X, Y)) then begin
                                //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
                                rect := TreeView.Selected.DisplayRect(true);
-                               if ((rect.Left <= X) and (rect.Right >= X)) and
+                               // \83A\83C\83R\83\93\95ª\82¾\82¯\8d\82É\82¸\82ç\82·
+                               if ((rect.Left - TreeView.Indent <= X) and (rect.Right >= X)) and
                                        ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
                                        // \83N\83\8a\83b\83N\82Æ\83_\83u\83\8b\83N\83\8a\83b\83N\82ð\83R\83R\82Å\94»\92è
                                        if ssDouble in Shift then begin
@@ -7832,10 +7748,224 @@ begin
                end;
        end;
 end;
+//! \82±\82Ì\83\8c\83X\82ÌURL\8eæ\93¾
+procedure TGikoForm.GetResURLMenuClick(Sender: TObject);
+begin
+;
+end;
+//! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
+procedure TGikoForm.RefreshListView(Thread: TThreadItem);
+begin
+       //Thread\82Ì\94Â\82Æ\95\\8e¦\82µ\82Ä\82¢\82é\94Â\82ª\93¯\82\82È\82ç\95`\89æ\82ð\8dX\90V\82·\82é
+       if (FActiveList is TBoard) and (TBoard(ActiveList) = Thread.ParentBoard) then begin
+               ListView.Refresh;
+       end;
+end;
+
+procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
+  MousePos: TPoint; var Handled: Boolean);
+var
+    pos : TPoint;
+    coolBar: TGikoCoolBar;
+begin
+    Handled := False;
+    if (Sender <> nil) and (Sender is TGikoCoolBar) then begin
+        coolBar := TGikoCoolBar(Sender);
+        if (coolBar = MainCoolBar) then begin
+            FToolBarSettingSender := tssMain;
+        end else if (coolBar = ListCoolBar) then begin
+            FToolBarSettingSender := tssList;
+        end else if (coolBar = BrowserCoolBar) then begin
+            FToolBarSettingSender := tssBrowser;
+        end else begin
+            FToolBarSettingSender := tssNone;
+        end;
+        pos := coolBar.ClientToScreen( MousePos );
+        MainCoolBarPopupMenu.Popup( pos.X, pos.Y );
+        Handled := True;
+    end;
+end;
+
+procedure TGikoForm.TaskTrayIconMessage(var Msg: TMsg);
+var
+    p: TPoint;
+begin
+    //  \8d\83N\83\8a\83b\83N\82È\82ç\95\9c\8c³\82·\82é
+    if  (Msg.wParam = WM_LBUTTONUP) then  begin
+        UnStoredTaskTray;
+    end else if (Msg.wParam=WM_RBUTTONUP) then begin
+        // \89E\83N\83\8a\83b\83N\82È\82ç\8fI\97¹\82·\82é
+        GetCursorPos ( p );
+        SetForegroundWindow ( Self.Handle );
+        TaskTrayPopupMenu.Popup ( p.X, p.Y );
+    end;
+end;
+//! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
+procedure TGikoForm.StoredTaskTray;
+begin
+    try
+        if (FIconData.uID = 0) then begin
+            FIconData.cbSize  :=  SizeOf(TNotifyIconData);
+            FIconData.uID     :=  Self.Handle;
+            FIconData.Wnd     :=  Handle;
+            FIconData.uFlags  :=  NIF_MESSAGE or NIF_ICON or NIF_TIP;
+            FIconData.uCallbackMessage  :=  USER_TASKTRAY;
+            FIconData.hIcon   :=  Application.Icon.Handle;  {\83A\83C\83R\83\93\8ew\92è}
+            FIconData.szTip   :=  '\83M\83R\83i\83r';      {\83q\83\93\83g\95\8e\9a\97ñ}
+            Shell_NotifyIcon(NIM_ADD, @FIconData);
+            ShowEditors(SW_HIDE);
+            ShowWindow(Self.Handle, SW_HIDE);
+        end;
+    except
+    end;
+end;
+//! \83^\83X\83N\83g\83\8c\83C\82Ì\83A\83C\83R\83\93\8dí\8f\9c\81\95\83t\83H\81[\83\80\95\\8e¦
+procedure TGikoForm.UnStoredTaskTray;
+begin
+    try
+        try
+            Shell_NotifyIcon(NIM_DELETE, @FIconData);
+            SetForegroundWindow(Application.Handle);
+        except
+        end;
+    finally
+        FIconData.uID := 0;
+        // Action\82©\82ç\8ai\94[\82µ\82½\82Æ\82«\82ÍTag\82Ì\92l\82Í0\88È\8aO
+        if (GikoDM.StoredTaskTrayAction.Tag = 0) then begin
+            ShowWindow(Self.Handle, SW_RESTORE);
+        end else begin
+            ShowWindow(Self.Handle, SW_SHOW);
+        end;
+        ShowEditors(SW_SHOW);
+        GikoDM.StoredTaskTrayAction.Tag := 0;
+    end;
+end;
+{
+\brief \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
+\param nCmdShow Windows.ShowWindow\82É\91\97\82é\83p\83\89\83\81\81[\83^\82Æ\93¯\82
+}
+procedure TGikoForm.ShowEditors(nCmdShow: Integer);
+var
+    i : Integer;
+begin
+    // \83\8c\83X\83G\83f\83B\83^\82ð\92T\82·
+    for i := 0 to Screen.CustomFormCount - 1 do begin
+        if TObject(Screen.CustomForms[i]) is TEditorForm then
+            ShowWindow(Screen.CustomForms[i].Handle, nCmdShow);
+
+    end;
+end;
+//! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
+procedure TGikoForm.CreateResPopupBrowser;
+begin
+    if (FResPopupBrowser = nil) then begin
+        FResPopupBrowser := TResPopupBrowser.Create(BrowserPanel);
+    end;
+end;
+//! 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
+        Board := TBoard(GetActiveList);
+        if MsgBox(Handle, Board.Title
+            + ' \94Â\82É\93ü\82ê\82Ä\82¢\82¢\82Å\82·\82©\81H', '\83M\83R\83i\83r', MB_YESNO or MB_ICONQUESTION) = IDYES      then 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.WParam, $FFFFFFFF, FileName, SizeOf(FileName));
+                for K := 0 to Cnt - 1 do begin
+                    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);
+                        if (FileExists( LogFolder + ExtractFileName(FileName))) then begin
+                            GikoUtil.MsgBox(Handle, LogFolder + '\82É' + ExtractFileName(FileName) + '\82ª\8aù\82É\91\8dÝ\82µ\82Ü\82·\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+                        end else begin
+                            if (not DirectoryExists(LogFolder)) then begin
+                                if (not GikoSys.ForceDirectoriesEx(LogFolder) ) then begin
+                                    GikoUtil.MsgBox(Handle, LogFolder + '\82Ì\90\90¬\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+                                end;
+                            end;
+                            if (not Windows.CopyFile(FileName,  PChar(LogFolder + ExtractFileName(FileName)), true)) then begin
+                                GikoUtil.MsgBox(Handle, FileName + '\82Ì\83R\83s\81[\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+                            end else begin
+                                datList.Add(ExtractFileName(FileName));
+                            end;
+                        end;
+                    end;
+                end;
+                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' );
+                       if GikoForm.TreeView.Visible then
+                               GikoForm.TreeView.Refresh;
+                           if GikoForm.ListView.Visible then
+                               GikoForm.ListView.Refresh;
+                end else begin
+                    ShowMessage('\88ê\82Â\82à\83R\83s\81[\82³\82ê\82Ü\82¹\82ñ\82Å\82µ\82½\81B' );
+                end;
+            finally
+                datList.Free;
+            end;
+
+        end;
+    end else 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
+    dt: TDateTime;
+begin
+    Result := True;
+    // \91\8dÝ\82·\82é\82©\81A\8ag\92£\8eqdat\81A\83t\83@\83C\83\8b\96¼
+    if ( not FileExists(FileName) ) then begin
+        Result := False;
+        GikoUtil.MsgBox(Handle, FileName + '\82Í\91\8dÝ\82µ\82Ü\82¹\82ñ\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+    end else if (ExtractFileExt(ExtractFileName(FileName)) <> '.dat' ) then begin
+        Result := False;
+        GikoUtil.MsgBox(Handle, ExtractFileName(FileName) + '\82Ì\8ag\92£\8eq\82ª".dat"\82Å\82 \82è\82Ü\82¹\82ñ\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+    end else begin
+        // \83\8d\83O\83t\83@\83C\83\8b\82Ì\8ag\92£\8eq\82ð\82Í\82¸\82µ\82½\82à\82Ì\82ª\83X\83\8c\8dì\90¬\93ú\8e\9e
+        try
+            dt := GikoSys.GetCreateDateFromName(FileName);
+            if ((UnixToDateTime(ZERO_DATE) + OffsetFromUTC) = dt) then begin
+                Result := False;
+                GikoUtil.MsgBox(Handle, ExtractFileName(FileName) + '\82Ì\83t\83@\83C\83\8b\96¼\82ª\95s\90³\82Å\82·\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+            end;
+        except
+            Result := False;
+            GikoUtil.MsgBox(Handle, ExtractFileName(FileName) + '\82Ì\83t\83@\83C\83\8b\96¼\82ª\95s\90³\82Å\82·\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
+        end;
+    end;
+end;
+
+procedure TGikoForm.ResPopupClearTimerTimer(Sender: TObject);
+begin
+    ResPopupClearTimer.Enabled := False;
+    if ResPopupClearTimer.Tag = 0 then begin
+        FResPopupBrowser.Clear;
+    end else begin
+        FResPopupBrowser.CurrentBrowser.ChildClear;
+    end;
+end;
 
 initialization
                                OleInitialize(nil);
 finalization
                                OleUninitialize;
 
+
 end.