OSDN Git Service

マルチモニタ向けの修正(未確認)
[gikonavigoeson/gikonavi.git] / Giko.pas
1 unit Giko;
2
3 interface
4
5 uses
6         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7         OleCtrls,       ComCtrls, ExtCtrls, Menus, StdCtrls, MMSystem, DateUtils,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10         MSHTML,
11 {$ELSE}
12         SHDocVw_TLB,
13         MSHTML_TLB,
14 {$IFEND}
15         IdHTTP, ActiveX, ActnList, ImgList,
16         ToolWin, Buttons, IdComponent, UrlMon, Tabs, IdGlobal, StrUtils,
17         CommCtrl, Dialogs, GikoSystem, Setting, BoardGroup, ThreadControl, ItemDownload,
18         Editor, RoundData, GikoPanel, Favorite, HTMLDocumentEvent,
19         {HintWindow,} GikoCoolBar, GikoListView, Search, ExternalBoardManager,
20         ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,
21         IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord, MoveHistoryItem,
22     ShellAPI,Preview, HistoryList, ResPopupBrowser;
23
24 const
25         NGWORDNAME_PANEL = 3;
26         THREADSIZE_PANEL = 2;
27     USER_RESPOPUPCLEAR          = WM_USER + 2005;       ///< wParam : TWebBrowser
28         
29 type
30
31         TToolBarSettingSenderType = (tssNone, tssMain, tssList, tssBrowser);
32         TMinimizeType = (mtNone, mtMinimizing, mtMinimized);
33         TResizeType = (rtNone, rtResizing);
34
35 //      TBrowserRecord = class;
36
37         TGikoForm = class(TForm)
38                 StatusBar: TStatusBar;
39                 MainPanel: TPanel;
40                 ClientPanel: TPanel;
41                 TreeSplitter: TSplitter;
42                 CabinetPanel: TPanel;
43                 TreeView: TTreeView;
44                 ThreadMainPanel: TPanel;
45                 ListSplitter: TSplitter;
46                 ViewPanel: TPanel;
47                 ListView: TGikoListView;
48                 ThreadPanel: TPanel;
49                 MessagePanel: TPanel;
50                 MessageBar: TPanel;
51                 MessageHideButton: TSpeedButton;
52                 MessageListView: TListView;
53                 MessageSplitter: TSplitter;
54                 Panel3: TPanel;
55     CabinetCloseSpeedButton: TSpeedButton;
56                 ToolBar1: TToolBar;
57                 CabinetSelectToolButton: TToolButton;
58                 HistoryToolBar: TToolBar;
59     HistoryShowToolButton: TToolButton;
60     HistoryAllClearToolButton: TToolButton;
61                 ItemIcon16: TImageList;
62                 ItemIcon32: TImageList;
63                 HotToobarImageList: TImageList;
64                 ItemImageList: TImageList;
65                 MainMenu: TMainMenu;
66                 FileMenu: TMenuItem;
67                 DeleteMenu: TMenuItem;
68                 ExitMenu: TMenuItem;
69                 KidokuMenu: TMenuItem;
70                 MidokuMenu: TMenuItem;
71                 AllSelectMenu: TMenuItem;
72                 ViewMenu: TMenuItem;
73                 StdToolBarMenu: TMenuItem;
74                 CabinetMenu: TMenuItem;
75                 H1: TMenuItem;
76                 N4: TMenuItem;
77                 CabinetVisibleMenu: TMenuItem;
78                 MessageMenu: TMenuItem;
79                 StatusBarMenu: TMenuItem;
80                 MMSep03: TMenuItem;
81                 LargeIconMenu: TMenuItem;
82                 SmallIconMenu: TMenuItem;
83                 ListMenu: TMenuItem;
84                 DetailMenu: TMenuItem;
85                 ToolMenu: TMenuItem;
86                 Find1: TMenuItem;
87                 RoundMenu: TMenuItem;
88                 MMSep04: TMenuItem;
89                 OptionMenu: TMenuItem;
90                 HelpMenu: TMenuItem;
91                 G1: TMenuItem;
92                 N1: TMenuItem;
93                 AboutMenu: TMenuItem;
94                 BrowserPopupMenu: TPopupMenu;
95                 ShowThreadMenu: TMenuItem;
96                 ShowBoardMenu: TMenuItem;
97                 ListIconPopupMenu: TPopupMenu;
98                 LargeIconPMenu: TMenuItem;
99                 SmallIconPMenu: TMenuItem;
100                 ListPMenu: TMenuItem;
101                 DetailPMenu: TMenuItem;
102                 ClosePopupMenu: TPopupMenu;
103                 CloseMenu: TMenuItem;
104                 U1: TMenuItem;
105                 N3: TMenuItem;
106                 B1: TMenuItem;
107                 S1: TMenuItem;
108                 N2: TMenuItem;
109                 A1: TMenuItem;
110                 L1: TMenuItem;
111                 N5: TMenuItem;
112                 S2: TMenuItem;
113                 ListPopupMenu: TPopupMenu;
114                 ListRoundPMenu: TMenuItem;
115                 ListReservPMenu: TMenuItem;
116                 LPMSep01: TMenuItem;
117                 ItemRoundPMenu: TMenuItem;
118                 LPMSep02: TMenuItem;
119                 KidokuPMenu: TMenuItem;
120                 MidokuPMenu: TMenuItem;
121                 AllSelectPMenu: TMenuItem;
122                 UrlCopyPMenu: TMenuItem;
123                 LPMSep05: TMenuItem;
124                 DeletePMenu: TMenuItem;
125                 LPMSep06: TMenuItem;
126                 ViewPMenu: TMenuItem;
127                 LargeIconLPMenu: TMenuItem;
128                 SmallIconLPMenu: TMenuItem;
129                 ListLPMenu: TMenuItem;
130                 DetailLPMenu: TMenuItem;
131                 T1: TMenuItem;
132                 B2: TMenuItem;
133                 N8: TMenuItem;
134                 URLC1: TMenuItem;
135                 N9: TMenuItem;
136                 N10: TMenuItem;
137                 G2: TMenuItem;
138                 N11: TMenuItem;
139                 T3: TMenuItem;
140                 L2: TMenuItem;
141                 N12: TMenuItem;
142                 K1: TMenuItem;
143                 N13: TMenuItem;
144                 N14: TMenuItem;
145                 R1: TMenuItem;
146                 A2: TMenuItem;
147                 N15: TMenuItem;
148                 KokoPopupMenu: TPopupMenu;
149                 KokomadePMenu: TMenuItem;
150                 AllPMenu: TMenuItem;
151                 MenuItem1: TMenuItem;
152                 MenuItem2: TMenuItem;
153                 BrowserTabPopupMenu: TPopupMenu;
154                 Close1: TMenuItem;
155                 A3: TMenuItem;
156                 N16: TMenuItem;
157                 A4: TMenuItem;
158                 TreePopupMenu: TPopupMenu;
159                 TreeSelectThreadPupupMenu: TMenuItem;
160                 TreeSelectBoardPupupMenu: TMenuItem;
161                 TPMSep01: TMenuItem;
162                 TreeSelectURLPupupMenu: TMenuItem;
163                 T2: TMenuItem;
164                 L3: TMenuItem;
165                 B3: TMenuItem;
166                 BrowserBottomPanel: TGikoPanel;
167                 CabinetSelectPopupMenu: TPopupMenu;
168                 H2: TMenuItem;
169                 ItemReservPMenu: TMenuItem;
170                 RoundNamePopupMenu: TPopupMenu;
171                 N7: TMenuItem;
172                 B4: TMenuItem;
173                 L4: TMenuItem;
174                 K2: TMenuItem;
175                 A5: TMenuItem;
176                 A6: TMenuItem;
177                 C1: TMenuItem;
178                 V1: TMenuItem;
179                 N19: TMenuItem;
180                 D1: TMenuItem;
181                 D2: TMenuItem;
182                 MessageImageList: TImageList;
183                 ProgressBar: TProgressBar;
184                 URL1: TMenuItem;
185                 NameUrlCopyPMenu: TMenuItem;
186                 URLC2: TMenuItem;
187                 URLN1: TMenuItem;
188                 N21: TMenuItem;
189                 URLC3: TMenuItem;
190                 URLN2: TMenuItem;
191                 N23: TMenuItem;
192                 ListCoolBar: TGikoCoolBar;
193                 ListToolBar: TToolBar;
194                 BrowserCoolBar: TGikoCoolBar;
195                 BrowserToolBar: TToolBar;
196                 ToolButton3: TToolButton;
197                 ToolButton9: TToolButton;
198                 ToolButton11: TToolButton;
199                 ToolButton5: TToolButton;
200                 ListNameToolBar: TToolBar;
201                 ListNameLabel: TLabel;
202                 FolderImage: TImage;
203                 BrowserNameToolBar: TToolBar;
204                 ItemBoardImage: TImage;
205                 BrowserBoardNameLabel: TLabel;
206                 ItemImage: TImage;
207                 BrowserNameLabel: TLabel;
208                 D3: TMenuItem;
209                 N25: TMenuItem;
210                 N26: TMenuItem;
211                 D4: TMenuItem;
212                 S3: TMenuItem;
213                 R2: TMenuItem;
214                 TreeSelectNameURLPupupMenu: TMenuItem;
215                 N27: TMenuItem;
216                 H3: TMenuItem;
217                 I1: TMenuItem;
218                 BrowserTabToolBar: TToolBar;
219                 BrowserTab: TTabControl;
220                 About1: TMenuItem;
221                 N28: TMenuItem;
222                 S4: TMenuItem;
223                 N29: TMenuItem;
224                 N30: TMenuItem;
225                 N31: TMenuItem;
226                 L5: TMenuItem;
227                 L6: TMenuItem;
228                 A7: TMenuItem;
229                 R3: TMenuItem;
230                 FavoriteMenu: TMenuItem;
231                 N32: TMenuItem;
232                 BoardFavoriteAddMenu: TMenuItem;
233                 ThreadFavoriteAddMenu: TMenuItem;
234                 N33: TMenuItem;
235                 TreeSelectFavoriteAddPupupMenu: TMenuItem;
236                 FavoriteTreeView: TTreeView;
237                 StateIconImageList: TImageList;
238                 TopPanel: TPanel;
239                 TopRightPanel: TPanel;
240                 AnimePanel: TPanel;
241                 Animate: TAnimate;
242                 TopCoolPanel: TPanel;
243                 MainCoolBar: TGikoCoolBar;
244                 MenuToolBar: TToolBar;
245                 StdToolBar: TToolBar;
246                 AddressToolBar: TToolBar;
247                 AddressComboBox: TComboBox;
248                 MoveToToolButton: TToolButton;
249                 AddressImageList: TImageList;
250                 AddressToolBarMenu: TMenuItem;
251                 T4: TMenuItem;
252                 Show1: TMenuItem;
253                 N34: TMenuItem;
254                 T5: TMenuItem;
255                 B5: TMenuItem;
256                 N35: TMenuItem;
257                 A8: TMenuItem;
258                 U2: TMenuItem;
259                 F1: TMenuItem;
260                 PreviewTimer: TTimer;
261                 MonazillaWebPageAction1: TMenuItem;
262                 N36: TMenuItem;
263                 H4: TMenuItem;
264                 K3: TMenuItem;
265                 L7: TMenuItem;
266                 N37: TMenuItem;
267                 A9: TMenuItem;
268                 ChevronPopupMenu: TPopupMenu;
269                 N2N1: TMenuItem;
270                 N38: TMenuItem;
271                 F2: TMenuItem;
272                 LinkToolBar: TToolBar;
273                 a10: TMenuItem;
274                 N39: TMenuItem;
275                 T6: TMenuItem;
276                 N40: TMenuItem;
277                 LinkBarPopupMenu: TPopupMenu;
278                 T7: TMenuItem;
279                 ThreadPopupMenu: TPopupMenu;
280                 MenuItem4: TMenuItem;
281                 MenuItem5: TMenuItem;
282                 MenuItem6: TMenuItem;
283                 T8: TMenuItem;
284                 URLN3: TMenuItem;
285                 SelectItemNameCopyAction1: TMenuItem;
286                 B6: TMenuItem;
287                 T9: TMenuItem;
288     NameCopyPMenu: TMenuItem;
289                 SelectComboBox: TComboBox;
290                 MainCoolBarPopupMenu: TPopupMenu;
291                 StdToolBarVisiblePMenu: TMenuItem;
292                 AddressToolBarVisiblePMenu: TMenuItem;
293                 LinkToolBarVisiblePMenu: TMenuItem;
294                 NG1: TMenuItem;
295                 NG2: TMenuItem;
296                 N43: TMenuItem;
297                 N44: TMenuItem;
298                 L9: TMenuItem;
299                 I3: TMenuItem;
300                 N45: TMenuItem;
301                 B9: TMenuItem;
302                 R5: TMenuItem;
303                 T12: TMenuItem;
304                 Show3: TMenuItem;
305                 N46: TMenuItem;
306                 T13: TMenuItem;
307                 B10: TMenuItem;
308                 N47: TMenuItem;
309                 A12: TMenuItem;
310                 U4: TMenuItem;
311                 F4: TMenuItem;
312                 N48: TMenuItem;
313                 T14: TMenuItem;
314                 ToolButton16: TToolButton;
315                 N50: TMenuItem;
316                 A11: TMenuItem;
317                 S5: TMenuItem;
318                 Reload: TMenuItem;
319                 GoBack: TMenuItem;
320                 GoFoward: TMenuItem;
321                 IndividualAbon1: TMenuItem;
322                 N41: TMenuItem;
323                 IndividualAbon2: TMenuItem;
324     AntiIndivAbonMenuItem: TMenuItem;
325                 AntiIndividualAbon: TMenuItem;
326                 N49: TMenuItem;
327                 N51: TMenuItem;
328                 N52: TMenuItem;
329                 SearchBoardName: TMenuItem;
330     TreeSelectLogDeleteSeparator: TMenuItem;
331                 N54: TMenuItem;
332                 A13: TMenuItem;
333                 FavoriteTreePopupMenu: TPopupMenu;
334                 FavoriteTreeRenamePopupMenu: TMenuItem;
335                 FavoriteTreeNewFolderPopupMenu: TMenuItem;
336                 N56: TMenuItem;
337                 FavoriteTreeDeletePopupMenu: TMenuItem;
338                 FavoriteToolBar: TToolBar;
339     FavoriteAddToolButton: TToolButton;
340     FavoriteArrangeToolButton: TToolButton;
341                 FavoriteTreeBrowseFolderPopupMenu: TMenuItem;
342                 N57: TMenuItem;
343                 FavoriteTreeReloadPopupMenu: TMenuItem;
344                 N58: TMenuItem;
345                 FavoriteTreeURLCopyPopupMenu: TMenuItem;
346                 FavoriteTreeNameCopyPopupMenu: TMenuItem;
347                 FavoriteTreeLogDeletePopupMenu: TMenuItem;
348                 N59: TMenuItem;
349                 FavoriteTreeNameURLCopyPopupMenu: TMenuItem;
350                 ToolButton20: TToolButton;
351                 N60: TMenuItem;
352                 ExportFavoriteFileAction1: TMenuItem;
353                 N6: TMenuItem;
354                 N17: TMenuItem;
355     N18: TMenuItem;
356     N20: TMenuItem;
357         N24: TMenuItem;
358     N62: TMenuItem;
359         N61: TMenuItem;
360         N63: TMenuItem;
361     N64: TMenuItem;
362     dummy1: TMenuItem;
363         TreeSelectLogDeletePopupMenu: TMenuItem;
364         N65: TMenuItem;
365     BBSSelectPopupMenu: TPopupMenu;
366                 PlugInMenu: TMenuItem;
367         TreeSelectNamePupupMenu: TMenuItem;
368     BrowserPanel: TPanel;
369         SelectTimer: TTimer;
370     SelectThreadSave: TMenuItem;
371     N55: TMenuItem;
372     N66: TMenuItem;
373     dat1: TMenuItem;
374                 OpenLogFolder: TMenuItem;
375     Browser: TWebBrowser;
376     TabSave: TMenuItem;
377         TabOpen: TMenuItem;
378     ResRangePopupMenu: TPopupMenu;
379     ResRangeHundPMenuItem: TMenuItem;
380     ResRangeKokoPMenuItem: TMenuItem;
381     ResRangeNewPMenuItem: TMenuItem;
382     ResRangeAllPMenuItem: TMenuItem;
383         BrowsBoradHeadAction1: TMenuItem;
384     ThreadRangePopupMenu: TPopupMenu;
385     A15: TMenuItem;
386     L8: TMenuItem;
387         N67: TMenuItem;
388     N68: TMenuItem;
389     S6: TMenuItem;
390     N69: TMenuItem;
391     ResRangeSelectPMenuItem: TMenuItem;
392     ListColumnPopupMenu: TPopupMenu;
393     N70: TMenuItem;
394     ID1: TMenuItem;
395     ID2: TMenuItem;
396     N53: TMenuItem;
397     ID3: TMenuItem;
398     N71: TMenuItem;
399     N72: TMenuItem;
400     N73: TMenuItem;
401     SelectComboBoxPanel: TPanel;
402     SelectComboBoxSplitter: TImage;
403         ToolButton1: TToolButton;
404     N74: TMenuItem;
405     WikiFAQ: TMenuItem;
406     GikoApplicationEvents: TApplicationEvents;
407     N22: TMenuItem;
408     N42: TMenuItem;
409     DAT2: TMenuItem;
410     N75: TMenuItem;
411     DAT3: TMenuItem;
412     N76: TMenuItem;
413     FavoriteTreeItemNameCopyPopupMenu: TMenuItem;
414     N77: TMenuItem;
415     N78: TMenuItem;
416     SaveThreadFile: TMenuItem;
417     N79: TMenuItem;
418     HTML1: TMenuItem;
419     DAT4: TMenuItem;
420     N80: TMenuItem;
421     SameBoardThreadItem: TMenuItem;
422     N81: TMenuItem;
423     N82: TMenuItem;
424     IDNG1: TMenuItem;
425     IDNG2: TMenuItem;
426     ResPopupClearTimer: TTimer;
427                                 procedure FormCreate(Sender: TObject);
428                 procedure FormDestroy(Sender: TObject);
429                 procedure BrowserStatusTextChange(Sender: TObject;
430                         const Text: WideString);
431                 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
432                 procedure TreeViewChanging(Sender: TObject; Node: TTreeNode;
433                         var AllowChange: Boolean);
434                 procedure ListViewKeyDown(Sender: TObject; var Key: Word;
435                         Shift: TShiftState);
436                 procedure ListViewColumnClick(Sender: TObject; Column: TListColumn);
437                 procedure MenuToolBarCustomDrawButton(Sender: TToolBar;
438                         Button: TToolButton; State: TCustomDrawState;
439                         var DefaultDraw: Boolean);
440                 procedure BrowserBeforeNavigate2(Sender: TObject;
441                         const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
442                         Headers: OleVariant; var Cancel: WordBool);
443                 procedure TreeViewCustomDraw(Sender: TCustomTreeView;
444                         const ARect: TRect; var DefaultDraw: Boolean);
445                 procedure TreeViewCustomDrawItem(Sender: TCustomTreeView;
446                         Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
447                 procedure TreeViewExpanded(Sender: TObject; Node: TTreeNode);
448                 procedure ListViewCustomDraw(Sender: TCustomListView;
449                         const ARect: TRect; var DefaultDraw: Boolean);
450                 procedure ListViewMouseDown(Sender: TObject; Button: TMouseButton;
451                         Shift: TShiftState; X, Y: Integer);
452                 procedure TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
453                 procedure MessageListViewResize(Sender: TObject);
454                 procedure       CabinetVisible( isVisible : Boolean );
455                 procedure FormResize(Sender: TObject);
456                 procedure ListPopupMenuPopup(Sender: TObject);
457                 procedure TreePopupMenuPopup(Sender: TObject);
458                 procedure BrowserNewWindow2(Sender: TObject; var ppDisp: IDispatch;
459                         var Cancel: WordBool);
460                 procedure ListSplitterMoved(Sender: TObject);
461                 procedure BrowserTabChange(Sender: TObject);
462                 procedure BrowserTabMouseDown(Sender: TObject; Button: TMouseButton;
463                         Shift: TShiftState; X, Y: Integer);
464                 procedure BrowserTabDragOver(Sender, Source: TObject; X, Y: Integer;
465                         State: TDragState; var Accept: Boolean);
466                 procedure BrowserTabDragDrop(Sender, Source: TObject; X, Y: Integer);
467                 procedure BrowserTabMouseMove(Sender: TObject; Shift: TShiftState; X,
468                         Y: Integer);
469                 procedure BrowserDocumentComplete(Sender: TObject;
470                         const pDisp: IDispatch; var URL: OleVariant);
471                 procedure RoundNamePopupMenuPopup(Sender: TObject);
472                 procedure FormShow(Sender: TObject);
473                 procedure BrowserTabToolBarResize(Sender: TObject);
474                 procedure FavoriteMenuClick(Sender: TObject);
475                 procedure MainCoolBarResize(Sender: TObject);
476                 procedure AddressToolBarResize(Sender: TObject);
477                 procedure AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
478                         Shift: TShiftState);
479                 procedure BrowserEnter(Sender: TObject);
480                 procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
481                 procedure PreviewTimerTimer(Sender: TObject);
482                 procedure MessageHideButtonClick(Sender: TObject);
483                 procedure HistoryAllClearToolButtonClick(Sender: TObject);
484                 procedure MainCoolBarBandInfo(Sender: TObject;
485                         var BandInfo: PReBarBandInfoA);
486                 procedure MainCoolBarChevronClick(Sender: TObject;
487                         RebarChevron: PNMRebarChevron);
488                 procedure ListCoolBarBandInfo(Sender: TObject;
489                         var BandInfo: PReBarBandInfoA);
490                 procedure ListCoolBarChevronClick(Sender: TObject;
491                         RebarChevron: PNMRebarChevron);
492                 procedure BrowserCoolBarBandInfo(Sender: TObject;
493                         var BandInfo: PReBarBandInfoA);
494                 procedure BrowserCoolBarChevronClick(Sender: TObject;
495                         RebarChevron: PNMRebarChevron);
496                 procedure ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
497                 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
498                         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
499                 procedure SelectComboBoxChange(Sender: TObject);
500                 procedure SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
501                         Shift: TShiftState);
502                 procedure SelectComboBoxExit(Sender: TObject);
503                 procedure SelectComboBoxSplitterMouseMove(Sender: TObject;
504                         Shift: TShiftState; X, Y: Integer);
505                 procedure SelectComboBoxSplitterMouseDown(Sender: TObject;
506                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
507                 procedure SelectComboBoxSplitterMouseUp(Sender: TObject;
508                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
509                 procedure StatusBarResize(Sender: TObject);
510                 procedure SelectComboBoxEnter(Sender: TObject);
511                 procedure FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
512                         Y: Integer);
513                 procedure FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
514                 procedure FavoriteTreeViewEdited(Sender: TObject; Node: TTreeNode;
515                         var S: String);
516                 procedure FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
517                         Shift: TShiftState);
518                 procedure FavoriteTreePopupMenuPopup(Sender: TObject);
519                 procedure LinkToolBarDragDrop(Sender, Source: TObject; X, Y: Integer);
520                 procedure BrowserTabMouseUp(Sender: TObject; Button: TMouseButton;
521                         Shift: TShiftState; X, Y: Integer);
522                 procedure LinkToolBarDragOver(Sender, Source: TObject; X, Y: Integer;
523                         State: TDragState; var Accept: Boolean);
524                 procedure FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
525                         Y: Integer);
526                 procedure FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
527     procedure BrowserTabContextPopup(Sender: TObject; MousePos: TPoint;
528       var Handled: Boolean);
529     procedure BrowserTabPopupMenuPopup(Sender: TObject);
530     procedure BrowserTabResize(Sender: TObject);
531     procedure TreeViewKeyDown(Sender: TObject; var Key: Word;
532       Shift: TShiftState);
533     procedure FavoriteTreeViewMouseDown(Sender: TObject;
534                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
535     procedure MessagePanelResize(Sender: TObject);
536                 procedure OnResized;
537         procedure SelectTimerTimer(Sender: TObject);
538                 procedure ListViewColumnRightClick(Sender: TObject;
539       Column: TListColumn; Point: TPoint);
540         procedure ListViewCustomDrawItem(Sender: TCustomListView;
541       Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
542     procedure FormActivate(Sender: TObject);
543     procedure BrowserPanelResize(Sender: TObject);
544     procedure MenuToolBarResize(Sender: TObject);
545     procedure ListToolBarResize(Sender: TObject);
546     procedure BrowserToolBarResize(Sender: TObject);
547         procedure KokoPopupMenuPopup(Sender: TObject);
548         procedure ListViewKeyUp(Sender: TObject; var Key: Word;
549           Shift: TShiftState);
550     procedure FavoriteTreeViewEditing(Sender: TObject; Node: TTreeNode;
551       var AllowEdit: Boolean);
552         procedure CabinetCloseSpeedButtonClick(Sender: TObject);
553     procedure FavoriteArrangeToolButtonClick(Sender: TObject);
554     procedure GikoApplicationEventsMessage(var Msg: tagMSG;
555           var Handled: Boolean);
556     procedure GikoApplicationEventsDeactivate(Sender: TObject);
557     procedure GikoApplicationEventsException(Sender: TObject; E: Exception);
558     procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
559       Shift: TShiftState; X, Y: Integer);
560     procedure GetResURLMenuClick(Sender: TObject);
561     procedure MainCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
562       var Handled: Boolean);
563     procedure ResPopupClearTimerTimer(Sender: TObject);
564         private
565                 { Private \90é\8c¾ }
566                 FEnabledCloseButton: Boolean;
567                 FClickNode: TTreeNode;
568                 FHttpState: Boolean;
569                 FPreviewBrowser: TPreviewBrowser;
570                 FPreviewURL: string;
571                 FBrowserSizeHeight: Integer;
572                 FBrowserSizeWidth: Integer;
573                 FTabHintIndex: Integer;
574                 FListStyle: TViewStyle;                         //\83\8a\83X\83g\83A\83C\83R\83\93\83X\83^\83C\83\8b
575                 FItemNoVisible: Boolean;                        //\83\8a\83X\83g\94Ô\8d\86\95\\8e¦\83t\83\89\83O
576                 FViewType: TGikoViewType;                       //\83\8a\83X\83g\83A\83C\83e\83\80\95\\8e¦\83^\83C\83v
577                 FActiveList: TObject;
578                 FActiveContent: TBrowserRecord; //
579                 FActiveBBS : TBBS;
580                 FHistoryList: THistoryList;                                     //\83q\83X\83g\83\8a\83\8a\83X\83g
581                 FTreeType: TGikoTreeType;
582                 FWorkCount: Integer;
583                 FNameCookie: string;
584                 FMailCookie: string;
585                 FDownloadTitle: string;                         //\83_\83E\83\93\83\8d\81[\83h\92\86\82Ì\83^\83C\83g\83\8b\96¼
586                 FDownloadMax: Integer;                          //\83_\83E\83\93\83\8d\81[\83h\92\86\82Ì\8dÅ\91å\83T\83C\83Y
587                 FEvent: THTMLDocumentEventSink;//\83u\83\89\83E\83U\83h\83L\83\85\83\81\83\93\83g\83C\83x\83\93\83g
588                 IsDraggingSelectComboBox : Boolean;
589                 DraggingSelectComboBoxPosition : TPoint;
590                 FSearchDialog: TSearchDialog;
591                 FDropSpaceNode: TTreeNode;
592                 FDragTime : Cardinal;                                                           ///< \83\8a\83\93\83N\82ÌD&D\97p
593                 FDragButton : TToolButton;                                      ///< \83\8a\83\93\83N\82ÌD&D\97p\82ÉDrag\82µ\82Ä\82éButton\95Û\91
594                 FDragWFirst : Boolean;                                                  ///< WebTab\82ÌD&D\97p
595                 FListViewBackGroundColor : TColor;      ///< ListView\82ÌBackGroundColor
596                 FUseOddResOddColor : Boolean;                   ///< \8eæ\93¾\83\8c\83X\90\94\82Æ\83X\83\8c\83b\83h\82Ì\83\8c\83X\90\94\82ª\88á\82Á\82½\82Æ\82«\82É\91¼\82Ì\90F\82Å\95\\8e¦
597                 FOddColor : TColor;                                                                     ///< \82»\82Ì\90F
598                 FSelectResWord  : string;                                               ///< \83\8c\83X\8di\8d\9e\83\8f\81[\83h
599                 FIsIgnoreResize : TResizeType;                  ///< \83\8a\83T\83C\83Y\83C\83x\83\93\83g\82ð\96³\8e\8b\82·\82é\82©\82Ç\82¤\82©
600                 FIsMinimize                     : TMinimizeType;                ///< \8dÅ\8f¬\89»\82µ\82Ä\82¢\82é\8dÅ\92\86\82©
601                 FOldFormWidth           : Integer;                                      ///< \92¼\91O\82Ì\83E\83B\83\93\83h\83E\82Ì\95\9d
602                 FToolBarSettingSender : TToolBarSettingSenderType;      ///< \83c\81[\83\8b\83o\81[\90Ý\92è\82ð\83N\83\8a\83b\83N\82µ\82½\83N\81[\83\8b\83o\81[
603                 FMouseDownPos           : TPoint;                                       ///< \83u\83\89\83E\83U\83^\83u\82Å\83}\83E\83X\82ð\89\9f\82µ\82½\82Æ\82«\82Ì\8dÀ\95W
604                 FBrowsers: TList;
605                 FResRangeMenuSelect     : Longint;                      ///< ResRangeButton \82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\8d\80\96Ú (\83t\83H\81[\83}\83b\83g\82Í ResRange \8cÝ\8a·)
606                 FStartUp : Boolean;
607                 FIsHandledWheel : Boolean;                      ///< \8aù\82É\8eó\82¯\8eæ\82Á\82½ WM_MOUSEWHEEL \82©\82Ç\82¤\82©
608                                 DiffComp: Boolean;                      //Add by Genyakun \83X\83\8c\82ª\8dX\90V\82³\82ê\82½\82Æ\82«\82ÉTrue\82É\82È\82é
609                 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ñ
610                 FPreviewBrowserRect: TRect;                     ///< \83v\83\8c\83r\83\85\81[\82Ì\95\\8e¦\88Ê\92u\82ð\8bL\89¯\82·\82é
611                 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ñ
612         FResPopupBrowser: TResPopupBrowser;
613                 procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
614                 procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
615                 procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
616                 procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
617                 procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
618                 procedure ListClick;
619                 procedure ListDoubleClick(Shift: TShiftState);
620                 function Hook(var Message: TMessage): Boolean;
621                 procedure AddRoundNameMenu(MenuItem: TMenuItem);
622                 procedure SetMenuFont;
623                 procedure CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
624                 procedure FavoriteClick(Sender: TObject; ActiveTab: Boolean); overload;
625                 procedure FavoriteClick(Sender: TObject); overload;
626                 procedure FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
627                 function OnDocumentContextMenu(Sender: TObject): WordBool;
628                 function GetWidthAllToolButton(ToolBar: TToolBar): Integer;
629                 procedure MenuBarChevronMenu;
630                 procedure LinkBarChevronMenu;
631                 procedure ToolBarChevronMenu(ToolBar: TToolBar);
632                 procedure LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
633                 procedure LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
634                 procedure LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
635                 procedure LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
636                 procedure LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
637                 function TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
638                 procedure FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
639                 procedure FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
640                 procedure FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
641                 //
642                 procedure SetListViewBackGroundColor(value: TColor);
643                 procedure BBSMenuItemOnClick( Sender : TObject );
644                 /// CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
645                 procedure       SaveCoolBarSettings;
646                 procedure       SaveMainCoolBarSettings;
647                 procedure       SaveBoardCoolBarSettings;
648                 procedure       SaveBrowserCoolBarSettings;
649                 /// CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82©\82ç\95\9c\8c³
650                 procedure       LoadCoolBarSettings;
651                 /// \8dÅ\8f¬\89»\82³\82ê\82é
652                 procedure OnMinimize;
653                 /// \8dÅ\8f¬\89»\82³\82ê\82½
654                 procedure OnMinimized;
655                 /// TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
656                 procedure TreeClick( Node : TTreeNode );
657                 /// TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
658                 procedure TreeDoubleClick( Node : TTreeNode );
659                 /// \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
660                 procedure SetBBSMenu;
661                 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
662                 procedure       ListColumnPopupMenuOnClick( Sender : TObject );
663                 //! \8di\82è\8d\9e\82Ý\95\8e\9a\97ñ\90Ý\92è
664                 procedure SetSelectWord( const text : string );
665                 //\8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
666                 function GetScreenCursor(): TCursor;
667                 //\83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
668                 procedure SetScreenCursor(Cursor : TCursor);
669                 //! \83_\83E\83\93\83\8d\81[\83h\83R\83\93\83g\83\8d\81[\83\8b\83X\83\8c\83b\83h\82Ì\90\90¬
670                 procedure CreateControlThread();
671                 //! \83u\83\89\83E\83U\82Ì\90\90¬
672                 procedure CreateBrowsers(count: Integer);
673                 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
674                 procedure GetGroupIndex(ActionList: TActionList);
675                 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
676                 procedure SetGroupIndex(ActionList: TActionList);
677                 //! \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é)
678                 procedure OpenThreadItem(Thread: TThreadItem; URL: String);
679                 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
680                 procedure RefreshListView(Thread: TThreadItem);
681                 //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
682                 procedure ClearThreadRengeAction;
683         //! \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¦
684         procedure UnStoredTaskTray;
685         //! \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
686         procedure ShowEditors(nCmdShow: Integer);
687         //! \82à\82Á\82Æ\82à\8cÃ\82¢Browser\82Ì\8aJ\95ú
688         procedure ReleaseOldestBrowser;
689         //! \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Á
690         procedure AddMenuSameBoardThread;
691         //!  \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
692         procedure SameBoardThreadSubItemOnClick(Sender: TObject);
693         //! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
694         procedure CreateResPopupBrowser;
695         //! \83t\83@\83C\83\8b\83`\83F\83b\83N
696         function isValidFile(FileName: String) : boolean;
697         //! ListView\82ÌD&D\8eó\82¯\8eæ\82è
698         procedure AcceptDropFiles(var Msg: TMsg);
699         protected
700                 procedure CreateParams(var Params: TCreateParams); override;
701                 procedure WndProc(var Message: TMessage); override;
702                 procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;
703                 procedure WMSettingChange(var Message: TWMWinIniChange); message WM_SETTINGCHANGE;
704                 procedure WMCopyData(var Message: TWMCopyData); message WM_COPYDATA;
705         public
706                 { Public \90é\8c¾ }
707                 LastRoundTime: TDateTime;
708                 BrowserNullTab: TBrowserRecord;
709                 FControlThread: TThreadControl;
710         FIconData : TNotifyIconData;
711                 procedure MoveToURL(const inURL: string);
712                 function InsertBrowserTab(ThreadItem: TThreadItem; ActiveTab: Boolean = True) : TBrowserRecord;
713                 procedure ReloadBBS;
714                 function GetHttpState: Boolean;
715                 procedure SetEnabledCloseButton(Enabled: Boolean);
716                 function GetTreeNode(Data: TObject): TTreeNode;
717                 procedure ListViewAllSelect;
718                 property ListStyle: TViewStyle read FListStyle write FListStyle;
719                 property ItemNoVisible: Boolean read FItemNoVisible write FItemNoVisible;
720                 property ViewType: TGikoViewType read FViewType write FViewType;
721                 property NameCookie: string read FNameCookie write FNameCookie;
722                 property MailCookie: string read FMailCookie write FMailCookie;
723                 property ClickNode: TTreeNode read FClickNode write FClickNode;
724                 property TreeType: TGikoTreeType read FTreeType write FTreeType;
725                 property ActiveContent: TBrowserRecord read FActiveContent write FActiveContent;
726                 property ResRangeMenuSelect: Longint read FResRangeMenuSelect write FResRangeMenuSelect;
727                 property SelectResWord  : string read FSelectResWord write FSelectResWord;
728                 property BrowserSizeWidth: Integer read FBrowserSizeWidth write FBrowserSizeWidth;
729                 property BrowserSizeHeight: Integer read FBrowserSizeHeight write FBrowserSizeHeight;
730                 property SearchDialog: TSearchDialog read FSearchDialog write FSearchDialog;
731                 property ToolBarSettingSender : TToolBarSettingSenderType
732                                                  read FToolBarSettingSender write FToolBarSettingSender;
733                 property ScreenCursor : TCursor read GetScreenCursor write SetScreenCursor;
734                 property ActiveBBS : TBBS read FActiveBBS write FActiveBBS;
735                 property WorkCount: Integer read FWorkCount write FWorkCount;
736                 procedure SetContent(inThread: TBrowserRecord);
737                 function GetActiveContent(popup :Boolean = false): TThreadItem;
738                 function GetActiveList: TObject;
739
740                 procedure SetListViewType(AViewType: TGikoViewType); overload;
741                 procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;
742                 procedure PlaySound(SoundEventName: string);
743                 procedure ShowBBSTree( inBBS : TBBS );
744                 procedure ShowBBSTreeOld( inBBS : TBBS );
745                 procedure ShowHistoryTree;
746                 procedure AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
747                 procedure SetBrowserTabState;
748                 procedure SetToolBarPopup;
749                 procedure ShowFavoriteAddDialog( Item : TObject );
750                 procedure FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
751                 procedure RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
752                 property ListViewBackGroundColor: TColor read FListViewBackGroundColor write SetListViewBackGroundColor;
753                 property UseOddResOddColor : Boolean read FUseOddResOddColor write FUseOddResOddColor;
754                 property OddColor : TColor read FOddColor write FOddColor;
755                 function FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
756                 procedure OnPlugInMenuItem( Sender : TObject );
757                 procedure TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
758                 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91¶ KuroutSetting\82©\82ç\82æ\82Ñ\82¾\82µ\82½\82¢\82Ì\82Å
759                 procedure ActiveListColumnSave;
760                 procedure SetActiveList(Obj: TObject);
761                 property ActiveList: TObject read GetActiveList write SetActiveList;
762                 /// CoolBar \82ª\83T\83C\83Y\95Ï\8dX\82³\82ê\82½
763                 procedure       CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
764                 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
765                 procedure IndividualAbonID(Atype : Integer);
766                 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
767                 procedure IndividualAbon(Atag, Atype : Integer);
768         //\93¯\88êID\82ðNG\83\8f\81[\83h\82É\93o\98^
769         procedure AddIDtoNGWord(invisible : boolean);
770                 //\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Ý
771                 procedure RepaintAllTabsBrowser();
772                 //\83\8a\83\93\83N\83o\81[\90Ý\92è
773                 procedure SetLinkBar;
774                 procedure FavoriteBrowseFolder( node: TTreeNode );
775                 //\83X\83\8c\83b\83h\82Ì\83_\83E\83\93\83\8d\81[\83h
776                 procedure DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
777                 //\94Â\82Ì\83_\83E\83\93\83\8d\81[\83h
778                 procedure DownloadList(Board: TBoard; ForceDownload: Boolean = False);
779                 //\97\9a\97ð\82©\82ç\8dí\8f\9c
780                 procedure DeleteHistory( threadItem: TThreadItem );
781                 //\83^\83u\82ð\8dí\8f\9c \83X\83\8c\83b\83h\8ew\92è
782                 procedure DeleteTab(ThreadItem: TThreadItem); overload;
783                 //\83^\83u\82ð\8dí\8f\9c \83u\83\89\83E\83U\83\8c\83R\81[\83h\81i\83^\83u\81j\8ew\92è
784                 procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
785         // \83^\83u\8dí\8f\9c\81i\8eÀ\91\95\95\94\81j
786         procedure DeleteTab(index, selectIndex: Integer); overload;
787                 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
788                 procedure BrowserMovement(const AName: string); overload;
789                 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
790                 procedure BrowserMovement(scroll: Integer); overload;
791                 //Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
792                 function GetMainForm(): TComponent;
793                 procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
794                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\8en
795                 procedure OnGestureStart(Sender: TObject);
796                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\92\86
797                 procedure OnGestureMove(Sender: TObject);
798                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8fI\97¹
799                 procedure OnGestureEnd(Sender: TObject);
800                 /// \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
801                 procedure ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
802                 //ListView\82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é
803                 procedure SelectListItem(List: TList);
804                 //\8ew\92è\82µ\82½\83\8c\83X\82ð\83R\83s\81[\82·\82é
805                 procedure KonoresCopy(Number: Integer; ReplaceTag : Boolean);
806                 //
807                 procedure ModifySelectList;
808                 //
809                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string); overload;
810                 //
811                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string); overload;
812                 //
813                 procedure SetSelectRoundName(Sender: TObject);
814                 //
815                 function GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
816                 //
817                 function WebBrowserClick(Sender: TObject): WordBool;
818                 //! \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é
819                 procedure SetSelectComboBox();
820
821         //! \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
822         procedure TaskTrayIconMessage(var Msg : TMsg); message WM_USER + 2010;
823         //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
824         procedure StoredTaskTray;
825         published
826                 property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
827         end;
828
829         TFavoriteMenuItem = class(TMenuItem)
830         private
831                 FData : Pointer;
832         public
833                 property Data: Pointer read FData write FData;
834         end;
835
836         TBBSMenuItem = class(TMenuItem)
837         private
838                 FData : Pointer;
839         public
840                 property Data: Pointer read FData write FData;
841         end;
842
843         TLinkToolButton = class(TToolButton)
844         private
845                 FData : Pointer;
846         public
847                 property Data: Pointer read FData write FData;
848         end;
849
850 var
851         GikoForm: TGikoForm;
852
853 implementation
854
855 uses
856         GikoUtil, IndividualAbon, Math, Kotehan, KeySetting,
857         YofUtils, ToolBarUtil, ToolBarSetting,
858         GikoXMLDoc, RoundName, IniFiles, FavoriteAdd,
859         FavoriteArrange, AddressHistory, Gesture,
860         About, Option, Round, Splash, Sort, ListSelect, Imm,
861         NewBoard, MojuUtils, Clipbrd, GikoBayesian,Y_TextConverter,
862         HTMLCreate, ListViewUtils, GikoDataModule, GikoMessage,
863   InputAssistDataModule, Types, ReplaceDataModule;
864
865 const
866         BLANK_HTML: string = 'about:blank';
867         BROWSER_COUNT           = 5;    //\83u\83\89\83E\83U\82Ì\90\94
868         //D&D臒l
869         DandD_THRESHOLD = 5;    //D&D\82Ìè\87\92l\81ipixcel)
870         //\83v\83\8c\83r\83\85\81[\83t\83@\83C\83\8b\96¼
871         HTML_FILE_NAME  = 'temp_preview.html';
872         //\83\81\83b\83Z\81[\83WID
873         USER_TREECLICK                                  = WM_USER + 2000;
874         USER_RESIZED            = WM_USER + 2001;
875         USER_MINIMIZED                                  = WM_USER + 2002;
876         USER_SETLINKBAR                                 = WM_USER + 2003;
877         USER_DOCUMENTCOMPLETE           = WM_USER + 2004;       ///< wParam : TWebBrowser
878     USER_TASKTRAY               = WM_USER + 2010;
879 {$R *.DFM}
880
881 procedure TGikoForm.CreateParams(var Params: TCreateParams);
882 begin
883         inherited;
884         if FormStyle in [fsNormal, fsStayOnTop] then begin
885                 if BorderStyle in [bsSingle, bsSizeable] then begin
886                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
887                         Params.WndParent := 0;
888                 end;
889         end;
890 end;
891
892 procedure TGikoForm.FormCreate(Sender: TObject);
893 const
894         TVS_NOTOOLTIPS = $0080;
895 var
896         FileName: string;
897         Style: DWORD;
898         msg: string;
899         i: Integer;
900         wp: TWindowPlacement;
901 begin
902 {$IFDEF DEBUG}
903         AllocConsole;
904         Writeln('============================================================');
905         Writeln(' \83M\83R\83i\83r\83f\83o\83b\83\83R\83\93\83\\81[\83\8b');
906         Writeln('');
907         Writeln(' \82±\82Ì\89æ\96Ê\82ð\95Â\82\82È\82¢\82Å\82­\82¾\82³\82¢\81B');
908         Writeln(' \8fI\97¹\8e\9e\82Í\81A\83M\83R\83i\83r\83E\83B\83\93\83h\83E\82ð\95Â\82\82Ä\82­\82¾\82³\82¢');
909         Writeln('============================================================');
910 {$ENDIF}
911 //try
912         Sort.SetSortDate(Now());
913         
914         FTreeType := gttNone;
915         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô
916         FStartUp := true;
917         Application.HookMainWindow(Hook);
918         FIsIgnoreResize := rtResizing;
919         //ActionList\82ÌGuoupIndex\82ð\95Û\91\82µ\82Ä\81A0\82É\83N\83\8a\83A\82·\82é\81B
920         //(\8bN\93®\8e\9e\82É\83c\81[\83\8b\83{\83^\83\93\82ÌDown\83v\83\8d\83p\83e\83B\82ð\94½\89f\82³\82¹\82é\93s\8d\87\8fãGroupIndex\82Í\90Ý\92è\82Å\82«\82È\82¢)
921         //\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
922         GetGroupIndex(GikoDM.GikoFormActionList);
923         FSearchDialog := nil;
924     FResPopupBrowser := nil;
925         CreateBrowsers(BROWSER_COUNT);
926     FIconData.uID := 0;
927
928         //\83\81\83j\83\85\81[\83t\83H\83\93\83g
929         SetMenuFont;
930
931         //\8eè\82Ì\83J\81[\83\\83\8b
932         Screen.Cursors[5] := LoadCursor(HInstance, 'GIKOHAND');
933
934         //\83A\83h\83\8c\83X\97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
935         AddressHistoryDM.ReadHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
936
937         EnabledCloseButton := True;
938
939         //\83\8a\83X\83g\83X\83^\83C\83\8b
940         ListView.ViewStyle := GikoSys.Setting.ListStyle;
941
942         //\83A\83j\83\81\83p\83l\83\8b\88Ê\92u
943         AnimePanel.Top := 0;
944         AnimePanel.Left := 0;
945
946         //\8ae\8eí\89Â\8e\8b\8fó\91Ô\82È\82Ç\90Ý\92è
947
948         //\83L\83\83\83r\83l\83b\83g
949         CabinetPanel.Width := GikoSys.Setting.CabinetWidth;
950
951         //\83\81\83b\83Z\81[\83W\83o\81[
952         GikoDM.MsgBarVisibleAction.Checked := GikoSys.Setting.MessageBarVisible;
953         GikoDM.MsgBarVisibleActionExecute(nil);
954         MessagePanel.Height := GikoSys.Setting.MessegeBarHeight;
955
956         //\83X\83e\81[\83^\83X\83o\81[
957         GikoDM.StatusBarVisibleAction.Checked := GikoSys.Setting.StatusBarVisible;
958         GikoDM.StatusBarVisibleActionExecute(nil);
959
960         //\83t\83H\83\93\83g\81E\90F\90Ý\92è
961         TreeView.Items.BeginUpdate;
962         FavoriteTreeView.Items.BeginUpdate;
963         ListView.Items.BeginUpdate;
964         try
965                 TreeView.Font.Name := GikoSys.Setting.CabinetFontName;
966                 TreeView.Font.Size := GikoSys.Setting.CabinetFontSize;
967                 TreeView.Font.Color := GikoSys.Setting.CabinetFontColor;
968                 TreeView.Color := GikoSys.Setting.CabinetBackColor;
969                 FavoriteTreeView.Font.Assign(TreeView.Font);
970                 FavoriteTreeView.Color := GikoSys.Setting.CabinetBackColor;
971
972                 ListView.Font.Name := GikoSys.Setting.ListFontName;
973                 ListView.Font.Size := GikoSys.Setting.ListFontSize;
974                 ListView.Font.Color := GikoSys.Setting.ListFontColor;
975                 ListView.Font.Style := [];
976                 if GikoSys.Setting.ListFontBold then
977                         ListView.Font.Style := [fsbold];
978                 if GikoSys.Setting.ListFontItalic then
979                         ListView.Font.Style := ListView.Font.Style + [fsitalic];
980
981                 ListViewBackGroundColor := clWhite;                                                                                             // \83f\83t\83H\83\8b\83g\82É\90Ý\92è\82µ\82½\82Ì\82¿
982                 ListViewBackGroundColor := GikoSys.Setting.ListBackColor;       // \83\86\81[\83U\92è\8b`\82É\95Ï\8dX
983                 FUseOddResOddColor := GikoSys.Setting.UseOddColorOddResNum;
984                 FOddColor := GikoSys.Setting.OddColor;
985
986         finally
987                 TreeView.Items.EndUpdate;
988                 FavoriteTreeView.Items.EndUpdate;
989                 ListView.Items.EndUpdate;
990         end;
991         //ViewNoButton.Down := GikoSys.Setting.ListViewNo;
992         GikoDM.ListNumberVisibleAction.Checked := GikoSys.Setting.ListViewNo;
993
994         //\83~\83\85\81[\83g\82Ì\8fó\91Ô\82ð\90Ý\92è
995         GikoDM.MuteAction.Checked := GikoSys.Setting.Mute;
996
997         // \83\8c\83X\95\\8e¦\94Í\88Í
998         FResRangeMenuSelect := GikoSys.ResRange;
999         case GikoSys.ResRange of
1000         Ord( grrAll ):
1001                 begin
1002                         GikoDM.AllResAction.Execute;
1003                 end;
1004         Ord( grrSelect ):
1005                 begin
1006                         SelectComboBox.Text := SelectComboBox.Items[ 1 ];
1007                         GikoDM.SelectResAction.Checked := True;
1008                 end;
1009         else
1010                 case FResRangeMenuSelect of
1011                 Ord( grrKoko ): GikoDM.OnlyKokoResAction.Checked        := True;
1012                 Ord( grrNew ):  GikoDM.OnlyNewResAction.Checked := True;
1013                 100:                    GikoDM.OnlyAHundredResAction.Checked            := True;
1014                 end;
1015         end;
1016
1017         // \83X\83\8c\83b\83h\88ê\97\97\95\\8e¦\94Í\88Í
1018         case GikoSys.Setting.ThreadRange of
1019         gtrAll:
1020                 begin
1021                         GikoDM.AllItemAction.Checked := True;
1022                         ViewType := gvtAll;
1023                 end;
1024         gtrLog:
1025                 begin
1026                         GikoDM.LogItemAction.Checked := True;
1027                         ViewType := gvtLog;
1028                 end;
1029         gtrNew:
1030                 begin
1031                         GikoDM.NewItemAction.Checked := True;
1032                         ViewType := gvtNew;
1033                 end;
1034         gtrLive:
1035                 begin
1036                         GikoDM.LiveItemAction.Checked := True;
1037                         ViewType := gvtLive;
1038                 end;
1039         gtrArch:
1040                 begin
1041                         GikoDM.ArchiveItemAction.Checked := True;
1042                         ViewType := gvtArch;
1043                 end;
1044         end;
1045
1046
1047         //\83u\83\89\83E\83U\83^\83u\83t\83H\83\93\83g
1048         BrowserTab.Font.Name := GikoSys.Setting.BrowserTabFontName;
1049         BrowserTab.Font.Size := GikoSys.Setting.BrowserTabFontSize;
1050         BrowserTab.Font.Style := [];
1051         if GikoSys.Setting.BrowserTabFontBold then
1052                 BrowserTab.Font.Style := [fsBold];
1053         if GikoSys.Setting.BrowserTabFontItalic then
1054                 BrowserTab.Font.Style := GikoForm.BrowserTab.Font.Style + [fsItalic];
1055         BrowserTab.DoubleBuffered := True;
1056         FDragWFirst := false;
1057         SetContent(BrowserNullTab);                                                                                                     //\83u\83\89\83E\83U\82ð\8bó\94\92\95\\8e¦
1058
1059         //\83u\83\89\83E\83U\83^\83u
1060         GikoDM.BrowserTabVisibleAction.Checked := GikoSys.Setting.BrowserTabVisible;
1061
1062         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
1063                 GikoDM.BrowserTabTopAction.Checked := True;
1064         end else begin
1065                 GikoDM.BrowserTabBottomAction.Checked := True;
1066         end;
1067
1068         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
1069                 GikoDM.BrowserTabTabStyleAction.Checked := True;
1070         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
1071                 GikoDM.BrowserTabButtonStyleAction.Checked := True;
1072         end else begin
1073                 GikoDM.BrowserTabFlatStyleAction.Checked := True;
1074         end;
1075
1076         //\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\8f\89\8aú\89»
1077         ProgressBar.Parent := StatusBar;
1078         ProgressBar.Top := 2;
1079         ProgressBar.Left := 0;
1080         ProgressBar.Width := StatusBar.Panels[0].Width;
1081         ProgressBar.Height := StatusBar.Height - 2;
1082         ProgressBar.Position := 0;
1083
1084         // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1085         InitializeBoardPlugIns;
1086
1087         // \83{\81[\83h\83t\83@\83C\83\8b\97ñ\8b\93(ReadFavorite \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1088         GikoSys.ListBoardFile;
1089         //\81@\98A\91±\8bN\93®\8e\9e\82É\83X\83v\83\89\83b\83V\83\85\83E\83B\83\93\83h\83E\82Ì\83\81\83\82\83\8a\82ª\95s\92è\82É
1090         try
1091         // \83X\83v\83\89\83b\83V\83\85\83E\83B\83\93\83h\83E\82Ì\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\90Ý\92è
1092                 if (SplashWindow <> nil) then begin
1093                         SplashWindow.ProgressBar.Max := Length(BBSs) * 20;
1094                 end;
1095         except
1096         end;
1097         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1098         for i := Length(BBSs) - 1 downto 0 do begin
1099                 if not BBSs[i].IsBoardFileRead then
1100                         GikoSys.ReadBoardFile(BBSs[i]);
1101
1102                 if SplashWindow <> nil then begin
1103                         SplashWindow.ProgressBar.StepBy(20);
1104                         SplashWindow.Update;
1105                 end;
1106         end;
1107
1108         //\8f\84\89ñ\83f\81[\83^\93Ç\82Ý\8d\9e\82Ý
1109         RoundList := TRoundList.Create;
1110         RoundList.LoadRoundBoardFile;
1111         RoundList.LoadRoundThreadFile;
1112
1113         //TreeView\82Ì\8e×\96\82\8fL\82¢ToolTip\82ð\94ñ\95\\8e¦
1114         Style := GetWindowLong(TreeView.Handle, GWL_STYLE);
1115         Style := Style or TVS_NOTOOLTIPS;
1116         SetWindowLong(TreeView.Handle, GWL_STYLE, Style);
1117
1118         // \83c\83\8a\81[\82ð\83\81\83C\83\93\82¾\82¯\95\\8e¦\82É\82µ\82Ä\8dÅ\91å\89»
1119         TreeView.Align := alClient;
1120         FavoriteTreeView.Align := alClient;
1121         FavoriteTreeView.Visible := False;
1122
1123         // \83\81\83j\83\85\81[\82É\92Ç\89Á
1124         SetBBSMenu;
1125
1126         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95\9c\8c³
1127         wp.length := sizeof(wp);
1128         wp.rcNormalPosition.Top := GikoSys.Setting.WindowTop;
1129         wp.rcNormalPosition.Left := GikoSys.Setting.WindowLeft;
1130         wp.rcNormalPosition.Bottom := GikoSys.Setting.WindowTop + GikoSys.Setting.WindowHeight;
1131         wp.rcNormalPosition.Right := GikoSys.Setting.WindowLeft + GikoSys.Setting.WindowWidth;
1132         wp.showCmd := SW_HIDE;
1133         SetWindowPlacement(Handle, @wp);
1134         //Self.Update;
1135
1136         if GikoSys.Setting.WindowMax then
1137                 WindowState := wsMaximized;
1138
1139         //\83M\83R\83A\83j\83\81
1140         try
1141                 FileName := GikoSys.GetAppDir + 'gikoNavi.avi';
1142                 if FileExists(FileName) then
1143                         Animate.FileName := FileName;
1144         except
1145         end;
1146
1147         //\83N\83b\83L\81[
1148         FNameCookie := '';
1149         FMailCookie := '';
1150
1151         //\83u\83\89\83E\83U\83T\83C\83Y\95Ï\8dX\82Ì\8f\89\8aú\89»
1152         FBrowserSizeHeight := GikoSys.Setting.ListHeight;
1153         FBrowserSizeWidth := GikoSys.Setting.ListWidth;
1154
1155
1156         // \83q\83X\83g\83\8a\83\8a\83X\83g(LoadHistory \82æ\82è\82à\90æ\82É\8ds\82¤\82±\82Æ)
1157         FHistoryList := THistoryList.Create;
1158
1159         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1160         FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1161         TreeView, FTreeType);
1162
1163         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1164         FavoriteDM.SetFavTreeView(FavoriteTreeView);
1165         FavoriteDM.ReadFavorite;
1166
1167         GikoDM.ArrangeAction.Checked := not (GikoSys.Setting.ListOrientation = gloVertical);
1168         GikoDM.ArrangeAction.Execute;
1169
1170         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
1171                 case GikoSys.Setting.ListWidthState of
1172                         glsMax: begin
1173                                 ViewPanel.Width := 1;
1174                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1175                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1176                         end;
1177                         glsMin: begin
1178                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1179                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1180                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1181                         end;
1182                         else begin
1183                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1184                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1185                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1186                         end;
1187                 end;
1188         end else begin
1189                 case GikoSys.Setting.ListHeightState of
1190                         glsMax: begin
1191                                 ViewPanel.Height := 1;
1192                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1193                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1194                         end;
1195                         glsMin: begin
1196                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1197                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1198                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1199                         end;
1200                         else begin
1201                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1202                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1203                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1204                         end;
1205                 end;
1206         end;
1207
1208         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
1209         CreateControlThread();
1210
1211         // \8di\8d\9e\8c\9f\8dõ\97\9a\97ð
1212         SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
1213
1214         //\83u\83\89\83E\83U\83^\83u\90Ý\92è
1215         SetBrowserTabState;
1216
1217         BrowserBoardNameLabel.Caption := '';
1218         BrowserNameLabel.Caption := '';
1219         FWorkCount := 0;
1220
1221         FTabHintIndex := -1;
1222
1223         //\83c\81[\83\8b\83o\81[Wrapable
1224         ListToolBar.Wrapable := GikoSys.Setting.ListToolBarWrapable;
1225         BrowserToolBar.Wrapable := GikoSys.Setting.BrowserToolBarWrapable;
1226
1227         MakeDefaultINIFile();
1228         //\83c\81[\83\8b\83{\83^\83\93\93Ç\82Ý\8d\9e\82Ý
1229         ReadToolBarSetting(GikoDM.GikoFormActionList, StdToolBar);
1230         ReadToolBarSetting(GikoDM.GikoFormActionList, ListToolBar);
1231         ReadToolBarSetting(GikoDM.GikoFormActionList, BrowserToolBar);
1232         SetToolBarPopup;
1233
1234         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
1235         SetSelectComboBox();
1236
1237         //\83A\83h\83\8c\83X\83o\81[
1238         AddressComboBox.TabStop := GikoSys.Setting.AddressBarTabStop;
1239
1240         //\83\8a\83\93\83N\83o\81[
1241         SetLinkBar;
1242         //\83N\81[\83\8b\83o\81[\95\9c\8c³\82ÍFormShow\82É\88Ú\93®\82µ\82½
1243
1244         //\83{\81[\83h\83t\83@\83C\83\8b\82ª\96³\82¢\8fê\8d\87\82Í\83\81\83b\83Z\81[\83W\95\\8e¦
1245         if not FileExists(GikoSys.GetBoardFileName) then begin
1246                 msg := '\82±\82Ì\83\81\83b\83Z\81[\83W\82Í\83M\83R\83i\83r\82ð\8f\89\82ß\82Ä\8eg\97p\82·\82é\82Æ\82«\82É\82P\89ñ\82¾\82¯\95\\8e¦\82³\82ê\82Ü\82·' + #13#10#13#10
1247                                  + '\82±\82ê\82©\82ç\81A\81u\82Q\82¿\82á\82ñ\82Ë\82é\81v\82Ì\83A\83h\83\8c\83X\88ê\97\97\82ð\83_\83E\83\93\83\8d\81[\83h\82µ\82Ü\82·' + #13#10
1248                                  + '\8e\9f\82É\8fo\82Ä\82­\82é\89æ\96Ê\82Å\81A\81u\8dX\90V\81v\83{\83^\83\93\82ð\89\9f\82µ\82Ä\82­\82¾\82³\82¢\81B';
1249                 MsgBox(SplashWindow.Handle, msg, '\83M\83R\83i\83r', MB_OK or MB_ICONINFORMATION);
1250                 GikoDM.NewBoardAction.Execute;
1251         end;
1252
1253         //\83L\81[\90Ý\92è\93Ç\82Ý\8d\9e\82Ý
1254         GikoSys.LoadKeySetting(GikoDM.GikoFormActionList, GikoSys.GetMainKeyFileName);
1255
1256         //\8dÅ\8fI\8f\84\89ñ\8e\9e\8aÔ
1257 //      FLastRoundTime := 0;
1258
1259         ListView.OnData := TListViewUtils.ListViewData;
1260
1261         // \8dÅ\8cã\82É\91I\91ð\82³\82ê\82½\83L\83\83\83r\83l\83b\83g\82Ì\95\9c\8c³
1262         CabinetVisible( False );
1263         if GikoSys.Setting.CabinetVisible then begin
1264                 i := CabinetSelectPopupMenu.Items.Count - 1;
1265                 if GikoSys.Setting.CabinetIndex = i - 1 then
1266                         GikoDM.CabinetHistoryAction.Execute
1267                 else if GikoSys.Setting.CabinetIndex = i then
1268                         GikoDM.CabinetFavoriteAction.Execute
1269                 else begin
1270                         if GikoSys.Setting.CabinetIndex < Length( BBSs ) then
1271                                 ShowBBSTree( BBSs[ GikoSys.Setting.CabinetIndex ] );
1272                         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô 2
1273                         FIsIgnoreResize := rtResizing;
1274                         GikoDM.CabinetBBSAction.Execute;
1275                 end;
1276         end else begin
1277                 ShowBBSTreeOld( BBSs[ 0 ] );
1278                 PostMessage( Handle, USER_TREECLICK, 0, 0 );
1279         end;
1280
1281         //\88ø\90\94\82ª\82 \82Á\82½\82ç\83X\83\8c\82ð\8aJ\82­\81i\96¢\8eæ\93¾\82È\82ç\83_\83E\83\93\83\8d\81[\83h\81j
1282         for i := 1 to ParamCount do     begin
1283                 MoveToURL(ParamStr(i));
1284         end;
1285
1286         GikoDM.RepaintStatusBar;
1287         StatusBarResize(Sender);
1288
1289         dummy1.Caption  := ItemReservPMenu.Caption;
1290         dummy1.Hint     := ItemReservPMenu.Hint;
1291
1292 {$IFDEF SPAM_FILTER_ENABLED}
1293         // \83X\83p\83\80\83t\83B\83\8b\83^\8aw\8fK\97\9a\97ð
1294         GikoSys.Bayesian.LoadFromFile( GikoSys.Setting.GetSpamFilterFileName );
1295 {$ENDIF}
1296
1297         // \83}\83E\83X\83W\83F\83X\83`\83\83\81[
1298         MouseGesture := TMouseGesture.Create;
1299         GikoSys.Setting.Gestures.LoadGesture(
1300                 GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
1301         MouseGesture.Margin := GikoSys.Setting.Gestures.Margin;
1302         MouseGesture.OnGestureStart := OnGestureStart;
1303         MouseGesture.OnGestureMove := OnGestureMove;
1304         MouseGesture.OnGestureEnd := OnGestureEnd;
1305         if GikoSys.Setting.GestureEnabled then
1306                 MouseGesture.SetHook( Handle );
1307
1308         //2ch\8c¾\8cê\93Ç\82Ý\8fo\82µ
1309         GikoSys.SetGikoMessage;
1310
1311         //\83I\81[\83g\83\8d\83O\83C\83\93
1312         if GikoSys.Setting.AutoLogin then
1313                 GikoDM.LoginAction.Execute;
1314
1315         GikoSys.Setting.BeLogin := GikoSys.Setting.BeAutoLogin;
1316
1317         //\83L\83\83\83v\83V\83\87\83\93\82ª\8fã\8f\91\82«\82³\82ê\82Ä\82µ\82Ü\82¤\82Ì\82Å\81A\82±\82±\82Å\8dÄ\90Ý\92è
1318         FavoriteAddToolButton.Caption := '\92Ç\89Á...';
1319         AntiIndivAbonMenuItem.Caption := '\8cÂ\95Ê\82 \82Ú\81`\82ñ\89ð\8f\9c';
1320
1321         //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\8f\89\8aú\89»
1322         InputAssistDM.Init(GikoSys.GetInputAssistFileName);
1323
1324     //\92u\8a·\90Ý\92è\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
1325     ReplaceDM.LoadFromFile(GikoSys.GetReplaceFileName);
1326
1327     //\83\8c\83X\83|\83b\83v\83A\83b\83v\8fÁ\8b\8e\83^\83C\83}\81[
1328     ResPopupClearTimer.Interval := GikoSys.Setting.RespopupWait;
1329
1330     // D&D\82ð\8eó\82¯\8eæ\82é
1331     DragAcceptFiles(ListView.Handle, True);
1332
1333     // \8f\89\8aú\89»\82É\8e¸\94s\82µ\82½\83\82\83W\83\85\81[\83\8b\83`\83F\83b\83N
1334     if (FavoriteDM.AbEnd) then begin
1335         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',
1336             '\8f\89\8aú\89»\88Ù\8fí');
1337         Self.Close;
1338     end;
1339
1340 end;
1341
1342 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
1343 procedure TGikoForm.SaveCoolBarSettings;
1344 begin
1345
1346         if IsIconic( Handle ) or (FIsIgnoreResize <> rtNone) then
1347                 Exit;
1348         SaveMainCoolBarSettings;
1349         SaveBoardCoolBarSettings;
1350         SaveBrowserCoolBarSettings;
1351
1352 end;
1353 procedure TGikoForm.SaveMainCoolBarSettings;
1354 var
1355         i : Integer;
1356         CoolSet : TCoolSet;
1357 begin
1358         //\83N\81[\83\8b\83o\81[\95Û\91¶(Main)
1359         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
1360                 CoolSet.FCoolID := MainCoolBar.Bands[i].ID;
1361                 CoolSet.FCoolWidth := MainCoolBar.Bands[i].Width;
1362                 CoolSet.FCoolBreak := MainCoolBar.Bands[i].Break;
1363                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
1364         end;
1365 end;
1366 procedure TGikoForm.SaveBoardCoolBarSettings;
1367 var
1368         i : Integer;
1369         CoolSet : TCoolSet;
1370 begin
1371         //\83N\81[\83\8b\83o\81[\95Û\91¶(Board)
1372         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
1373                 CoolSet.FCoolID := ListCoolBar.Bands[i].ID;
1374                 CoolSet.FCoolWidth := ListCoolBar.Bands[i].Width;
1375                 CoolSet.FCoolBreak := ListCoolBar.Bands[i].Break;
1376                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
1377         end;
1378 end;
1379 procedure TGikoForm.SaveBrowserCoolBarSettings;
1380 var
1381         i : Integer;
1382         CoolSet : TCoolSet;
1383 begin
1384         //\83N\81[\83\8b\83o\81[\95Û\91¶(Browser)
1385         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
1386                 CoolSet.FCoolID := BrowserCoolBar.Bands[i].ID;
1387                 CoolSet.FCoolWidth := BrowserCoolBar.Bands[i].Width;
1388                 CoolSet.FCoolBreak := BrowserCoolBar.Bands[i].Break;
1389                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
1390         end;
1391 end;
1392 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82©\82ç\95\9c\8c³
1393 procedure TGikoForm.LoadCoolBarSettings;
1394 var
1395         i                               : Integer;
1396         CoolSet : TCoolSet;
1397 begin
1398
1399         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Main)
1400         MainCoolBar.Bands.BeginUpdate;
1401         try
1402 //              for i := 0 to MainCoolBar.Bands.Count - 1 do begin
1403                 for i := MAIN_COOLBAND_COUNT - 1 downto 0 do begin
1404                         CoolSet := GikoSys.Setting.MainCoolSet[i];
1405                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1406                                 FIsIgnoreResize := rtNone;
1407                                 SaveCoolBarSettings;
1408                                 Exit;
1409                         end;
1410                         MainCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1411                         MainCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1412                         MainCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1413                 end;
1414         finally
1415                 MainCoolBar.Bands.EndUpdate;
1416         end;
1417
1418         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Board)
1419         ListCoolBar.Bands.BeginUpdate;
1420         try
1421 //              for i := 0 to ListCoolBar.Bands.Count - 1 do begin
1422                 for i := LIST_COOLBAND_COUNT - 1 downto 0 do begin
1423                         CoolSet := GikoSys.Setting.ListCoolSet[i];
1424                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1425                                 FIsIgnoreResize := rtNone;
1426                                 SaveCoolBarSettings;
1427                                 Exit;
1428                         end;
1429                         ListCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1430                         ListCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1431                         ListCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1432                 end;
1433         finally
1434                 ListCoolBar.Bands.EndUpdate;
1435         end;
1436
1437         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Browser)
1438         BrowserCoolBar.Bands.BeginUpdate;
1439         try
1440 //              for i := 0 to BrowserCoolBar.Bands.Count - 1 do begin
1441                 for i := BROWSER_COOLBAND_COUNT - 1 downto 0 do begin
1442                         CoolSet := GikoSys.Setting.BrowserCoolSet[i];
1443                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1444                                 FIsIgnoreResize := rtNone;
1445                                 SaveCoolBarSettings;
1446                                 Exit;
1447                         end;
1448                         BrowserCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1449                         BrowserCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1450                         BrowserCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1451                 end;
1452         finally
1453                 BrowserCoolBar.Bands.EndUpdate;
1454         end;
1455
1456 end;
1457 //
1458 procedure TGikoForm.FormShow(Sender: TObject);
1459 var
1460         item        : TThreadItem;
1461 begin
1462         if FStartUp then begin
1463                 ShowWindow(Application.Handle, SW_HIDE);
1464
1465                 //FormCreate\82Å\82â\82é\82Æ\89Â\8e\8b\90Ý\92è\82ª\94½\89f\82³\82ê\82È\82¢\8fê\8d\87\82ª\82 \82é\82Ì\82ÅFormShow\82Å\82â\82é\82±\82Æ\82É\82µ\82½
1466                 //\83c\81[\83\8b\83o\81[\95\\8e¦
1467                 GikoDM.StdToolBarVisibleAction.Checked := GikoSys.Setting.StdToolBarVisible;
1468                 GikoDM.StdToolBarVisibleActionExecute( nil );
1469                 GikoDM.AddressBarVisibleAction.Checked := GikoSys.Setting.AddressBarVisible;
1470                 GikoDM.AddressBarVisibleActionExecute( nil );
1471                 GikoDM.LinkBarVisibleAction.Checked := GikoSys.Setting.LinkBarVisible;
1472                 GikoDM.LinkBarVisibleActionExecute( nil );
1473                 GikoDM.ListToolBarVisibleAction.Checked := GikoSys.Setting.ListToolBarVisible;
1474                 GikoDM.ListToolBarVisibleActionExecute( nil );
1475                 GikoDM.ListNameBarVisibleAction.Checked := GikoSys.Setting.ListNameBarVisible;
1476                 GikoDM.ListNameBarVisibleActionExecute( nil );
1477                 GikoDM.BrowserToolBarVisibleAction.Checked := GikoSys.Setting.BrowserToolBarVisible;
1478                 GikoDM.BrowserToolBarVisibleActionExecute( nil );
1479                 GikoDM.BrowserNameBarVisibleAction.Checked := GikoSys.Setting.BrowserNameBarVisible;
1480                 GikoDM.BrowserNameBarVisibleActionExecute( nil );
1481
1482                 // CoolBar \95\9c\8c³
1483                 LoadCoolBarSettings;
1484
1485                 //\8fd\97v\81@\82±\82ê\82ª\82È\82¢\82Æ\83c\81[\83\8b\83{\83^\83\93\82Ì\8dX\90V\82ª\82¨\82©\82µ\82­\82È\82é
1486 //              ResetBandInfo( ListCoolBar, ListToolBar );
1487                 FIsIgnoreResize := rtNone;
1488
1489                 //FormCrete\82©\82ç\88Ú\93®\81B
1490                 if GikoSys.Setting.TabAutoLoadSave then begin
1491             GikoDM.TabsOpenAction.Tag := 1;
1492                         GikoDM.TabsOpenAction.Execute;
1493             GikoDM.TabsOpenAction.Tag := 0;
1494             if (GikoSys.Setting.LastCloseTabURL <> '') then begin
1495                 PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( FActiveContent.Browser ), 0 );
1496                 if ( FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
1497                         while (FActiveContent.Browser.ReadyState <> READYSTATE_COMPLETE) and
1498                                 (FActiveContent.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1499                                 Application.ProcessMessages;
1500                     end;
1501                         end;
1502                 item := BBSsFindThreadFromURL( GikoSys.Setting.LastCloseTabURL );
1503                 if (item <> nil) and (item.IsLogFile) then begin
1504                     OpenThreadItem(item, item.URL);
1505                 end;
1506                 GikoSys.Setting.LastCloseTabURL := '';
1507             end;
1508                 end;
1509
1510         //ActionList\82ÌGroupIndex\82ð\8c³\82É\96ß\82·
1511                 SetGroupIndex(GikoDM.GikoFormActionList);
1512
1513                 FStartUp := false;
1514         end;
1515 end;
1516
1517 procedure TGikoForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
1518 begin
1519 //      if GikoForm.WindowState <> wsMinimized then
1520 //              SaveCoolBarSettings;
1521         CanClose := True;
1522         if ( GikoSys.Setting.ShowDialogForEnd ) and
1523                         (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
1524                 CanClose := false;
1525                         Exit;
1526         end;
1527
1528     GikoSys.Setting.LastCloseTabURL := '';
1529         if GikoSys.Setting.TabAutoLoadSave then begin
1530                 GikoDM.TabsSaveAction.Execute;
1531         if (GetActiveContent <> nil) and
1532             (GetActiveContent.IsLogFile) then begin
1533             GikoSys.Setting.LastCloseTabURL := GetActiveContent.URL;
1534         end;
1535         end;
1536
1537         if (SearchDialog <> nil) then begin
1538                 if (SearchDialog.Visible) then begin
1539                         SearchDialog.Close;
1540                         try
1541                                 SearchDialog.Release;
1542                         except
1543                         end;
1544                         SearchDialog := nil;
1545                 end;
1546         end;
1547
1548         //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\95Â\82\82é
1549     GikoDM.CloseAllEditorAction.Execute;
1550
1551         Application.UnhookMainWindow(Hook);
1552         Application.Terminate;
1553 end;
1554
1555 procedure TGikoForm.FormDestroy(Sender: TObject);
1556 var
1557         i                               : Integer;
1558         wp                      : TWindowPlacement;
1559         tmpBool : Boolean;
1560 begin
1561         // \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\95ú
1562         try
1563         MouseGesture.Clear;
1564                 MouseGesture.UnHook;
1565         MouseGesture.Free;
1566         MouseGesture := nil;
1567         except
1568         end;
1569         try
1570                 ActiveListColumnSave;
1571         except
1572         end;
1573         try
1574                 //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
1575                 wp.length := sizeof(wp);
1576                 GetWindowPlacement(Handle, @wp);
1577                 GikoSys.Setting.WindowTop := wp.rcNormalPosition.Top;
1578                 GikoSys.Setting.WindowLeft := wp.rcNormalPosition.Left;
1579                 GikoSys.Setting.WindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
1580                 GikoSys.Setting.WindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
1581                 GikoSys.Setting.WindowMax := WindowState = wsMaximized;
1582
1583                 GikoSys.Setting.ListStyle := ListView.ViewStyle;
1584                 GikoSys.Setting.CabinetVisible := GikoDM.CabinetVisibleAction.Checked;
1585                 GikoSys.Setting.CabinetWidth := CabinetPanel.Width;
1586                 GikoSys.Setting.ListHeight := FBrowserSizeHeight;
1587                 GikoSys.Setting.ListWidth := FBrowserSizeWidth;
1588                 if GikoDM.ArrangeAction.Checked then
1589                         GikoSys.Setting.ListOrientation := gloVertical
1590                 else
1591                         GikoSys.Setting.ListOrientation := gloHorizontal;
1592                 GikoSys.Setting.MessegeBarHeight := MessagePanel.Height;
1593         except
1594         end;
1595
1596         try
1597                 // \83\8c\83X\95\\8e¦\94Í\88Í
1598                 if not GikoSys.Setting.ResRangeHold then
1599                         GikoSys.Setting.ResRange := FResRangeMenuSelect;
1600         except
1601         end;
1602         if WindowState <> wsNormal then
1603                 WindowState := wsNormal;
1604         SaveCoolBarSettings;
1605         try
1606                 GikoSys.Setting.WriteWindowSettingFile;
1607                 GikoSys.Setting.WriteNameMailSettingFile;
1608         except
1609         end;
1610         // \83\8a\83A\83\8b\83^\83C\83\80\82É\95Û\91\82³\82ê\82é\82Ì\82Å\81A\82Ü\82½\81A\83E\83B\83\93\83h\83E\83T\83C\83Y\82ª CoolBar \82æ\82è
1611         // \8f¬\82³\82­\82È\82Á\82Ä\82¢\82é\82Æ\82«\82É\95Û\91\82·\82é\82Æ\92l\82ª\8fã\8f\91\82«\82³\82ê\82Ä\82µ\82Ü\82¤\82Ì\82Å\82±\82±\82Å\82Í\95Û\91\82µ\82È\82¢
1612
1613                 // \81ªFormDestroy\92\86\82É\88Ú\93®\82µ\82½\82Ì\82Å\81A\82±\82±\82Å\95Û\91\82µ\82È\82¢\82Æ\82¢\82¯\82È\82¢\82Æ\8ev\82¤\81B\81i\82à\82\82ã\81@2004/04/09\81j
1614         // CoolBar \95Û\91
1615         //if (GikoForm.WindowState <> wsMinimized) and (GikoForm.WindowState <> wsMaximized) then
1616
1617         //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\90Ý\92è\82Ì\95Û\91
1618         InputAssistDM.SaveToFile(GikoSys.GetInputAssistFileName);
1619
1620         //\82¨\8bC\82É\93ü\82è\95Û\91
1621         try
1622                 //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é
1623         // \8f\89\8aú\89»\88Ù\8fí\8e\9e\82©\82ç\82Ì\8fI\97¹\82Å\82Í\95Û\91\82µ\82È\82¢
1624         if not (FavoriteDM.AbEnd) then begin
1625                 FavoriteDM.WriteFavorite;
1626         end;
1627                 FavoriteDM.Clear;
1628         except
1629         end;
1630         //LockWindowUpdate(Self.Handle);
1631         try
1632                 //\83^\83u\83N\83\8d\81[\83Y
1633                 tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
1634                 GikoSys.Setting.ShowDialogForAllTabClose := false;
1635                 GikoDM.AllTabCloseAction.Execute;
1636                 GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
1637         except
1638         end;
1639         try
1640                 for i := FBrowsers.Count - 1 downto 0 do begin
1641                         TWebBrowser(FBrowsers[i]).Free;
1642                 end;
1643                 FBrowsers.Clear;
1644                 FBrowsers.Capacity := 0;
1645         finally
1646                 FBrowsers.Free;
1647         end;
1648         try
1649                 if BrowserNullTab <> nil then begin
1650                         BrowserNullTab.Browser := nil;  {*BrowserNullTab\82ÌBrowser\82Í\90Ý\8cv\8e\9e\82É\93\\82è\95t\82¯\82Ä\82é\93z
1651                                                                                          *\82È\82Ì\82Å\82±\82±\82ÅFree\82³\82ê\82é\82Æ\8d¢\82é\82Ì\82Å\82Í\82¸\82µ\82Ä\82µ\82Ü\82¤\81B
1652                                                                                          *}
1653                         BrowserNullTab.Free;
1654                 end;
1655         except
1656         end;
1657
1658         try
1659                 TreeView.Items.BeginUpdate;
1660                 TreeView.Items.GetFirstNode.Free;
1661                 TreeView.Items.Clear;
1662                 TreeView.Items.EndUpdate;
1663         except
1664         end;
1665
1666         //\83A\83h\83\8c\83X\97\9a\97ð\95Û\91
1667         try
1668                 //AddressHistoryDM\82Í\8e©\93®\90\90¬\83t\83H\81[\83\80\82È\82Ì\82Å\81A\89ð\95ú\82Í\8e©\93®\93I\82É\82³\82ê\82é\81B
1669                 AddressHistoryDM.WriteHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
1670         except
1671         end;
1672
1673         //\83q\83X\83g\83\8a\83\8a\83X\83g\95Û\91
1674         try
1675                 FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1676         except
1677         end;
1678         try
1679                 try
1680                         FHistoryList.Clear;
1681                 except
1682                 end;
1683         finally
1684                 FHistoryList.Free;
1685         end;
1686
1687         //\8f\84\89ñ\83\8a\83X\83g\95Û\91¶&\94j\8aü
1688         try
1689                 RoundList.SaveRoundFile;
1690         except
1691         end;
1692         try
1693                 try
1694                         RoundList.Clear;
1695                 except
1696                 end;
1697         finally
1698                 RoundList.Free;
1699          end;
1700
1701         try
1702                 try
1703                         FControlThread.Terminate;
1704                         FControlThread.WaitFor;
1705                 except
1706                 end;
1707         finally
1708                 FControlThread.Free;
1709         end;
1710     // \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é
1711     for i := GikoForm.PlugInMenu.Count - 1 downto 0 do begin
1712                 GikoForm.PlugInMenu.items[i].Free;
1713         end;
1714     GikoForm.PlugInMenu.Clear;
1715
1716
1717         // TBBS \82Í\95Û\8e\9d\82µ\82Ä\82¢\82é TCategory, TBoard, TThreadItem \82·\82×\82Ä\82ð\8aJ\95ú\82·\82é
1718         // 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Å
1719         // BoardPluteIns \82Ì\8aJ\95ú\82æ\82è\90æ\82É\8ds\82¤\82±\82Æ
1720         for i := Length(BoardGroups) - 1 downto 0 do begin
1721                 //BoardGroups[i].Clear;
1722                 BoardGroups[i].Free;
1723         end;
1724
1725         try
1726                 for i := Length( BBSs ) - 1 downto 0 do begin
1727                         if BBSs[ i ] <> nil then
1728                                 BBSs[ i ].Free;
1729                         BBSs[ i ] := nil;
1730                 end;
1731         except
1732         end;
1733
1734         try
1735                 if FEvent <> nil then
1736                         FEvent.Free;
1737
1738         try
1739             if FResPopupBrowser <> nil then  begin
1740                 TOleControl(FResPopupBrowser).Parent := nil;
1741                 FResPopupBrowser.Free;
1742             end;
1743
1744         except
1745         end;
1746                 //Preview\94j\8aü
1747                 if FPreviewBrowser <> nil then begin
1748                         FPreviewBrowser.Free;
1749                         FPreviewBrowser := nil;
1750                 end;
1751         except
1752         end;
1753         //LockWindowUpdate(0);
1754 end;
1755
1756 // \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
1757 procedure TGikoForm.SetBBSMenu;
1758 var
1759         i                       : Integer;
1760         item    : TBBSMenuItem;
1761 begin
1762
1763         // \83\81\83j\83\85\81[\82ð\8dí\8f\9c
1764         for i := CabinetSelectPopupMenu.Items.Count - 1 downto 0 do begin
1765                 try
1766                         if CabinetSelectPopupMenu.Items[ i ] is TBBSMenuItem then begin
1767                                 CabinetSelectPopupMenu.Items[ i ].Free;
1768                                 CabinetMenu.Items[ i ].Free;
1769                                 BBSSelectPopupMenu.Items[ i ].Free;
1770                         end;
1771                 except
1772                 end;
1773         end;
1774
1775         // \83\81\83j\83\85\81[\82ð\90Ý\92è
1776         for i := Length( BBSs ) - 1 downto 0 do begin
1777                 try
1778                         item                                    := TBBSMenuItem.Create( PopupMenu );
1779                         item.Caption    := BBSs[ i ].Title;
1780                         item.Data                       := BBSs[ i ];
1781                         item.OnClick    := BBSMenuItemOnClick;
1782                         CabinetSelectPopupMenu.Items.Insert( 0, item );
1783                         item                                    := TBBSMenuItem.Create( PopupMenu );
1784                         item.Caption    := BBSs[ i ].Title;
1785                         item.Data                       := BBSs[ i ];
1786                         item.OnClick    := BBSMenuItemOnClick;
1787                         CabinetMenu.Insert( 0, item );
1788                         item                                    := TBBSMenuItem.Create( PopupMenu );
1789                         item.Caption    := BBSs[ i ].Title;
1790                         item.Data                       := BBSs[ i ];
1791                         item.OnClick    := BBSMenuItemOnClick;
1792                         BBSSelectPopupMenu.Items.Insert( 0, Item );
1793                 except
1794                 end;
1795         end;
1796
1797 end;
1798
1799 procedure TGikoForm.ReloadBBS;
1800 var
1801         i                       : Integer;
1802         tmpBool: Boolean;
1803 begin
1804     LockWindowUpdate(Self.Handle);
1805
1806         //\83^\83u\83N\83\8d\81[\83Y
1807         tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
1808         GikoSys.Setting.ShowDialogForAllTabClose := false;
1809         GikoDM.AllTabCloseAction.Execute;
1810         GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
1811         SetContent(BrowserNullTab);
1812         //TreeView\83N\83\8a\83A\81iBBS2ch.Free\82Ì\8cã\82É\83N\83\8a\83A\82·\82é\82ÆXP\83X\83^\83C\83\8b\8e\9e\82É\83G\83\89\81[\8fo\82é\81j
1813         TreeView.Items.Clear;
1814
1815         //\8f\84\89ñ\83\8a\83X\83g\95Û\91
1816         try
1817                 RoundList.SaveRoundFile;
1818         except
1819         end;
1820         //\8f\84\89ñ\83\8a\83X\83g\82ð\94j\8aü
1821         try
1822                 RoundList.Clear;
1823         except
1824         end;
1825
1826         //\97\9a\97ð\82Ì\95Û\91\82Æ\94j\8aü
1827         try
1828                 FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1829                 FHistoryList.Clear;
1830         except
1831         end;
1832
1833         //\82¨\8bC\82É\93ü\82è\82Ì\95Û\91\82Æ\94j\8aü
1834         try
1835                 FavoriteDM.WriteFavorite;
1836                 FavoriteDM.Clear;
1837         except
1838         end;
1839
1840         //\94Â\81E\83X\83\8c\81EPLUGIN\82Ì\94j\8aü
1841         for i := Length(BoardGroups) - 1 downto 0 do begin
1842                 try
1843                         BoardGroups[i].Free;
1844                 except
1845                 end;
1846         end;
1847         //BBS\94j\8aü
1848         try
1849                 for i := Length( BBSs ) - 1 downto 0 do begin
1850                         if BBSs[ i ] <> nil then
1851                                 BBSs[ i ].Free;
1852                         BBSs[ i ] := nil;
1853                 end;
1854         except
1855         end;
1856
1857         ActiveList := nil;
1858
1859         FTreeType := gttNone;
1860
1861         //============\82±\82±\82©\82ç\89º\82Å\81A\8dÄ\90¶================================//
1862
1863         // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1864         InitializeBoardPlugIns;
1865
1866         GikoSys.ListBoardFile;          //\83{\81[\83h\83t\83@\83C\83\8b\93Ç\8d\9e
1867
1868         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1869         for i := Length(BBSs) - 1 downto 0 do begin
1870                 if not BBSs[i].IsBoardFileRead then
1871                         GikoSys.ReadBoardFile(BBSs[i]);
1872         end;
1873
1874         // BBS \83\81\83j\83\85\81[\82Ì\8dX\90V
1875         SetBBSMenu;
1876
1877         ShowBBSTree( BBSs[ 0 ] );
1878
1879         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1880     FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1881         TreeView, FTreeType);
1882
1883         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1884         FavoriteDM.ReadFavorite;
1885
1886         SetLinkBar;
1887
1888         //\8f\84\89ñ\82Ì\93Ç\82Ý\8d\9e\82Ý
1889         RoundList.LoadRoundBoardFile;
1890         RoundList.LoadRoundThreadFile;
1891
1892         LockWindowUpdate(0);
1893 end;
1894
1895 {!
1896 \todo \89½\8cÌ IE 7 \82Å\82Í about:.. \82É\82È\82é\82Ì\82©
1897       (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©)
1898       \92²\8d¸\82·\82é\82±\82Æ
1899 }
1900 procedure TGikoForm.BrowserStatusTextChange(Sender: TObject; const Text: WideString);
1901 var
1902         p: TPoint;
1903         s: string;
1904         tmp2: string;
1905         URL: string;
1906         ATitle: Boolean;
1907
1908         threadItem      : TThreadItem;
1909         board                           : TBoard;
1910         Protocol, Host, Path, Document, Port, Bookmark: string;
1911
1912         wkInt: Integer;
1913         wkIntSt: Integer;
1914         wkIntTo: Integer;
1915         ActiveFileName: string;
1916         e: IHTMLElement;
1917         Ext: string;
1918         PathRec: TPathRec;
1919   Text2: string;
1920     cResPopup: TResPopupBrowser;
1921 begin
1922         // \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ª
1923   // 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è)
1924         if Pos('about:..', Text) = 1 then
1925         Text2 := 'about:blank..' + Copy( Text, Length('about:..')+1, Length(Text) )
1926   else
1927         Text2 := Text;
1928         if not( TObject(Sender) is TWebBrowser )then
1929                 Exit;
1930         try
1931                 try
1932                         if (TWebBrowser(Sender) <> nil) and (not TWebBrowser(Sender).Busy) and (Assigned(TWebBrowser(Sender).Document)) then begin
1933                                 if LowerCase(OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset) <> 'shift_jis' then begin
1934                                         OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset := 'shift_jis';
1935                                 end;
1936                         end;
1937                 except
1938                 end;
1939         finally
1940         end;
1941         if PreviewTimer.Enabled then
1942                 PreviewTimer.Enabled := False;
1943         Application.CancelHint;
1944         try
1945                 if GetActiveContent <> nil then
1946                         ActiveFileName := ChangeFileExt(ExtractFileName(GetActiveContent.FileName), '')
1947                 else
1948                         ActiveFileName := '';
1949         except
1950                 FActiveContent := nil;
1951                 Exit;
1952         end;
1953     // \91O\89ñ\82Æ\93¯\82\8fê\8d\87\8fI\97¹
1954     if (StatusBar.Panels[1].Text = Text2) then begin
1955         if Text2 = '' then begin
1956             if FResPopupBrowser <> nil then begin
1957                 if not(Sender is TResPopupBrowser) then
1958                     FResPopupBrowser.Clear
1959                 else begin
1960                     TResPopupBrowser(Sender).ChildClear;
1961                 end;
1962             end;
1963         end;
1964         Exit;
1965     end;
1966         StatusBar.Panels[1].Text := Text2;
1967
1968
1969         if FPreviewBrowser <> nil then
1970                 ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
1971
1972     if FResPopupBrowser <> nil then begin
1973         if not(Sender is TResPopupBrowser) then begin
1974             if (FResPopupBrowser.Visible) then begin
1975                 if ResPopupClearTimer.Interval > 0 then begin
1976                     ResPopupClearTimer.Enabled := True;
1977                     ResPopupClearTimer.Tag := 0;
1978                 end else begin
1979                     FResPopupBrowser.Clear;
1980                 end;
1981             end;
1982         end else begin
1983             if ResPopupClearTimer.Interval > 0 then begin
1984                 ResPopupClearTimer.Enabled := True;
1985                 ResPopupClearTimer.Tag := 1;
1986             end else begin
1987                 TResPopupBrowser(Sender).ChildClear;
1988             end;
1989         end;
1990     end;
1991     cResPopup := nil;
1992     
1993     if not(Sender is TResPopupBrowser) then
1994         if not GikoSys.Setting.UnActivePopup then
1995                 if not GikoForm.Active then
1996                         Exit;
1997
1998
1999
2000 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10
2001 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10-15
2002
2003         s := '';
2004         Ext := AnsiLowerCase(ExtractFileExt(Text2));
2005         if (Pos('http://', Text2) = 1) and (GikoSys.Setting.PreviewVisible) and
2006                         ((Ext = '.jpg') or (Ext = '.jpeg') or (Ext = '.gif') or (Ext = '.png')) then begin
2007                 if FPreviewBrowser = nil then begin
2008                         FPreviewBrowser := TPreviewBrowser.Create(Self);
2009                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
2010                         TOleControl(FPreviewBrowser).Parent := nil;
2011                 end;
2012                 FPreviewBrowser.Navigate(BLANK_HTML);//\91O\89ñ\82Ì\83v\83\8c\83r\83\85\81[\89æ\91\9c\8fÁ\8b\8e\97p
2013                 FPreviewURL := Text2;
2014                 PreviewTimer.Interval := GikoSys.Setting.PreviewWait;
2015                 PreviewTimer.Enabled := True;
2016         end else if (Pos('about:blank', Text2) = 1) or (Pos('http://', Text2) = 1) or (Pos('mailto:', Text2) = 1) then begin
2017                 if (Pos('mailto:', Text2) = 1) and (GikoSys.Setting.RespopupMailTo) then begin
2018                         s := StringReplace(Text2, 'mailto:', '', [rfIgnoreCase]);
2019                         //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g3\82Ì466\8e\81\82É\8a´\8eÓ
2020                         GetCursorPos(p);
2021                         p.x := p.x - TWebBrowser(Sender).ClientOrigin.x;
2022                         p.y := p.y - TWebBrowser(Sender).ClientOrigin.y;
2023                         e := IHTMLDocument2(TWebBrowser(Sender).Document).elementFromPoint(p.x, p.y);
2024                         if (Assigned(e)) then begin
2025                 CreateResPopupBrowser;
2026
2027                 if not(Sender is TResPopupBrowser) then begin
2028                     if (FResPopupBrowser.Visible) then begin
2029                         FResPopupBrowser.Clear;
2030                     end;
2031                 end else begin
2032                     TResPopupBrowser(Sender).ChildClear;
2033                 end;
2034
2035                 cResPopup := FResPopupBrowser.CreateNewBrowser;
2036                                 tmp2 := ZenToHan(e.Get_outerText);
2037                                 if (GikoSys.IsNumeric(tmp2)) then begin
2038                                         //\82\93\82Í\83\8c\83X\94Ô\8d\86\82Á\82Û\82¢\82Á\82·\81B
2039                                         wkIntSt := StrToInt64(tmp2);
2040                                         wkIntTo := StrToInt64(tmp2);
2041                     cResPopup.PopupType := gptThread;
2042                                         HTMLCreater.SetResPopupText(cResPopup, GetActiveContent(true), wkIntSt, wkIntTo, False, False);
2043                                 end else begin
2044                     cResPopup.PopupType := gptRaw;
2045                     cResPopup.Title := s;
2046                                 end;
2047                         end;
2048                 end else begin
2049             CreateResPopupBrowser;
2050
2051             if not(Sender is TResPopupBrowser) then begin
2052                 if (FResPopupBrowser.Visible) then begin
2053                     FResPopupBrowser.Clear;
2054                 end;
2055             end else begin
2056                 TResPopupBrowser(Sender).ChildClear;
2057             end;
2058
2059                         threadItem := GetActiveContent(true);
2060                         URL := THTMLCreate.GetRespopupURL(Text2, threadItem.URL);
2061                         PathRec := Gikosys.Parse2chURL2(URL);
2062                         if (PathRec.FNoParam) then begin
2063                                 PathRec.FSt := 1;
2064                                 PathRec.FTo := 1;
2065                         end else begin
2066                                 Gikosys.GetPopupResNumber(URL,PathRec.FSt,PathRec.FTo);
2067                         end;
2068                         GikoSys.ParseURI( URL, Protocol, Host, Path, Document, Port, Bookmark );
2069
2070                         if PathRec.FDone or (not GikoSys.Is2chHost( Host )) then begin
2071
2072                                 URL := GikoSys.GetBrowsableThreadURL( URL );
2073                                 wkIntSt := PathRec.FSt;
2074                                 wkIntTo := PathRec.FTo;
2075
2076                                 if (wkIntSt = 0) and (wkIntTo = 0) then begin
2077                                         wkIntSt := 1;
2078                                         wkIntTo := 1;
2079                                 end else if (wkIntSt = 0) and (wkIntTo > 0) then begin
2080                                         wkIntSt := wkIntTo;
2081                                 end else if (wkIntSt > 0) and (wkIntTo = 0) then begin
2082                                         wkIntTo := wkIntSt;
2083                                 end else if wkIntSt > wkIntTo then begin
2084                                         wkInt := wkIntTo;
2085                                         wkIntTo := wkIntSt;
2086                                         wkIntSt := wkInt;
2087                                 end;
2088                                 if (FActiveContent <> nil) and (FActiveContent.Thread.URL = URL) then
2089                                         ATitle := false
2090                                 else
2091                                         ATitle := true;
2092
2093                                 threadItem := BBSsFindThreadFromURL( URL );
2094
2095                                 if (threadItem = nil) and GikoSys.Is2chHost( Host ) then begin
2096                                         board := BBSs[ 0 ].FindBBSID( PathRec.FBBS );
2097                                         if board <> nil then begin
2098                                                 if not board.IsThreadDatRead then
2099                                                         GikoSys.ReadSubjectFile( board );
2100                                                 threadItem := board.FindThreadFromFileName( PathRec.FKey + '.dat' );
2101                                         end;
2102                                 end;
2103
2104                                 if threadItem <> nil then begin
2105                                         //HintData := GetThreadText(PathRec.FBBS, PathRec.FKey, wkIntSt, wkIntTo, ATitle, PathRec.FFirst);
2106                                         //URL\82Ì\8dÅ\8cã\82É/\82ª\95t\82¢\82Ä\82¢\82È\82¢\82Æ\82«\97p
2107                                         if ( IntToStr(wkIntSt) = ChangeFileExt(threadItem.FileName, '') ) then begin
2108                                                 wkIntSt := 1;
2109                                                 wkIntTo := 1;
2110                                         end;
2111                     cResPopup := FResPopupBrowser.CreateNewBrowser;
2112                     cResPopup.PopupType := gptThread;
2113                                         HTMLCreater.SetResPopupText(cResPopup, threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
2114                                 end;
2115                         end;
2116                 end;
2117         if (cResPopup <> nil) then begin
2118             ResPopupClearTimer.Enabled := False;
2119
2120             if cResPopup.PopupType = gptRaw then begin
2121                 if cResPopup.Title <> '' then begin
2122                     cResPopup.TitlePopup;
2123                 end;
2124             end else begin
2125                 if cResPopup.RawDocument <> '' then begin
2126                     cResPopup.Popup;
2127                 end else if cResPopup.Title <> '' then begin
2128                     cResPopup.TitlePopup;
2129                 end;
2130             end;
2131         end;
2132         end;
2133 end;
2134
2135 procedure TGikoForm.SetEnabledCloseButton(Enabled: Boolean);
2136 var
2137         SysMenu: HMenu;
2138 begin
2139         FEnabledCloseButton := Enabled;
2140         SysMenu := GetSystemMenu(Handle, False);
2141
2142         if Enabled then begin
2143                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
2144         end else begin
2145                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
2146         end;
2147
2148         DrawMenuBar(Handle);
2149 end;
2150
2151 procedure TGikoForm.TreeViewChanging(Sender: TObject; Node: TTreeNode;
2152         var AllowChange: Boolean);
2153 begin
2154 //\83\\81[\83g\8f\87\82ð\95Û\91\82·\82é\82æ\82¤\82É\82µ\82½\82Ì\82Å\8dí\8f\9c
2155 //      if FTreeType = gtt2ch then
2156 //              FSortIndex := -1;
2157 end;
2158
2159 procedure TGikoForm.ListViewKeyDown(Sender: TObject; var Key: Word;
2160         Shift: TShiftState);
2161 var
2162         pos     : TPoint;
2163 begin
2164         if GetActiveList is TBoard then begin
2165                 case Key of
2166                 VK_BACK:;       //      UpFolderButtonClick(Sender);
2167                 VK_SPACE:                       ListDoubleClick(Shift);
2168                 VK_RETURN:              ListClick;
2169                 VK_APPS:
2170                         begin
2171                                 if ListView.Selected <> nil then begin
2172                                         pos.X := ListView.Column[ 0 ].Width;
2173                                         pos.Y := ListView.Selected.Top;
2174                                 end else begin
2175                                         pos.X := ListView.Left;
2176                                         pos.Y := ListView.Top;
2177                                 end;
2178                                 Windows.ClientToScreen( ListView.Handle, pos );
2179                                 ListPopupMenu.Popup( pos.X, pos.Y );
2180                         end;
2181                 end;
2182         end else begin // TBBS, TCategory
2183                 case Key of
2184                 VK_BACK:;       //      UpFolderButtonClick(Sender);
2185                 VK_SPACE:                       ListClick;
2186                 VK_RETURN:              ListDoubleClick(Shift);
2187                 VK_APPS:
2188                         begin
2189                                 if ListView.Selected <> nil then begin
2190                                         pos.X := ListView.Column[ 0 ].Width;
2191                                         pos.Y := ListView.Selected.Top;
2192                                 end else begin
2193                                         pos.X := ListView.Left;
2194                                         pos.Y := ListView.Top;
2195                                 end;
2196                                 Windows.ClientToScreen( ListView.Handle, pos );
2197                                 ListPopupMenu.Popup( pos.X, pos.Y );
2198                         end;
2199                 end;
2200         end;
2201 end;
2202
2203 function TGikoForm.GetHttpState: Boolean;
2204 begin
2205         Result := FHttpState;
2206 end;
2207
2208 procedure TGikoForm.ListViewColumnClick(Sender: TObject;
2209         Column: TListColumn);
2210 var
2211         id, idx                 : Integer;
2212         orderList               : TList;
2213         vSortIndex              : Integer;
2214         vSortOrder              : Boolean;
2215 begin
2216         idx := TListViewUtils.ActiveListTrueColumn( Column ).Tag;
2217         if TObject( FActiveList ) is TBBS then begin
2218                 orderList := GikoSys.Setting.BBSColumnOrder;
2219                 vSortIndex := GikoSys.Setting.BBSSortIndex;
2220                 vSortOrder := GikoSys.Setting.BBSSortOrder;
2221         end else if TObject( FActiveList ) is TCategory then begin
2222                 orderList := GikoSys.Setting.CategoryColumnOrder;
2223                 vSortIndex := GikoSys.Setting.CategorySortIndex;
2224                 vSortOrder := GikoSys.Setting.CategorySortOrder;
2225         end else if TObject( FActiveList ) is TBoard then begin
2226                 orderList := GikoSys.Setting.BoardColumnOrder;
2227                 vSortIndex := GikoSys.Setting.BoardSortIndex;
2228                 vSortOrder := GikoSys.Setting.BoardSortOrder;
2229         end else
2230                 Exit;
2231
2232         id := Integer( orderList[ idx ] );
2233
2234
2235         if vSortIndex = id then
2236                 vSortOrder := not vSortOrder
2237         else begin
2238                 vSortOrder := id = 0;
2239         end;
2240
2241         TListViewUtils.ListViewSort(Sender, ListView, Column, GikoDM.ListNumberVisibleAction.Checked, vSortOrder);
2242 end;
2243
2244 procedure TGikoForm.MenuToolBarCustomDrawButton(Sender: TToolBar;
2245         Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);
2246 var
2247         ARect: TRect;
2248 begin
2249         DefaultDraw := True;
2250 // \82È\82º\82©\96³\8fð\8c\8f\82ÅExit\82µ\82Ä\82¢\82é
2251         Exit;
2252         DefaultDraw := False;
2253         if (cdsSelected in State) or (cdsHot in State) then begin
2254                 Sender.Canvas.Brush.Color := clHighlight;
2255                 Sender.Canvas.Font.Color := clHighlightText;
2256         end else begin
2257                 Sender.Canvas.Brush.Color := clBtnFace;
2258                 Sender.Canvas.Font.Color := clBtnText;
2259         end;
2260         ARect := Rect(Button.Left, Button.Top, Button.Left + Button.Width, Button.Top + Button.Height);
2261         Sender.Canvas.FillRect(ARect);
2262         DrawText(Sender.Canvas.Handle, PChar(Button.Caption), -1, ARect, DT_SINGLELINE or DT_VCENTER or DT_CENTER);
2263 end;
2264
2265 function TGikoForm.GetTreeNode(Data: TObject): TTreeNode;
2266 var
2267         Nodes: TTreeNodes;
2268         i: integer;
2269 begin
2270         Nodes := TreeView.Items;
2271
2272         for i := 0 to Nodes.Count - 1 do begin
2273                 if Nodes.Item[i].Data = Data then begin
2274                         Result := Nodes.Item[i];
2275                         Exit;
2276                 end;
2277         end;
2278         Result := nil;
2279 end;
2280
2281 procedure TGikoForm.BrowserBeforeNavigate2(Sender: TObject;
2282         const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
2283         Headers: OleVariant; var Cancel: WordBool);
2284 var
2285         sNo: string;
2286         p: TPoint;
2287 const
2288         kMenuName: string = 'menu:';
2289 begin
2290 {$IFDEF DEBUG}
2291         Writeln(URL);
2292 {$ENDIF}
2293         if Pos(kMenuName, URL) <> 0 then begin
2294                 sNo := Copy( URL, Pos( kMenuName, URL ) + Length( kMenuName ), Length( URL ) );
2295                 
2296                 if not GikoSys.IsNumeric(sNo) then Exit;
2297
2298                 Cancel := True;
2299                 GetCursorpos(p);
2300         KokoPopupMenu.PopupComponent := nil;
2301         if (Sender is TComponent) then
2302             KokoPopupMenu.PopupComponent := TComponent(Sender);
2303                 KokoPopupMenu.Tag := StrToInt(sNo);
2304                 KokoPopupMenu.Popup(p.x, p.y);
2305         end else if Pos('mailto', LowerCase(URL)) <> 0 then begin
2306                 Cancel := not GikoSys.Setting.OpenMailer;
2307         end;
2308
2309 end;
2310
2311 procedure TGikoForm.TreeViewCustomDraw(Sender: TCustomTreeView;
2312         const ARect: TRect; var DefaultDraw: Boolean);
2313 var
2314         NodeRect: TRect;
2315         i, j: Integer;
2316         IsBoardNode: Boolean;
2317         Cnt: Integer;
2318         CntText: string;
2319         TextWidth: Integer;
2320         TextRect: TRect;
2321         Board: TBoard;
2322         Category: TCategory;
2323         Bitmap: TBitmap;
2324         NodeWidth: Integer;
2325 begin
2326         DefaultDraw := True;
2327
2328         if FTreeType = gttHistory then Exit;
2329
2330         TreeView.Canvas.Font.Color := clBlue;
2331         IsBoardNode := False;
2332         for i := 0 to TreeView.Items.Count - 1 do begin
2333                 Cnt := 0;
2334                 if not TreeView.Items[i].IsVisible then
2335                         continue;
2336
2337                 if TObject(TreeView.Items[i].Data) is TCategory then begin
2338                         if TreeView.Items[i].Expanded then
2339                                 continue;
2340
2341                         IsBoardNode := False;
2342                         Category := TCategory(TreeView.Items[i].Data);
2343                         for j := 0 to Category.Count - 1 do begin
2344                                 Board := Category.Items[j];
2345                                 if Board <> nil then begin
2346                                         if Board.UnRead > 0 then begin
2347                                                 Cnt := 1;
2348                                                 Break;
2349                                         end;
2350                                 end;
2351                         end;
2352                         if Cnt <> 1 then
2353                                 continue;
2354                 end else if TObject(TreeView.Items[i].Data) is TBoard then begin
2355                         IsBoardNode := True;
2356                         Board := TBoard(TreeView.Items[i].Data);
2357
2358                         Cnt := Board.UnRead;
2359                         if Cnt <= 0 then
2360                                 continue;
2361                 end else
2362                         continue;
2363
2364                 Bitmap := TBitmap.Create;
2365                 try
2366                         Bitmap.Canvas.Font.Assign(TreeView.Canvas.Font);
2367                         Bitmap.Canvas.Font.Style := [fsBold];
2368                         NodeWidth := Bitmap.Canvas.TextWidth(TreeView.Items[i].Text);
2369                 finally
2370                         Bitmap.Free;
2371                 end;
2372
2373                 NodeRect := TreeView.Items[i].DisplayRect(True);
2374
2375                 if IsBoardNode then
2376                         CntText := '(' + IntToStr(Cnt) + ')'
2377                 else if Cnt = 1 then
2378                         CntText := '(+)';
2379
2380
2381                 TextWidth := TreeView.Canvas.TextWidth(CntText);
2382
2383                 TextRect := Rect(NodeRect.Left + NodeWidth + 8,
2384                                                                                  NodeRect.Top,
2385                                                                                  NodeRect.Left + NodeWidth + TextWidth + 8,
2386                                                                                  NodeRect.Bottom);
2387                 DrawText(TreeView.Canvas.Handle,
2388                                                  PChar(CntText),
2389                                                  -1,
2390                                                  TextRect,
2391                                                  DT_SINGLELINE or DT_VCENTER);
2392         end;
2393         TreeViewCustomDrawItem(nil, nil, [], DefaultDraw);
2394 end;
2395
2396 procedure TGikoForm.TreeViewCustomDrawItem(Sender: TCustomTreeView;
2397         Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
2398 var
2399         Board: TBoard;
2400         Category: TCategory;
2401         i: Integer;
2402 begin
2403         DefaultDraw := True;
2404
2405         if FTreeType = gttHistory then Exit;
2406
2407         TreeView.Canvas.Font.Style := [];
2408         if Node <> nil then begin
2409                 if TObject(Node.Data) is TCategory then begin
2410                         Category := TCategory(Node.Data);
2411                         for i := 0 to Category.Count - 1 do begin
2412                                 Board := Category.Items[i];
2413                                 if Board <> nil then begin
2414                                         if Board.UnRead > 0 then begin
2415                                                 TreeView.Canvas.Font.Style := [fsBold];
2416                                                 Break;
2417                                         end;
2418                                 end;
2419                         end;
2420                 end else if TObject(Node.Data) is TBoard then begin
2421                         Board := TBoard(Node.Data);
2422                         if Board.UnRead > 0 then
2423                                 TreeView.Canvas.Font.Style := [fsBold];
2424                 end;
2425         end;
2426 end;
2427
2428 procedure TGikoForm.TreeViewExpanded(Sender: TObject; Node: TTreeNode);
2429 begin
2430         TreeView.Invalidate;
2431
2432         if TObject(Node.Data) is TBBS then begin
2433                 TBBS(Node.Data).NodeExpand := True;
2434         end else if TObject(Node.Data) is TCategory then begin
2435                 TCategory(Node.Data).NodeExpand := True;
2436         end else if TObject(Node.Data) is TBoard then begin
2437                 TBoard(Node.Data).NodeExpand := True;
2438         end;
2439 end;
2440
2441 procedure TGikoForm.ListViewAllSelect;
2442 begin
2443         ListView.SetFocus;
2444         ListView.SelectAll;
2445 end;
2446 procedure TGikoForm.DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
2447 begin
2448         AddMessageList(Msg, nil, Icon);
2449 end;
2450 // *************************************************************************
2451 //! \83_\83E\83\93\83\8d\81[\83h\82ª\8a®\97¹\82µ\82½\82Æ\82«\82É\94­\90\82·\82é\83C\83x\83\93\83g
2452 // *************************************************************************
2453 procedure TGikoForm.DownloadEnd(Sender: TObject; Item: TDownloadItem);
2454 var
2455         ATitle: string;
2456         s: string;
2457         boardPlugIn : TBoardPlugIn;
2458         i: Integer;
2459         Res : TResRec;
2460 begin
2461         try
2462                 if Item.DownType = gdtBoard then
2463                         ATitle := Item.Board.Title
2464                 else
2465                         ATitle := Item.ThreadItem.Title;
2466                 if ATitle = '' then
2467                         ATitle := GikoSys.GetGikoMessage(gmUnKnown);
2468
2469                 if Item.State in [gdsComplete, gdsDiffComplete] then begin
2470                         //\90³\8fí\8fI\97¹
2471                         if Item.DownType = gdtBoard then begin
2472                                 //\94Â
2473                                 Item.SaveListFile;
2474                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureItiran), nil, gmiOK);
2475                                 if GetActiveList = Item.Board then begin
2476                                         FActiveList := nil;
2477                                         //\8e©\93®\83\\81[\83g\82Ì\8fê\8d\87\94Â\88ê\97\97\82Ì\83\\81[\83g\8f\87\82ð\83N\83\8a\83A\82·\82é
2478                                         if (GikoSys.Setting.AutoSortThreadList) then begin
2479                                                 GikoSys.Setting.BoardSortIndex := 0;
2480                                                 GikoSys.Setting.BoardSortOrder := True;
2481                                         end;
2482                                         Sort.SetSortDate(Now());
2483                                         SetActiveList(Item.Board);
2484                                 end;
2485                                 Item.Board.Modified := True;
2486                                 Item.Board.IsThreadDatRead := True;
2487                                 PlaySound('New');
2488                                 ListView.Refresh;
2489                         end else if Item.DownType = gdtThread then begin
2490                                 //\83X\83\8c
2491                                 Item.SaveItemFile;
2492                                 Item.ThreadItem.NewArrival := True;
2493                                 //if (Item.ThreadItem.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
2494                                 if (Item.ThreadItem.ParentBoard.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
2495                                         //boardPlugIn           := Item.ThreadItem.BoardPlugIn;
2496                                         boardPlugIn             := Item.ThreadItem.ParentBoard.BoardPlugIn;
2497                                         THTMLCreate.DivideStrLine(boardPlugIn.GetDat( DWORD( Item.ThreadItem ), 1 ), @Res);
2498                                         Item.ThreadItem.Title := Res.FTitle;
2499                                         ATitle := Item.ThreadItem.Title;
2500                                 end else if ATitle = '\81i\96¼\8fÌ\95s\96¾\81j' then begin
2501                                         THTMLCreate.DivideStrLine(GikoSys.ReadThreadFile(Item.ThreadItem.GetThreadFileName, 1), @Res);
2502                                         ATitle := Res.FTitle;
2503                                 end;
2504                                 for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
2505                                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = Item.ThreadItem then begin
2506                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
2507                                                 break;
2508                                         end;
2509                                 end;
2510                                 if GikoSys.Setting.BrowserTabVisible then begin
2511                                         if GetActiveContent = Item.ThreadItem then
2512                                                 InsertBrowserTab(Item.ThreadItem)
2513                                         else if (ListView.Selected <> nil ) and ( TObject(ListView.Selected.Data) is TThreadItem ) and ( Item.ThreadItem = TThreadItem(ListView.Selected.Data)) then
2514                                                 InsertBrowserTab(Item.ThreadItem, True)
2515                                         else
2516                                                 InsertBrowserTab(Item.ThreadItem, False);
2517
2518                                 end else begin
2519                                         if (GetActiveContent = Item.ThreadItem) or (FActiveContent = nil) or(FActiveContent.Browser = BrowserNullTab.Browser) then
2520                                                                                                 InsertBrowserTab(Item.ThreadItem);
2521                                 end;
2522
2523                                                                 Application.ProcessMessages;
2524
2525                                 if Item.State = gdsComplete then begin
2526                                         PlaySound('New');
2527                                                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureSyutoku), nil, gmiOK);
2528                                                                                 //Add by Genyakun
2529                                                                                 DiffComp := True;
2530                                 end else begin
2531                                         PlaySound('NewDiff');
2532                                                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureDiff), nil, gmiOK);
2533                                                                                 //Add by Genyakun
2534                                                                                 DiffComp := True;
2535                                 end;
2536
2537                                 //\8f\84\89ñ\82 \82è\82Ì\8fê\8d\87\81\95\82P\82O\82O\82O\92´\82Í\8f\84\89ñ\8dí\8f\9c
2538                                 if (Item.ThreadItem.Round) and (Item.ThreadItem.Count > 1000) then begin
2539                                         Item.ThreadItem.Round := False;
2540                                         //Item.ThreadItem.RoundName := '';
2541                                         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);
2542                                 end;
2543                                 TreeView.Refresh;
2544                                 //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
2545                                 if (ActiveList <> nil) and (ActiveList is TBoard) then begin
2546                                         TBoard(ActiveList).LogThreadCount := TBoard(ActiveList).GetLogThreadCount;
2547                                         TBoard(ActiveList).NewThreadCount := TBoard(ActiveList).GetNewThreadCount;
2548                                         TBoard(ActiveList).UserThreadCount:= TBoard(ActiveList).GetUserThreadCount;
2549                     //ListView\82Ì\83A\83C\83e\83\80\82Ì\8cÂ\90\94\82à\8dX\90V
2550                                         case GikoForm.ViewType of
2551                                                 gvtAll: ListView.Items.Count := TBoard(ActiveList).Count;
2552                                                 gvtLog: ListView.Items.Count := TBoard(ActiveList).LogThreadCount;
2553                                                 gvtNew: ListView.Items.Count := TBoard(ActiveList).NewThreadCount;
2554                                                 gvtArch: ListView.Items.Count := TBoard(ActiveList).ArchiveThreadCount;
2555                                                 gvtLive: ListView.Items.Count := TBoard(ActiveList).LiveThreadCount;
2556                                                 gvtUser: ListView.Items.Count := TBoard(ActiveList).UserThreadCount;
2557                                         end;
2558                                 end;
2559                                 RefreshListView(Item.ThreadItem);
2560                         end;
2561
2562                 end else if Item.State = gdsNotModify then begin
2563                         //\95Ï\8dX\83i\83V
2564 {                       if (Item.DownType = gdtThread) and (AddHistory(Item.ThreadItem)) then begin
2565                                 //SetContent(Item.ThreadItem);
2566                                 InsertBrowserTab(Item.ThreadItem);
2567                         end;}
2568                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmNotMod), nil, gmiSAD);
2569                         PlaySound('NoChange');
2570                         Screen.Cursor := crDefault;
2571                 end else if Item.State = gdsAbort then begin
2572                         //\92\86\92f
2573                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiOK);
2574                 end else if Item.State = gdsError then begin
2575                         //\83G\83\89\81[
2576                         s := Item.ErrText;
2577                         if s <> '' then
2578                                 s := ':' + s;
2579                         AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmError) + ' (' + IntToStr(Item.ResponseCode) + ')' + s, nil, gmiNG);
2580 //                      if Item.ResponseCode = 302 then
2581 //                              AddMessageList('\94Â\82ª\88Ú\93]\82µ\82½\82©\82à\82µ\82ê\82È\82¢\82Ì\82Å\94Â\8dX\90V\82ð\8ds\82Á\82Ä\82­\82¾\82³\82¢\81B', nil, gmiNG);
2582                         PlaySound('Error');
2583                 end;
2584         finally
2585                 Item.Free;
2586                 Dec(FWorkCount);
2587                 if FWorkCount < 0 then FWorkCount := 0;
2588                 if FWorkCount = 0 then begin
2589                         try
2590                                 Animate.Active := False;
2591                         finally
2592                                 Screen.Cursor := crDefault;
2593                         end;
2594                 end;
2595
2596         end;
2597 end;
2598
2599 procedure TGikoForm.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
2600 begin
2601 //      SetProgressValue(Number, 0, AWorkCountMax);
2602 //      ProgressBar.Visible := True;
2603         ProgressBar.Position := 0;
2604         ProgressBar.Max := AWorkCountMax;
2605         FDownloadTitle := AWorkTitle;
2606         StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82·';
2607         FDownloadMax := AWorkCountMax;
2608 end;
2609
2610 procedure TGikoForm.WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
2611 begin
2612         ProgressBar.Position := 0;
2613         if FDownloadMax <> 0 then
2614                 StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ª\8a®\97¹\82µ\82Ü\82µ\82½';
2615 end;
2616
2617 procedure TGikoForm.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
2618 begin
2619         ProgressBar.Position := AWorkCount;
2620 //      SetProgressValue(Number, AWorkCount);
2621         StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\92\86 (' + IntToStr(AWorkCount) + '/' + IntToStr(FDownloadMax) + ')';
2622 end;
2623
2624 procedure TGikoForm.AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
2625 var
2626         ListItem: TListItem;
2627 begin
2628         MessageListView.Items.BeginUpdate;
2629         try
2630                 ListItem := MessageListView.Items.Add;
2631                 ListItem.Caption := ACaption;
2632                 ListItem.Data := AObject;
2633                 ListItem.MakeVisible(False);
2634                 case Icon of
2635                         gmiOK:   ListItem.ImageIndex := 0;
2636                         gmiSAD: ListItem.ImageIndex := 1;
2637                         gmiNG:   ListItem.ImageIndex := 2;
2638                         gmiWhat: ListItem.ImageIndex := 3;
2639                 end;
2640         finally
2641                 MessageListView.Items.EndUpdate;
2642         end;
2643 end;
2644
2645 //! \82à\82Á\82Æ\82à\8cÃ\82¢Browser\82Ì\8aJ\95ú
2646 procedure TGikoForm.ReleaseOldestBrowser;
2647 var
2648     i: Integer;
2649 begin
2650     for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
2651         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser =
2652                 TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
2653             ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
2654             break;
2655         end;
2656     end;
2657 end;
2658
2659 function TGikoForm.InsertBrowserTab(
2660         ThreadItem      : TThreadItem;
2661         ActiveTab               : Boolean = True
2662 ) : TBrowserRecord;
2663 var
2664         i, j, idx               : Integer;
2665         favItem                 : TFavoriteThreadItem;
2666         newBrowser      : TBrowserRecord;
2667     ins : Integer;
2668 begin
2669
2670         Result := nil;
2671         if Threaditem = nil then Exit;
2672
2673         if ThreadItem.IsLogFile then begin
2674                 //\82¨\8bC\82É\93ü\82è\82Ì\91S\82Ä\8aJ\82­\82Æ\82©\82â\82é\82Æ\81A\8d¡\8aJ\82¢\82Ä\82é\83X\83\8c\82Ìbrowser\82ð\95t\82¯\91Ö\82¦\82é\8b°\82ê\82ª\82 \82é
2675                 //\8fí\82É\82S\94Ô\96Ú\82ÉActive\82Ì\83u\83\89\83E\83U\82ª\97\88\82È\82¢\82æ\82¤\82É\88Ú\93®\82³\82¹\82é
2676                 if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) and
2677                         (FActiveContent.Browser <> BrowserNullTab.Browser)then begin
2678                         j := FBrowsers.IndexOf(FActiveContent.Browser);
2679                         if j = BROWSER_COUNT - 1 then
2680                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
2681                 end;
2682                 favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title );
2683                 if not FHistoryList.AddHistory( favItem, TreeView, FTreeType ) then
2684                         favItem.Free;
2685
2686                 for i := 0 to BrowserTab.Tabs.Count - 1 do begin
2687                         if TObject(BrowserTab.Tabs.Objects[i]) is TBrowserRecord then begin
2688                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
2689                                         Result := TBrowserRecord( BrowserTab.Tabs.Objects[i] );
2690                                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = nil then begin
2691                         //\88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
2692                         ReleaseOldestBrowser;
2693                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2694                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
2695                                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
2696                                         end;
2697                                         if ActiveTab then begin
2698                                                 BrowserTab.TabIndex := i;
2699                                                         BrowserTab.OnChange(nil);
2700                                                 BrowserTab.Repaint;
2701                                         end;
2702                                         Exit;
2703                                 end;
2704                         end;
2705                 end;
2706                 idx := BrowserTab.TabIndex;
2707         newBrowser := TBrowserRecord.Create;
2708         // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
2709         ReleaseOldestBrowser;
2710         newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2711         FBrowsers.Move(BROWSER_COUNT - 1, 0);
2712         newBrowser.thread := ThreadItem;
2713         newBrowser.Repaint := true;
2714
2715                 if GikoSys.Setting.BrowserTabAppend = gtaFirst then begin
2716                         BrowserTab.Tabs.InsertObject(0, GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
2717                         if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
2718                                 DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 1 ] ) );
2719                         end;// else begin
2720                         //end;
2721                         BrowserTab.Repaint;
2722                         if ActiveTab then begin
2723                                 BrowserTab.TabIndex := 0;
2724                         end;
2725                 end else if GikoSys.Setting.BrowserTabAppend = gtaLast then begin
2726                         i := BrowserTab.Tabs.AddObject(GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
2727                         if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
2728                                 DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 0 ] ) );
2729                         end;
2730                         //end;
2731                         BrowserTab.Repaint;
2732                         if ActiveTab then begin
2733                                 if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 0) then
2734                                         BrowserTab.TabIndex := 0
2735                                 else
2736                                         BrowserTab.TabIndex := i;
2737                         end;
2738                 end else begin
2739             // \83^\83u\88Ê\92u\82ð\8eæ\93¾
2740             ins := -1;
2741             for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
2742             if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser =
2743                     TWebBrowser(FBrowsers[1]) then begin
2744                     ins := i;
2745                     break;
2746                 end;
2747             end;
2748             if GikoSys.Setting.BrowserTabAppend = gtaRight then begin
2749                 Inc(ins);
2750                     end;
2751             // \83^\83u\82ª\96³\82¢\82Æ\82«\82È\82Ç\91Î\8dô
2752             if (ins < 0) then begin
2753                 ins := 0;
2754             end;
2755                         BrowserTab.Tabs.InsertObject(ins, GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
2756                         if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
2757                 if GikoSys.Setting.BrowserTabAppend = gtaRight then begin
2758                                 DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 0 ] ) );
2759                 end else begin
2760                     DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 1 ] ) );
2761                 end;
2762                         end;
2763                         //end;
2764                         BrowserTab.Repaint;
2765                         if ActiveTab then begin
2766                                 if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 0) then
2767                                         BrowserTab.TabIndex := 0
2768                                 else
2769                                         BrowserTab.TabIndex := ins;
2770                         end;
2771         end;
2772                 Result := newBrowser;
2773                 if(ActiveTab) or (idx = -1) then begin
2774                         BrowserTab.OnChange(nil);
2775                 end;
2776         end else begin
2777                 if BrowserNullTab = nil then begin
2778                         BrowserNullTab := TBrowserRecord.Create;
2779                         BrowserNullTab.Browser := Browser;
2780                 end;
2781 //              if BrowserNullTab.thread <> ThreadItem then begin
2782 //                      BrowserNullTab.Movement := '';
2783 //              end;
2784                 BrowserNullTab.thread := ThreadItem;
2785                 Result := BrowserNullTab;
2786                 BrowserTab.TabIndex := -1;
2787                 SetContent(BrowserNullTab);
2788         end;
2789
2790         if GikoSys.Setting.URLDisplay then
2791                 AddressComboBox.Text := ThreadItem.URL;
2792
2793 end;
2794
2795 procedure TGikoForm.SetContent(inThread : TBrowserRecord);
2796 var
2797         BBSID: string;
2798         FileName: string;
2799         sTitle: string;
2800         doc: Variant;
2801         s: string;
2802         idx: Integer;
2803         ThreadItem: TThreadItem;
2804         Thread: TBrowserRecord;
2805         ThreadTitle, ThreadPTitle: string;
2806         ThreadIsLog, {ThreadUnRead,} ThreadNewArraical: boolean;
2807 begin
2808         Thread := inThread;
2809         idx := BrowserTab.TabIndex;
2810         if  (not FStartUp) and
2811         (FActiveContent <> nil) and
2812                 (FActiveContent.Thread <> Thread.Thread) and
2813                 (FActiveContent.Browser <> nil) and
2814                 (Assigned(FActiveContent.Browser.Document)) then begin
2815                 try
2816                 try
2817                         FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document).Body).ScrollTop;
2818                 except
2819                         on E: Exception do
2820                                 MsgBox(Handle, E.Message, 'SetContent[<-ScrollTop]', 0);
2821                 end;
2822                 finally
2823                 end;
2824         end;
2825         if not (Assigned(Thread)) or (Thread.Thread = nil) then begin
2826                 Thread.Browser.Navigate(BLANK_HTML);
2827                 BrowserBoardNameLabel.Caption := '';
2828                 ItemBoardImage.Picture := nil;
2829                 BrowserNameLabel.Caption := '';
2830                 ItemImage.Picture := nil;
2831         BrowserNullTab.Thread := nil;
2832                 //TOleControl(BrowserNullTab.Browser).Visible := true;
2833                 ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
2834                 FActiveContent := nil;
2835                 Exit;
2836         end     else if Thread.Browser = nil then begin
2837                 if FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then
2838                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
2839         // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
2840         ReleaseOldestBrowser;
2841                 Thread.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2842                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
2843         end;
2844
2845         ThreadTitle := Thread.Thread.Title;
2846         ThreadPTitle := Thread.Thread.ParentBoard.Title;
2847         //ThreadScrollTop := Thread.Thread.ScrollTop;
2848     if Thread.Thread.IsLogFile then  begin
2849         if not FileExists(Thread.Thread.GetThreadFileName) then begin
2850             Thread.Thread.DeleteLogFile;
2851         end;
2852     end;
2853
2854         ThreadIsLog := Thread.Thread.IsLogFile;
2855         ThreadItem := Thread.Thread;
2856         ThreadNewArraical :=  Thread.Thread.NewArrival;
2857         //ThreadUnRead := Thread.Thread.UnRead;
2858         BBSID := ThreadItem.ParentBoard.BBSID;
2859         FileName := ThreadItem.FileName;
2860
2861         if GetCapture = ListView.Handle then
2862                 ReleaseCapture;
2863
2864         Screen.Cursor := crHourGlass;
2865
2866
2867         try
2868                 if(FActiveContent <> nil) and (FActiveContent <> Thread) then begin
2869                         if (FActiveContent.Browser <> BrowserNullTab.Browser) then
2870                                 ShowWindow(FActiveContent.Browser.Handle, SW_HIDE);
2871                 end;
2872                 ShowWindow(Thread.Browser.Handle, SW_SHOW);
2873                 if (not Assigned(Thread.Browser.Document)) then begin
2874                         Thread.Browser.Navigate('about:blank');
2875                 end;
2876                 while (Thread.Browser.ReadyState <> READYSTATE_COMPLETE) and
2877                                 (Thread.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
2878                         Application.ProcessMessages;
2879                         if idx <> BrowserTab.TabIndex then begin
2880                                 Exit;
2881                         end;
2882                 end;
2883
2884                 if (Thread <> nil) and (ThreadItem <>nil) then begin
2885                         BrowserBoardNameLabel.Caption := ThreadPTitle;
2886                         ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
2887                         BrowserNameLabel.Caption := ThreadTitle;
2888                         ItemImage.Picture := nil;
2889                         if ThreadIsLog then
2890                                 if ThreadNewArraical then
2891                                         ItemImageList.GetBitmap(2, ItemImage.Picture.Bitmap)
2892                                 else
2893                                         ItemImageList.GetBitmap(0, ItemImage.Picture.Bitmap)
2894                         else
2895                                 ItemImageList.GetBitmap(1, ItemImage.Picture.Bitmap);
2896
2897                         ItemImage.Left := BrowserBoardNameLabel.Left + BrowserBoardNameLabel.Width + 8;
2898                         BrowserNameLabel.Left := ItemImage.Left + 20;
2899
2900                 end;
2901                 //ActiveContent\81@\82Ì\8dX\90V
2902                 FActiveContent := Thread;
2903
2904                 if not ThreadIsLog then begin
2905                         Self.Caption := GikoDataModule.CAPTION_NAME ;
2906                         //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\8fÁ\8b\8e
2907                         StatusBar.Panels[THREADSIZE_PANEL].Text := '';
2908                         try
2909                                 Thread.Browser.BringToFront;
2910                                 s := '<HTML><BODY><CENTER>\82±\82Ì\83X\83\8c\83b\83h\82Í\8eæ\93¾\82µ\82Ä\82¢\82Ü\82¹\82ñ</CENTER></BODY></HTML>';
2911                                 doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
2912                                 doc.open;
2913                                 doc.charset := 'Shift_JIS';
2914                                 doc.Write(s);
2915                                 doc.Close;
2916                         finally
2917                                 
2918                         end;
2919                 end else begin
2920                         Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + ThreadTitle + ']';
2921                         //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
2922                         StatusBar.Panels[THREADSIZE_PANEL].Text := Format('%6.2f kB', [ThreadItem.Size / 1024]);
2923                         StatusBar.Panels[THREADSIZE_PANEL].Width :=
2924                                 Max(StatusBar.Canvas.TextWidth(StatusBar.Panels[THREADSIZE_PANEL].Text), 70);
2925                         //Thread.Repaint\82Í\81A\83X\83L\83\93\93\99\82Ì\90Ý\92è\82ð\95Ï\8dX\82µ\82½\82Æ\82«\81AThread\82ð\83_\83E\83\93\83\8d\81[\83h\82µ\82½\82Æ\82«
2926                         //\90V\8bK\82ÉThread\82ð\8aJ\82¢\82½\82Æ\82«\82É\90^\82É\82È\82Á\82Ä\82¢\82é\81B
2927                         if Thread.Repaint then begin
2928                                 Thread.Repaint := false;
2929
2930                                 Thread.Browser.OnStatusTextChange := nil;
2931                                 LockWindowUpdate(Thread.Browser.ParentWindow);
2932                                 HTMLCreater.CreateHTML2(Thread.Browser, ThreadItem, sTitle);
2933                                 Thread.Browser.OnStatusTextChange := BrowserStatusTextChange;
2934                                 PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( Thread.Browser ), 0 );
2935                         end;
2936                 end;
2937
2938                 RefreshListView(ThreadItem);
2939         finally
2940                 Screen.Cursor := crDefault;
2941         end;
2942 end;
2943
2944 function TGikoForm.GetActiveContent(popup :Boolean = false): TThreadItem;
2945 begin
2946         try
2947                 if FActiveContent <> nil then begin
2948                         Result := FActiveContent.Thread;
2949             if (popup) and
2950                 (FResPopupBrowser <> nil) and (FResPopupBrowser.CurrentBrowser.Visible = True) then
2951                 if (FResPopupBrowser.CurrentBrowser.Thread <> nil) then begin
2952                     Result := FResPopupBrowser.CurrentBrowser.Thread;
2953                 end;
2954                 end else
2955                         Result := nil;
2956         except
2957                 Result := nil;
2958         end;
2959
2960 end;
2961
2962 procedure TGikoForm.SetActiveList(Obj: TObject);
2963 var
2964         idx     : Integer;
2965 begin
2966 //      if FActiveList <> Obj then begin
2967                 FActiveList := Obj;
2968         try
2969                         if ListView.Selected <> nil then
2970                                 idx := ListView.Selected.Index
2971                         else
2972                                 idx := -1;
2973         except
2974                 idx := -1;
2975         end;
2976                 ListView.Items.Count := 0;
2977                 ListView.Items.Clear;
2978                 ListView.Selected := nil;
2979 //      ListView.Columns.Clear;
2980                 if (FActiveContent <> nil) and (FActiveContent.Thread <> nil)
2981                         and (FActiveContent.Thread.IsLogFile) then begin
2982                         try
2983                                 Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + FActiveContent.Thread.Title + ']'
2984                         except
2985                                 on E: Exception do begin
2986                                         //\83X\83\8c\88ê\97\97DL\8cã\82È\82Ç\82ÉFActiveContent\82Ì\8e\9d\82ÂThread\82ª
2987                                         //\8dí\8f\9c\82³\82ê\82Ä\82¢\82é\8fê\8d\87\82ª\82 \82é\82Ì\82Å\82±\82±\82Ä\8f\88\97\9d\82·\82é
2988                                         ReleaseBrowser(FActiveContent);
2989                                         FActiveContent.Thread := nil;
2990                                         Self.Caption := GikoDataModule.CAPTION_NAME;
2991                                 end;
2992                         end;
2993                 end else
2994                         Self.Caption := GikoDataModule.CAPTION_NAME;
2995                 //Application.Title := CAPTION_NAME;
2996
2997 //              ActiveListColumnSave;
2998
2999                 Screen.Cursor := crHourGlass;
3000                 try
3001                         if Obj is TBBS then begin
3002                                 TListViewUtils.SetCategoryListItem(TBBS(obj), ListView, GikoDM.ListNumberVisibleAction.Checked);
3003                         end else if Obj is TCategory then begin
3004                                 TListViewUtils.SetBoardListItem(TCategory(Obj), ListView, GikoDM.ListNumberVisibleAction.Checked);
3005                         end else if Obj is TBoard then begin
3006                                 TListViewUtils.SetThreadListItem(TBoard(Obj), ListView,  GikoDM.ListNumberVisibleAction.Checked);
3007                         end;
3008                 finally
3009                         Screen.Cursor := crDefault;
3010                 end;
3011
3012                 if idx >= 0  then begin
3013                         if idx >= ListView.Items.Count then
3014                                 idx := ListView.Items.Count - 1;
3015                         ListView.ItemIndex := idx;
3016                         ListView.ItemFocused := ListView.Items.Item[ idx ];
3017                 end;
3018 //      end;
3019 end;
3020
3021
3022 //\81\9a\81\9a\83q\83\8d\83\86\83L\83\81\83\82
3023 //\82»\82Ì\82¤\82¿interface\82ð\8eg\82¤
3024 function TGikoForm.GetActiveList: TObject;
3025 begin
3026         Result := FActiveList;
3027 end;
3028
3029 procedure TGikoForm.SetListViewType(AViewType: TGikoViewType);
3030 begin
3031         SetListViewType(AViewType, '', False);
3032 end;
3033
3034 procedure TGikoForm.SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean);
3035 var
3036         Board: TBoard;
3037         i: Integer;
3038 begin
3039         for i := Length( BBSs ) - 1 downto 0 do begin
3040                 BBSs[i].SelectText := SelectText;
3041                 BBSs[i].KubetsuChk := KubetsuChk;
3042         end;
3043         ViewType := AViewType;
3044         if ActiveList is TBoard then begin
3045                 Board := TBoard(ActiveList);
3046                 case ViewType of
3047                         //gvtAll: ListView.Items.Count := Board.Count;
3048                         gvtLog: Board.LogThreadCount := Board.GetLogThreadCount;
3049                         gvtNew: Board.NewThreadCount := Board.GetNewThreadCount;
3050                         gvtArch: Board.ArchiveThreadCount := Board.GetArchiveThreadCount;
3051                         gvtLive: Board.LiveThreadCount := Board.GetLiveThreadCount;
3052                         gvtUser: Board.UserThreadCount:= Board.GetUserThreadCount;
3053
3054                 end;
3055
3056                 SetActiveList(Board);
3057         end;
3058 end;
3059
3060 procedure TGikoForm.ListViewCustomDraw(Sender: TCustomListView;
3061         const ARect: TRect; var DefaultDraw: Boolean);
3062 var
3063         s: string;
3064         p: TPoint;
3065 //      Board: TBoard;
3066 begin
3067         if ListView.Items.Count = 0 then begin
3068                 DefaultDraw := true;
3069                 ListView.Canvas.Brush.Color := ListView.Color;
3070                 ListView.Canvas.FillRect(ARect);
3071
3072                 case ViewType of
3073                         gvtAll: begin
3074                                 ListView.Canvas.Font.Color := clWindowText;
3075                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3076                         end;
3077                         gvtLog: begin
3078                                 ListView.Canvas.Font.Color := clBlue;
3079                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\83\8d\83O\97L\82è\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3080                         end;
3081                         gvtNew: begin
3082                                 ListView.Canvas.Font.Color := clGreen;
3083                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90V\92\85\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3084                         end;
3085                         gvtArch: begin
3086                                 ListView.Canvas.Font.Color := clFuchsia;
3087                                 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';
3088                         end;
3089                         gvtLive: begin
3090                                 ListView.Canvas.Font.Color := clMaroon;
3091                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90\91\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3092                         end;
3093                         gvtUser: begin
3094                                 ListView.Canvas.Font.Color := clNavy;
3095                                 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';
3096                                 if GetActiveList is TBoard then
3097                                         s := Format(s, [TBoard(GetActiveList).ParentCategory.ParenTBBS.SelectText]);
3098 //                                      SelectText]);
3099                         end;
3100                         else begin
3101                                 s := '';
3102                         end;
3103                 end;
3104
3105                 p := Point((ListView.ClientWidth div 2) - (ListView.Canvas.TextWidth(s) div 2),
3106                                                          (ListView.ClientHeight div 2) - (ListView.Canvas.TextHeight(s) div 2));
3107                 ListView.Canvas.TextOut(p.X, p.Y, s);
3108         end else begin
3109                 DefaultDraw := True;
3110         end;
3111 end;
3112
3113 procedure TGikoForm.DownloadList(Board: TBoard; ForceDownload: Boolean = False);
3114 var
3115         Item: TDownloadItem;
3116 begin
3117         if not Board.IsThreadDatRead then
3118                 GikoSys.ReadSubjectFile(Board);
3119         Item := TDownloadItem.Create;
3120         try
3121                 Item.Board := Board;
3122                 Item.DownType := gdtBoard;
3123                 Item.ForceDownload := ForceDownload;
3124                 FControlThread.AddItem(Item);
3125                 if FWorkCount = 0 then begin
3126                         try
3127                                 Animate.Active := True;
3128                         except
3129                         end;
3130                         Screen.Cursor := crAppStart;
3131                 end;
3132                 Inc(FWorkCount);
3133         finally
3134                 //Item.Free;
3135         end;
3136 end;
3137
3138 procedure TGikoForm.DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
3139 var
3140         Item: TDownloadItem;
3141 begin
3142         Item := TDownloadItem.Create;
3143         try
3144                 Item.ThreadItem := ThreadItem;
3145                 Item.DownType := gdtThread;
3146                 Item.ForceDownload := ForceDownload;
3147                 FControlThread.AddItem(Item);
3148                 if FWorkCount = 0 then begin
3149                         try
3150                                 Animate.Active := True;
3151                         except
3152                         end;
3153                         Screen.Cursor := crAppStart;
3154                 end;
3155                 Inc(FWorkCount);
3156         finally
3157 //              Item.Free;
3158         end;
3159 end;
3160
3161 procedure TGikoForm.PlaySound(SoundEventName: string);
3162 var
3163         FileName: string;
3164 begin
3165         if not GikoSys.Setting.Mute then begin
3166                 FileName := GikoSys.Setting.FindSoundFileName(SoundEventName);
3167                 if FileExists(FileName) then begin
3168                         if not sndPlaySound(PChar(FileName), SND_ASYNC or SND_NOSTOP) then begin
3169                                 sndPlaySound(nil, SND_SYNC);
3170                                 Application.ProcessMessages;
3171                                 Sleep(10);
3172                                 sndPlaySound(PChar(FileName), SND_ASYNC);
3173                         end;
3174                 end;
3175         end;
3176 end;
3177
3178 //\97\9a\97ð\82©\82ç\8dí\8f\9c
3179 procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );
3180 begin
3181     FHistoryList.DeleteHistory( threadItem, TreeView, TreeType );
3182 end;
3183
3184 procedure TGikoForm.ShowBBSTreeOld(
3185         inBBS : TBBS
3186 );
3187 var
3188         i, b            : Integer;
3189         item            : TMenuItem;
3190 begin
3191         try
3192                 FavoriteTreeView.Visible := False;
3193                 FavoriteToolBar.Hide;
3194                 TreeView.Visible := True;
3195
3196                 b := CabinetSelectPopupMenu.Items.Count - 1;
3197                 for i := 0 to b do begin
3198                         item := CabinetSelectPopupMenu.Items[ i ];
3199                         if item is TBBSMenuItem then begin
3200                                 if TBBSMenuItem( item ).Data = inBBS then begin
3201                                         item.Checked := True;
3202                                         // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
3203                                         CabinetMenu.Items[ i ].Checked := True;
3204                                         GikoSys.Setting.CabinetIndex := i;
3205                                         Continue;
3206                                 end;
3207                         end;
3208                         item.Checked := False;
3209                         // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
3210                         CabinetMenu.Items[ i ].Checked := False;
3211                 end;
3212                 CabinetSelectToolButton.Caption := inBBS.Title;
3213
3214                 GikoDM.CabinetHistoryAction.Checked := False;
3215                 GikoDM.CabinetFavoriteAction.Checked := False;
3216
3217                 if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS) then begin
3218                         FTreeType := gtt2ch;
3219                         HistoryToolBar.Hide;
3220                         FActiveBBS := inBBS;
3221                         TListViewUtils.SetBoardTreeNode(inBBS, TreeView);
3222                         TreeView.Items.GetFirstNode.Expanded := True;                           //?c???[?g?b?v???????J??
3223                         //?c???[??g?b?v?????I????
3224                         if GetActiveList = nil then
3225                                 TreeView.Selected := TreeView.Items[0]
3226                         else begin
3227                                 for i := 0 to TreeView.Items.Count - 1 do begin
3228                                         if TreeView.Items[i].Data = GetActiveList then begin
3229                                                 TreeView.Selected := TreeView.Items[i];
3230                                                 Exit;
3231                                         end;
3232                                 end;
3233                                 TreeView.Selected := TreeView.Items[0]
3234                         end;
3235                 end;
3236         except
3237         end;
3238
3239 end;
3240
3241 procedure TGikoForm.ShowBBSTree(
3242         inBBS : TBBS
3243 );
3244 var
3245         i, b            : Integer;
3246         item            : TMenuItem;
3247 begin
3248
3249         try
3250                 FavoriteTreeView.Visible := False;
3251                 FavoriteToolBar.Hide;
3252                 TreeView.Visible := True;
3253
3254                 b := CabinetSelectPopupMenu.Items.Count - 1;
3255                 for i := 0 to b do begin
3256                         item := CabinetSelectPopupMenu.Items[ i ];
3257                         if item is TBBSMenuItem then begin
3258                                 if TBBSMenuItem( item ).Data = inBBS then begin
3259                                         item.Checked := True;
3260                                         // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3261                                         CabinetMenu.Items[ i ].Checked := True;
3262                                         GikoSys.Setting.CabinetIndex := i;
3263                                         Continue;
3264                                 end;
3265                         end;
3266                         item.Checked := False;
3267                         // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3268                         CabinetMenu.Items[ i ].Checked := False;
3269                 end;
3270                 CabinetSelectToolButton.Caption := inBBS.Title;
3271
3272                 GikoDM.CabinetHistoryAction.Checked := False;
3273                 GikoDM.CabinetFavoriteAction.Checked := False;
3274
3275                 if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS)
3276                         or (not (CabinetPanel.Visible)) then begin
3277                         FTreeType := gtt2ch;
3278                         HistoryToolBar.Hide;
3279                         FActiveBBS := inBBS;
3280                         TListViewUtils.SetBoardTreeNode(inBBS, TreeView);
3281                         TreeView.Items.GetFirstNode.Expanded := True;                           //\83c\83\8a\81[\83g\83b\83v\8d\80\96Ú\82¾\82¯\82ð\8aJ\82­
3282                         //\83c\83\8a\81[\82Ì\83g\83b\83v\8d\80\96Ú\82ð\91I\91ð\82·\82é
3283                         if GetActiveList = nil then begin
3284                                 try
3285                                         TreeClick( TreeView.Items[0] );
3286                                 except
3287                                 end;
3288                         end else begin
3289                                 for i := 0 to TreeView.Items.Count - 1 do begin
3290                                         if TreeView.Items[i].Data = GetActiveList then begin
3291                                                 TreeClick( TreeView.Items[i] );
3292                                                 Exit;
3293                                         end;
3294                                 end;
3295                                 TreeClick( TreeView.Items[0] );
3296                         end;
3297                 end;
3298         except
3299         end;
3300
3301 end;
3302
3303 procedure TGikoForm.ShowHistoryTree;
3304 var
3305         i, b : Integer;
3306         item : TMenuItem;
3307 begin
3308         if CabinetPanel.Visible then begin
3309                 if FTreeType = gttHistory then begin
3310                         CabinetVisible( False );
3311                         GikoDM.CabinetHistoryAction.Checked := False;
3312                 end else begin
3313                         GikoDM.CabinetHistoryAction.Checked := True;
3314                 end;
3315         end else begin
3316                 CabinetVisible( True );
3317                 GikoDM.CabinetHistoryAction.Checked := True;
3318         end;
3319
3320         // BBS...BBS, History, Favorite
3321         GikoSys.Setting.CabinetIndex := CabinetSelectPopupMenu.Items.Count - 2;
3322
3323         FavoriteTreeView.Visible := False;
3324         TreeView.Visible := True;
3325
3326         GikoDM.CabinetBBSAction.Checked := False;
3327         GikoDM.CabinetFavoriteAction.Checked := False;
3328
3329         if FTreeType <> gttHistory then begin
3330                 b := CabinetSelectPopupMenu.Items.Count - 1;
3331                 for i := 0 to b do begin
3332                         item := CabinetSelectPopupMenu.Items[ i ];
3333                         if item is TBBSMenuItem then begin
3334                                 item.Checked := False;
3335                                 // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3336                                 CabinetMenu.Items[ i ].Checked := False;
3337                         end;
3338                 end;
3339
3340                 FTreeType := gttHistory;
3341                 HistoryToolBar.Show;
3342                 FavoriteToolBar.Hide;
3343         FHistoryList.SetTreeNode( TreeView );
3344                 CabinetSelectToolButton.Caption := '\97\9a\97ð\83\8a\83X\83g';
3345         end;
3346 end;
3347
3348 procedure TGikoForm.SelectTreeNode(Item: TObject; CallEvent: Boolean);
3349 var
3350         ChangeEvent: TTVChangedEvent;
3351         ChangingEvent: TTVChangingEvent;
3352         i: Integer;
3353         bbs : TBBS;
3354 begin
3355         if Item is TCategory then
3356                 bbs := TCategory( Item ).ParenTBBS
3357         else if Item is TBoard then
3358                 bbs := TBoard( Item ).ParentCategory.ParenTBBS
3359         else
3360                 bbs := nil;
3361
3362         if (FTreeType = gtt2ch) and (FActiveBBS = bbs) then begin
3363                 if Item <> FActiveList then begin
3364                         ChangeEvent := nil;
3365                         ChangingEvent := nil;
3366
3367                         if not CallEvent then begin
3368                                 ChangeEvent := TreeView.OnChange;
3369                                 ChangingEvent := TreeView.OnChanging;
3370                         end;
3371                         try
3372                                 if not CallEvent then begin
3373                                         TreeView.OnChange := nil;
3374                                         TreeView.OnChanging := nil;
3375                                 end;
3376                                 //Application.ProcessMessages;
3377                                 for i := 0 to TreeView.Items.Count - 1 do begin
3378                                         if TreeView.Items[i].Data = Item then begin
3379                                                 TreeView.Items[i].Selected := True;
3380                                                 if CallEvent then
3381                                                         TreeClick(TreeView.Items[i]);
3382                                                 Break;
3383                                         end;
3384                                 end;
3385                                 //Application.ProcessMessages;
3386                         finally
3387                                 if not CallEvent then begin
3388                                         TreeView.OnChange := ChangeEvent;
3389                                         TreeView.OnChanging := ChangingEvent;
3390                                 end;
3391                         end;
3392                 end;
3393         end else begin
3394                 if Item <> FActiveList then begin
3395                         ActiveListColumnSave;
3396                         if (Item is TBBS) or (Item is TCategory) then begin
3397                                 ListView.Columns.Clear;
3398                                 SetActiveList( Item );
3399                         end else if Item is TBoard then begin
3400                                 if not TBoard( Item ).IsThreadDatRead then begin
3401                                         Screen.Cursor := crHourGlass;
3402                                         try
3403                                                 if not TBoard( Item ).IsThreadDatRead then
3404                                                         GikoSys.ReadSubjectFile(TBoard( Item ));
3405                                         finally
3406                                                 Screen.Cursor := crDefault;
3407                                         end;
3408                                 end;
3409                                 Sort.SetSortDate(Now());
3410                                 SetActiveList( Item );
3411                         end;
3412                 end;
3413         end;
3414
3415         if Item is TBoard then begin // not TCategory
3416                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3417                         if GikoSys.Setting.ListWidthState = glsMax then begin
3418                                 GikoDM.BrowserMinAction.Execute;
3419                                 if GikoForm.Visible then
3420                                         ListView.SetFocus;
3421                         end;
3422                 end else begin
3423                         if GikoSys.Setting.ListHeightState = glsMax then begin
3424                                 GikoDM.BrowserMinAction.Execute;
3425                                 if GikoForm.Visible then
3426                                         ListView.SetFocus;
3427                         end;
3428                 end;
3429         end;
3430 end;
3431
3432 procedure TGikoForm.ListViewMouseDown(Sender: TObject;
3433         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
3434 var
3435         listItem                : TListItem;
3436         threadItem      : TThreadItem;
3437         pos                                     : TPoint;
3438 //      t: Cardinal;
3439 begin
3440         case Button of
3441         mbMiddle:
3442                 begin
3443                         if not (GetActiveList is TBoard) then Exit;
3444                         listItem := ListView.GetItemAt( X, Y );
3445                         if listItem = nil then Exit;
3446                         if not (TObject(listItem.Data) is TThreadItem) then Exit;
3447
3448                         threadItem := TThreadItem(ListItem.Data);
3449                         InsertBrowserTab(threadItem, False);
3450                         if threadItem.IsLogFile then
3451                                 ListView.UpdateItems(listItem.Index, listItem.Index);
3452                 end;
3453         mbLeft:
3454                 begin
3455                         //\82±\82±\82ÅDblClick\8fE\82í\82È\82¢\82Æ\81AClick\83C\83x\83\93\83g\82ª\97D\90æ\82µ\82Ä\8bN\82«\82Ä\82µ\82Ü\82¤\82Ì\82Å
3456                         if (ssDouble in Shift) then
3457                                 ListDoubleClick(Shift)
3458                         else
3459                                 ListClick;
3460                 end;
3461         mbRight:
3462                 begin
3463                         pos.X := X;
3464                         pos.Y := Y;
3465                         Windows.ClientToScreen( ListView.Handle, pos );
3466                         ListPopupMenu.Popup( pos.X, pos.Y );
3467                 end;
3468         end;
3469
3470 end;
3471
3472 procedure TGikoForm.ListClick;
3473 var
3474         ListItem: TListItem;
3475         ThreadItem: TThreadItem;
3476 begin
3477         if ListView.SelCount <> 1 then Exit;
3478         ListItem := ListView.Selected;
3479         if ListItem = nil then Exit;
3480         if not (TObject(ListItem.Data) is TThreadItem) then Exit;
3481
3482         ThreadItem := TThreadItem(ListItem.Data);
3483         if ThreadItem.IsLogFile then begin
3484                 InsertBrowserTab(ThreadItem);
3485                 ListView.UpdateItems(ListItem.Index, ListItem.Index);
3486         end else begin
3487                 InsertBrowserTab(ThreadItem);
3488         end;
3489
3490         if GikoSys.Setting.BrowserAutoMaximize = gbmClick then begin
3491                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3492                         if GikoSys.Setting.ListWidthState = glsMin then begin
3493                                 GikoDM.BrowserMaxAndFocusAction.Execute;
3494                         end;
3495                 end else begin
3496                         if GikoSys.Setting.ListHeightState = glsMin then begin
3497                                 GikoDM.BrowserMaxAndFocusAction.Execute;
3498                         end;
3499                 end;
3500         end;
3501 end;
3502
3503 procedure TGikoForm.ListDoubleClick(Shift: TShiftState);
3504 var
3505         ThreadItem: TThreadItem;
3506         shiftDown: Boolean;
3507 begin
3508         shiftDown := (ssShift in Shift);
3509
3510         if ListView.Selected = nil then Exit;
3511
3512         if TObject(ListView.Selected.Data) is TCategory then begin
3513                 SelectTreeNode(ListView.Selected.Data, True);
3514         end else if TObject(ListView.Selected.Data) is TBoard then begin
3515                 SelectTreeNode(ListView.Selected.Data, True)
3516         end else if TObject(ListView.Selected.Data) is TThreadItem then begin
3517                 Application.ProcessMessages;
3518                 ThreadItem := TThreadItem(ListView.Selected.Data);
3519                 DownloadContent(ThreadItem, shiftDown);
3520
3521                 if GikoSys.Setting.BrowserAutoMaximize = gbmDoubleClick then begin
3522                         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3523                                 if GikoSys.Setting.ListWidthState = glsMin then begin
3524                                         GikoDM.BrowserMaxAction.Execute;
3525                                         GikoDM.SetFocusForBrowserAction.Execute;
3526                                 end;
3527                         end else begin
3528                                 if GikoSys.Setting.ListHeightState = glsMin then begin
3529                                         GikoDM.BrowserMaxAction.Execute;
3530                                         GikoDM.SetFocusForBrowserAction.Execute;
3531                                 end;
3532                         end;
3533                 end;
3534         end;
3535 end;
3536
3537 procedure TGikoForm.BrowserMovement(const AName: string);
3538 begin
3539         // Access Violation \82ª\8bN\82«\82é\8e\96\82ª\82 \82é\82Ì\82Å\8d¡\8cã\97v\83`\83F\83b\83N
3540         if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
3541                 and (FActiveContent <> nil) then begin
3542                 FActiveContent.Move(AName);
3543         end;
3544 end;
3545 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
3546 procedure TGikoForm.BrowserMovement(scroll: Integer);
3547 begin
3548         if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
3549                 and (FActiveContent <> nil) then begin
3550                 FActiveContent.Move(scroll);
3551         end;
3552 end;
3553 procedure TGikoForm.TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
3554 begin
3555         if TObject(Node.Data) is TBBS then begin
3556                 TBBS(Node.Data).NodeExpand := False;
3557         end else if TObject(Node.Data) is TCategory then begin
3558                 TCategory(Node.Data).NodeExpand := False;
3559         end else if TObject(Node.Data) is TBoard then begin
3560                 TBoard(Node.Data).NodeExpand := False;
3561         end;
3562         if (TreeView.Selected <> nil) and (TreeView.Selected = Node) then begin
3563         TreeClick(TreeView.Selected);
3564         end;
3565 end;
3566
3567 procedure TGikoForm.MessageListViewResize(Sender: TObject);
3568 begin
3569 //      MessageListView.Column[0].Width := MessageListView.ClientWidth - 16;
3570 end;
3571 procedure       TGikoForm.CabinetVisible( isVisible : Boolean );
3572 begin
3573         TreeSplitter.Visible := isVisible;
3574         CabinetPanel.Visible := isVisible;
3575         GikoDM.CabinetVisibleAction.Checked := isVisible;
3576 end;
3577
3578 procedure TGikoForm.SelectListItem(List: TList);
3579 var
3580         TmpListItem: TListItem;
3581 begin
3582         List.Clear;
3583         List.Capacity := 0;
3584         TmpListItem := ListView.Selected;
3585         while TmpListItem <> nil do begin
3586                 List.Add(TmpListItem.Data);
3587                 TmpListItem := ListView.GetNextItem(TmpListItem, sdAll, [isSelected]);
3588         end;
3589
3590 end;
3591
3592 procedure TGikoForm.FormResize(Sender: TObject);
3593 begin
3594
3595         MessageListView.Column[0].Width := MessageListView.ClientWidth - 32;
3596         MainCoolBar.Width := TopPanel.Width - TopRightPanel.Width;
3597
3598         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3599                 if GikoSys.Setting.ListWidthState = glsMin then begin
3600                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
3601                         ViewPanel.Width := ThreadMainPanel.Width - 80;
3602                 end;
3603         end else begin
3604                 if GikoSys.Setting.ListHeightState = glsMin then begin
3605                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
3606                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
3607                 end;
3608         end;
3609
3610         FIsIgnoreResize := rtResizing;
3611         PostMessage( Handle, USER_RESIZED, 0, 0 );
3612
3613
3614 end;
3615
3616 procedure TGikoForm.DeleteTab(BrowserRecord: TBrowserRecord);
3617 var
3618         i: Integer;
3619 begin
3620         FTabHintIndex := -1;
3621         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3622                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]) = BrowserRecord then begin
3623             DeleteTab(i, BrowserTab.TabIndex);
3624                         Break;
3625                 end;
3626         end;
3627 end;
3628 procedure TGikoForm.DeleteTab(ThreadItem: TThreadItem);
3629 var
3630         i: Integer;
3631 begin
3632         FTabHintIndex := -1;
3633         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3634                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
3635             DeleteTab(i, BrowserTab.TabIndex);
3636                         Break;
3637                 end;
3638         end;
3639 end;
3640 procedure TGikoForm.DeleteTab(index, selectIndex: Integer);
3641 var
3642     doc: Variant;
3643     j: Integer;
3644 begin
3645     try
3646         if TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser <> nil then begin
3647             doc := TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser.Document;
3648             TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.ScrollTop := doc.Body.ScrollTop;
3649         end;
3650     except
3651         TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.ScrollTop := 0;
3652     end;
3653     if(FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[index])) then
3654         FActiveContent := nil;
3655     if TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser <> nil then begin
3656         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser);
3657         if j <> -1 then
3658             FBrowsers.Move(j, BROWSER_COUNT - 1);
3659     end;
3660     BrowserTab.Tabs.BeginUpdate;
3661     try
3662         GikoSys.Setting.LastCloseTabURL :=
3663             TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.URL;
3664         TBrowserRecord(BrowserTab.Tabs.Objects[index]).Free;
3665         if ( BrowserTab.Tabs.Count - 1 = index ) and
3666             ( BrowserTab.TabRect(index).Left
3667                 <= BrowserTab.DisplayRect.Left ) then begin
3668             BrowserTab.ScrollTabs(-1);
3669         end;
3670         BrowserTab.Tabs.Delete(index);
3671         if selectIndex > index then begin
3672             BrowserTab.TabIndex := selectIndex - 1;
3673         end else begin
3674             if BrowserTab.Tabs.Count -1 >= selectIndex then
3675                 BrowserTab.TabIndex := selectIndex
3676             else
3677                 BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
3678         end;
3679     finally
3680         BrowserTab.Tabs.EndUpdate;
3681     end;
3682     if BrowserTab.Tabs.Count = 0 then begin
3683         BrowserNullTab.Thread := nil;
3684     end;
3685     if(BrowserTab.TabIndex <> -1) and
3686         ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
3687         // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
3688         ReleaseOldestBrowser;
3689
3690         TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
3691              :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3692         TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
3693         FBrowsers.Move(BROWSER_COUNT - 1, 0);
3694     end;
3695
3696     if( FActiveContent = nil) then
3697         BrowserTab.OnChange(nil);
3698 end;
3699 function TGikoForm.Hook(var Message: TMessage): Boolean;
3700 begin
3701         //\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Ì
3702         //\83\81\83j\83\85\81[\82Ì\83V\83\87\81[\83g\83J\83b\83g\83L\81[\82ª\83T\83u\83\81\83j\83\85\81[\82©\82ç\93ü\97Í\82³\82ê\82é\82Ì\82ð\89ñ\94ð
3703         Result := False;
3704         case Message.Msg of
3705         CM_APPKEYDOWN:
3706                 Result := True;         //\83V\83\87\81[\83g\83J\83b\83g\83L\81[\96³\8cø
3707         CM_APPSYSCOMMAND:
3708                 Result := True;  // \83A\83N\83Z\83\89\83\8c\81[\83^\82ð\96³\8cø\82É\82·\82é
3709         end;
3710 end;
3711
3712 procedure TGikoForm.ListPopupMenuPopup(Sender: TObject);
3713 var
3714     bBoard, bCategory : Boolean;
3715 begin
3716     bBoard := (GetActiveList is TBoard);
3717     bCategory := (GetActiveList is TCategory);
3718         ItemRoundPMenu.Visible := bBoard;
3719         ItemReservPMenu.Visible := bBoard;
3720         LPMSep01.Visible := bBoard;
3721         ListRoundPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
3722         ListReservPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
3723         LPMSep02.Visible := bCategory or bBoard;
3724         KidokuPMenu.Visible := bBoard;
3725         MidokuPMenu.Visible := bBoard;
3726         UrlCopyPMenu.Visible := bCategory or bBoard;
3727         NameUrlCopyPMenu.Visible := bCategory or bBoard;
3728         AllSelectPMenu.Visible := bCategory or bBoard;
3729         LPMSep05.Visible := bCategory or bBoard;
3730         DeletePMenu.Visible := bBoard;
3731         LPMSep06.Visible := bCategory or bBoard;
3732         BoardFavoriteAddMenu.Visible := bCategory;
3733         ThreadFavoriteAddMenu.Visible := bBoard;
3734     SaveThreadFile.Visible := bBoard;
3735         AddRoundNameMenu(ItemReservPMenu);
3736         AddRoundNameMenu(ListReservPMenu);
3737 end;
3738
3739 procedure TGikoForm.TreePopupMenuPopup(Sender: TObject);
3740 begin
3741         FClickNode := TreeView.Selected;
3742         if FClickNode = nil then begin
3743                 TreeSelectThreadPupupMenu.Visible := False;
3744                 TreeSelectBoardPupupMenu.Visible := False;
3745                 TPMSep01.Visible := False;
3746                 TreeSelectURLPupupMenu.Visible := False;
3747                 TreeSelectNamePupupMenu.Visible := False;
3748                 TreeSelectNameURLPupupMenu.Visible := False;
3749                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3750                 TreeSelectLogDeleteSeparator.Visible := False;
3751                 TreeSelectLogDeletePopupMenu.Visible := False;
3752         end else if TObject(FClickNode.Data) is TBoard then begin
3753                 TreeSelectThreadPupupMenu.Visible := False;
3754                 TreeSelectBoardPupupMenu.Visible := True;
3755                 TPMSep01.Visible := True;
3756                 TreeSelectURLPupupMenu.Visible := True;
3757                 TreeSelectNamePupupMenu.Visible := True;
3758                 TreeSelectNameURLPupupMenu.Visible := True;
3759                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3760                 TreeSelectLogDeleteSeparator.Visible := False;
3761                 TreeSelectLogDeletePopupMenu.Visible := False;
3762         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
3763                 TreeSelectThreadPupupMenu.Visible := False;
3764                 TreeSelectBoardPupupMenu.Visible := True;
3765                 TPMSep01.Visible := True;
3766                 TreeSelectURLPupupMenu.Visible := True;
3767                 TreeSelectNamePupupMenu.Visible := True;
3768                 TreeSelectNameURLPupupMenu.Visible := True;
3769                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3770                 TreeSelectLogDeleteSeparator.Visible := False;
3771                 TreeSelectLogDeletePopupMenu.Visible := False;
3772         end else if (TObject(FClickNode.Data) is TThreadItem) then begin
3773                 TreeSelectThreadPupupMenu.Visible := True;
3774                 TreeSelectBoardPupupMenu.Visible := False;
3775                 TPMSep01.Visible := True;
3776                 TreeSelectURLPupupMenu.Visible := True;
3777                 TreeSelectNamePupupMenu.Visible := True;
3778                 TreeSelectNameURLPupupMenu.Visible := True;
3779                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3780                 TreeSelectLogDeleteSeparator.Visible := True;
3781                 TreeSelectLogDeletePopupMenu.Visible := True;
3782         end else if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
3783                 TreeSelectThreadPupupMenu.Visible := True;
3784                 TreeSelectBoardPupupMenu.Visible := False;
3785                 TPMSep01.Visible := True;
3786                 TreeSelectURLPupupMenu.Visible := True;
3787                 TreeSelectNamePupupMenu.Visible := True;
3788                 TreeSelectNameURLPupupMenu.Visible := True;
3789                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3790                 TreeSelectLogDeleteSeparator.Visible := True;
3791                 TreeSelectLogDeletePopupMenu.Visible := True;
3792         end else if (TObject(FClickNode.Data) is TCategory) then begin
3793                 TreeSelectThreadPupupMenu.Visible := False;
3794                 TreeSelectBoardPupupMenu.Visible := False;
3795                 TPMSep01.Visible := False;
3796                 TreeSelectURLPupupMenu.Visible := False;
3797                 TreeSelectNamePupupMenu.Visible := True;
3798                 TreeSelectNameURLPupupMenu.Visible := False;
3799                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3800                 TreeSelectLogDeleteSeparator.Visible := False;
3801                 TreeSelectLogDeletePopupMenu.Visible := False;
3802         end else if FClickNode.IsFirstNode then begin
3803                 TreeSelectThreadPupupMenu.Visible := False;
3804                 TreeSelectBoardPupupMenu.Visible := False;
3805                 TPMSep01.Visible := False;
3806                 TreeSelectURLPupupMenu.Visible := False;
3807                 TreeSelectNamePupupMenu.Visible := True;
3808                 TreeSelectNameURLPupupMenu.Visible := False;
3809                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3810                 TreeSelectLogDeleteSeparator.Visible := False;
3811                 TreeSelectLogDeletePopupMenu.Visible := False;
3812         end else begin
3813                 TreeSelectThreadPupupMenu.Visible := False;
3814                 TreeSelectBoardPupupMenu.Visible := False;
3815                 TPMSep01.Visible := False;
3816                 TreeSelectURLPupupMenu.Visible := False;
3817                 TreeSelectNamePupupMenu.Visible := False;
3818                 TreeSelectNameURLPupupMenu.Visible := False;
3819                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3820                 TreeSelectLogDeleteSeparator.Visible := False;
3821                 TreeSelectLogDeletePopupMenu.Visible := False;
3822         end;
3823 end;
3824
3825 procedure TGikoForm.BrowserNewWindow2(Sender: TObject;
3826         var ppDisp: IDispatch; var Cancel: WordBool);
3827 var
3828         Text: string;
3829         Html: string;
3830         URL: string;
3831         idx: Integer;
3832         wkIntSt: Integer;
3833         wkIntTo: Integer;
3834     BNum, BRes: string;
3835     threadItem: TThreadItem;
3836     aElement : IHTMLElement;
3837 begin
3838 {$IFDEF DEBUG}
3839         Writeln(IntToStr(Integer(ppDisp)));
3840 {$ENDIF}
3841         Cancel := True;
3842     aElement := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement;
3843         if ( aElement <> nil) then begin
3844                 Text := aElement.Get_outerText;
3845                 Html := aElement.Get_outerHTML;
3846                 if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
3847                         or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
3848                         if GikoSys.Setting.ResAnchorJamp then begin
3849
3850                                 Text := ZenToHan(Trim(Text));
3851
3852                                 if(AnsiPos('>>', Text) = 1) then begin
3853                                         //Text := Copy(Text, 3, Length(Text) - 2);
3854                                         Delete(Text, 1, 2);
3855                                 end else begin
3856                                         //Text := Copy(Text, 2, Length(Text) - 1);
3857                                         Delete(Text, 1, 1);
3858                                 end;
3859
3860                                 if AnsiPos('-', Text) <> 0 then begin
3861                                         wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
3862                                         Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
3863                                         wkIntTo := StrToIntDef(Text, 0);
3864                                         if wkIntTo < wkIntSt then
3865                                                 wkIntSt := wkIntTo;
3866                                 end else begin
3867                                         wkIntSt := StrToIntDef(Text, 0);
3868                                 end;
3869
3870                                 if wkIntSt <> 0 then begin
3871                         FActiveContent.IDAnchorPopup('');
3872                     MoveHisotryManager.pushItem(FActiveContent);
3873                     if (Sender is TResPopupBrowser) then begin
3874                         TResPopupBrowser(Sender).ChildClear;
3875                         OpenThreadItem(
3876                             GetActiveContent(true),
3877                             GetActiveContent(true).URL + '&st=' +
3878                                  IntToStr(wkIntSt) + '&to=' + IntToStr(wkIntSt));
3879                     end else begin
3880                                         BrowserMovement(IntToStr(wkIntSt));
3881                     end;
3882                 end;
3883                         end;
3884                 end else begin
3885             ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
3886
3887                         URL := GikoSys.GetHRefText(Html);
3888                         URL := GikoSys.HTMLDecode(URL);
3889             if AnsiPos('BE:', URL) = 1 then begin
3890                                 BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
3891                                 BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
3892                 threadItem := FActiveContent.Thread;
3893                 if threadItem = nil then Exit;
3894                 URL := BE_PHP_URL + BNum + '&u=d'
3895                         + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
3896             end;
3897
3898                         if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
3899                                 ( AnsiPos('ftp://', URL) = 1) then begin
3900                                 //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
3901                                 if GikoSys.Setting.LinkAddAddressBar then begin
3902                                         idx := AddressComboBox.Items.IndexOf(URL);
3903                                         if idx = -1 then begin
3904                                                 AddressComboBox.Items.Insert(0, URL);
3905                                                 if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
3906                                                         AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
3907                                         end else begin
3908                                                 AddressComboBox.Items.Delete(idx);
3909                                                 AddressComboBox.Items.Insert(0, URL);
3910                                         end;
3911                                 end;
3912                 if (Sender is TResPopupBrowser) then begin
3913                     TResPopupBrowser(Sender).ChildClear
3914                 end;
3915
3916                 MoveHisotryManager.pushItem(FActiveContent);
3917                                 MoveToURL( URL );
3918                         end;
3919                 end;
3920     end;
3921
3922 end;
3923
3924 procedure TGikoForm.ListSplitterMoved(Sender: TObject);
3925 begin
3926         if Mouse.Capture <> 0 then
3927                 Exit;
3928         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3929                 if (ViewPanel.Width > 1) and (ViewPanel.Width <= (ThreadMainPanel.Width - 80)) then
3930                         FBrowserSizeWidth := ViewPanel.Width;
3931         end else begin
3932                 if (ViewPanel.Height > 1) and (ViewPanel.Height <= (ThreadMainPanel.Height - BrowserCoolBar.Height)) then
3933                         FBrowserSizeHeight := ViewPanel.Height;
3934         end;
3935         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3936                 if ViewPanel.Width < 2 then begin
3937                         ViewPanel.Width := 1;
3938                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3939                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3940                         GikoSys.Setting.ListWidthState := glsMax;
3941                 end else if ViewPanel.Width > (ThreadMainPanel.Width - 80) then begin
3942                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3943                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3944                         GikoSys.Setting.ListWidthState := glsMin;
3945                 end else begin
3946                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3947                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3948                         GikoSys.Setting.ListWidthState := glsNormal;
3949                 end;
3950         end else begin
3951                 if ViewPanel.Height < 2 then begin
3952                         ViewPanel.Height := 1;
3953                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3954                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3955                         GikoSys.Setting.ListHeightState := glsMax;
3956                 end else if ViewPanel.Height > (ThreadMainPanel.Height - BrowserCoolBar.Height - 7) then begin
3957                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3958                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3959                         GikoSys.Setting.ListHeightState := glsMin;
3960                 end else begin
3961                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3962                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3963                         GikoSys.Setting.ListHeightState := glsNormal;
3964                 end;
3965         end;
3966 {       if (Mouse.Capture = 0) and (ViewPanel.Height > 1) and (not ArrangeAction.Checked) then
3967                 FBrowserSizeHeight := ViewPanel.Height
3968         else if (Mouse.Capture = 0) and (ViewPanel.Width > 1) and (ArrangeAction.Checked) then
3969                 FBrowserSizeWidth := ViewPanel.Width;}
3970 end;
3971
3972 procedure TGikoForm.BrowserTabChange(Sender: TObject);
3973 var
3974         j: Integer;
3975         idx: Integer;
3976 begin
3977         BrowserTab.Tabs.BeginUpdate;
3978         try
3979                 if not BrowserTab.Dragging then begin
3980                         FTabHintIndex := -1;
3981                         BrowserTab.Hint := '';
3982                         idx := BrowserTab.TabIndex;
3983                         if idx = -1 then begin
3984                                 SetContent(BrowserNullTab);
3985
3986                         end else if(BrowserTab.Tabs.Objects[idx] <> nil) and (BrowserTab.Tabs.Objects[idx] is TBrowserRecord) then begin
3987                                 if TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser <> nil then begin
3988                                         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser);
3989                                         if j <> -1 then
3990                                                 FBrowsers.Move(j ,0);
3991                                 end else begin
3992                                         if( FActiveContent <> nil ) and (FActiveContent.Browser <> nil) and
3993                                                 (FActiveContent.Browser <> BrowserNullTab.Browser) and
3994                                                 (FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
3995                                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
3996
3997                     // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
3998                     ReleaseOldestBrowser;
3999
4000                                         TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
4001                                         TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Repaint := true;
4002                                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
4003                                 end;
4004                                 MoveWindow(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser.Handle, 0, 0, BrowserPanel.Width, BrowserPanel.Height, false);
4005                                 TOleControl(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser).BringToFront;
4006                                 SetContent(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
4007
4008                                 if (GikoSys.Setting.URLDisplay) and (GetActiveContent <> nil) then
4009                                         AddressComboBox.Text := GetActiveContent.URL;
4010
4011                                 if ((TreeView.Visible) and (TreeView.Focused)) or ((FavoriteTreeView.Visible) and (FavoriteTreeView.Focused)) or
4012                                         (ListView.Focused) or (SelectComboBox.Focused) or (AddressComboBox.Focused)
4013                                 then
4014                                 else
4015                                         GikoDM.SetFocusForBrowserAction.Execute;
4016                         end;
4017                 end;
4018         finally
4019                 BrowserTab.Tabs.EndUpdate;
4020         end;
4021 end;
4022
4023
4024 procedure TGikoForm.BrowserTabMouseDown(Sender: TObject;
4025         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
4026 var
4027         p: TPoint;
4028         p2: TPoint;
4029         idx: Integer;
4030 begin
4031         if Button = mbMiddle then begin
4032                 // \83}\83E\83X\92\86\83{\83^\83\93
4033                 GetCursorPos(p);
4034                 p2 := p;
4035                 p := BrowserTab.ScreenToClient(p);
4036                 idx := BrowserTab.IndexOfTabAt(p.X, p.Y);
4037                 if idx <> -1 then
4038                         DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
4039         end else if Button = mbLeft then begin
4040                 FDragWFirst := true;
4041                 FMouseDownPos.X := X;
4042                 FMouseDownPos.Y := Y;
4043         end;
4044
4045 end;
4046
4047 procedure TGikoForm.SetBrowserTabState;
4048 var
4049         CoolBand: TCoolBand;
4050 begin
4051         BrowserBottomPanel.AutoSize := False;
4052         if GikoSys.Setting.BrowserTabVisible then begin
4053                 BrowserTab.Hide;
4054                 BrowserTab.Tabs.BeginUpdate;
4055                 try
4056                         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
4057                                 BrowserTab.Style := tsTabs;
4058                                 if GikoSys.Setting.BrowserTabPosition = gtpTop then
4059                                         BrowserTab.TabPosition := tpTop
4060                                 else
4061                                         BrowserTab.TabPosition := tpBottom;
4062                         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
4063                                 BrowserTab.TabPosition := tpTop;
4064                                 BrowserTab.Style := tsButtons;
4065                         end else begin
4066                                 BrowserTab.TabPosition := tpTop;
4067                                 BrowserTab.Style := tsFlatButtons
4068                         end;
4069
4070                         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
4071                                 BrowserTab.Parent := BrowserTabToolBar;
4072                                 BrowserBottomPanel.Hide;
4073                                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4074                                 if CoolBand <> nil then
4075                                         CoolBand.Visible := True;
4076                         end else begin
4077                                 BrowserTab.Parent := BrowserBottomPanel;
4078                                 BrowserTab.Top := 0;
4079                                 BrowserTab.Left := 0;
4080                                 BrowserBottomPanel.Show;
4081                                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4082                                 if CoolBand <> nil then
4083                                         CoolBand.Visible := False;
4084                         end;
4085                 finally
4086                         BrowserTab.Tabs.EndUpdate;
4087                         BrowserTab.Show;
4088                 end;
4089         end else begin
4090                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4091                 if CoolBand <> nil then
4092                         CoolBand.Visible := False;
4093                 BrowserBottomPanel.Visible := False;
4094                 GikoDM.AllTabCloseAction.Execute;
4095         end;
4096 end;
4097
4098 procedure TGikoForm.BrowserTabDragOver(Sender, Source: TObject; X,
4099         Y: Integer; State: TDragState; var Accept: Boolean);
4100 var
4101         idx: Integer;
4102 begin
4103         idx := BrowserTab.IndexOfTabAt(X, Y);
4104         Accept := (Source = BrowserTab) and (BrowserTab.TabIndex <> idx);
4105 end;
4106
4107 procedure TGikoForm.BrowserTabDragDrop(Sender, Source: TObject; X,
4108         Y: Integer);
4109 var
4110         idx: Integer;
4111 begin
4112     FDragWFirst := False;
4113         idx := BrowserTab.IndexOfTabAt(X, Y);
4114         if idx <> -1 then
4115                 BrowserTab.Tabs.Move(BrowserTab.TabIndex, idx);
4116 end;
4117
4118 procedure TGikoForm.BrowserTabMouseMove(Sender: TObject;
4119         Shift: TShiftState; X, Y: Integer);
4120 var
4121         TabIdx: Integer;
4122         ThreadItem: TThreadItem;
4123 begin
4124
4125         TabIdx := BrowserTab.IndexOfTabAt(x, y);
4126
4127         if ( ssLeft in Shift ) then begin
4128         if (FDragWFirst) then begin
4129                         BrowserTab.EndDrag(false);
4130                         BrowserTab.BeginDrag(false, DandD_THRESHOLD);
4131         end;
4132         end else begin
4133                 BrowserTab.EndDrag(false);
4134                 FDragWFirst := false;
4135         end;
4136         
4137         if (FTabHintIndex <> TabIdx) and (TabIdx <> -1) then begin
4138                 Application.CancelHint;
4139                 ThreadItem := TBrowserRecord(BrowserTab.Tabs.Objects[TabIdx]).Thread;
4140                 if ThreadItem.Title <> BrowserTab.Tabs[TabIdx] then begin
4141                         BrowserTab.Hint := ThreadItem.Title;
4142                         Application.ShowHint := True;
4143                 end else begin
4144                         BrowserTab.Hint := '';
4145                         Application.ShowHint := True;
4146                 end;
4147                 FTabHintIndex := TabIdx;
4148         end;
4149
4150 end;
4151
4152 procedure TGikoForm.BrowserDocumentComplete(Sender: TObject;
4153         const pDisp: IDispatch; var URL: OleVariant);
4154 var
4155         FDispHtmlDocument: DispHTMLDocument;
4156         BrowserRecord :TBrowserRecord;
4157         i :Integer;
4158         doc                                     : Variant;
4159         threadItem      : TThreadItem;
4160 begin
4161         if TObject(Sender) is TWebBrowser then begin
4162                 BrowserRecord := nil;
4163                 if TWebBrowser(Sender) <> Browser then begin
4164                         for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
4165                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(Sender) then begin
4166                                                 BrowserRecord := TBrowserRecord(BrowserTab.Tabs.Objects[i]);
4167                                                 break;
4168                                 end;
4169                         end;
4170                         if BrowserRecord <> nil then begin
4171                                 if BrowserRecord.Event <> nil then
4172                                         BrowserRecord.Event.Free;
4173                                 FDispHtmlDocument := Idispatch(OleVariant(BrowserRecord.Browser.ControlInterface).Document) as DispHTMLDocument;
4174                                 BrowserRecord.Event := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4175                                 BrowserRecord.Event.OnContextMenu := OnDocumentContextMenu;
4176                                 BrowserRecord.Event.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4177                         end;
4178                 end else begin
4179                         if GetActiveContent <> nil then begin
4180                                 FDispHtmlDocument := Idispatch(OleVariant(Browser.ControlInterface).Document) as DispHTMLDocument;
4181                                 if FEvent <> nil then
4182                                         FEvent.Free;
4183                                 FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4184                                 FEvent.OnContextMenu := OnDocumentContextMenu;
4185                                 FEvent.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4186                         end else begin
4187                                 if FEvent <> nil then begin
4188                                         FEvent.Free;
4189                                         FEvent := nil;
4190                                 end;
4191                         end;
4192
4193                 end;
4194
4195                 if (BrowserRecord <> nil) and
4196                          Assigned( BrowserRecord.Thread ) then begin
4197                         threadItem := BrowserRecord.Thread;
4198
4199                         if (threadItem.JumpAddress > 0) then begin
4200                                 if threadItem.UnRead then begin
4201                                         threadItem.UnRead := False;
4202                                         TreeView.Refresh;
4203                                         RefreshListView(threadItem);
4204                                 end;
4205                                 // \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®
4206                                 //if (StrToIntDef(BrowserRecord.Movement, 0) <= BrowserRecord.Thread.Count) then begin
4207                                 if (threadItem.JumpAddress <= BrowserRecord.Thread.Count) then begin
4208                                         BrowserRecord.Move(IntToStr(threadItem.JumpAddress));
4209                                         threadItem.JumpAddress := 0;
4210                                 end else begin
4211                                         BrowserRecord.Move(IntToStr(BrowserRecord.Thread.Count));
4212                                 end;
4213
4214                         end else if threadItem.UnRead then begin
4215                                 threadItem.UnRead := False;
4216                                 TreeView.Refresh;
4217                                 BrowserRecord.Move('new');
4218                                 RefreshListView(threadItem);
4219                         end else if threadItem.ScrollTop <> 0 then begin
4220                                 try
4221                                         doc := Idispatch( OleVariant( BrowserRecord.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4222                                         doc.Body.ScrollTop := threadItem.ScrollTop;
4223                                 except
4224                                         on E: Exception do
4225                                                 MsgBox(Handle, E.Message, 'SetContent[ScrollTop<-]', 0);
4226                                 end;
4227                         end;
4228                 end;
4229         end;
4230         LockWindowUpdate(0);
4231 end;
4232
4233 procedure TGikoForm.RoundNamePopupMenuPopup(Sender: TObject);
4234 begin
4235         AddRoundNameMenu(RoundNamePopupMenu.Items);
4236 end;
4237
4238 procedure TGikoForm.AddRoundNameMenu(MenuItem: TMenuItem);
4239 var
4240         i: Integer;
4241         Item: TMenuItem;
4242 begin
4243         MenuItem.Clear;
4244         Item := TMenuItem.Create(Self);
4245         Item.Caption := '\90V\82µ\82¢\96¼\91O\82Å\8f\84\89ñ\97\\96ñ(&N)...';
4246         Item.OnClick := GikoDM.SelectNewRoundNameExecute;
4247         MenuItem.Add(Item);
4248         Item := TMenuItem.Create(Self);
4249         Item.Caption := '\8f\84\89ñ\83\8a\83X\83g\82©\82ç\8dí\8f\9c(&D)';
4250         Item.OnClick := GikoDM.SelectDeleteRoundExecute;
4251         MenuItem.Add(Item);
4252         Item := TMenuItem.Create(Self);
4253         Item.Caption := '-';
4254         MenuItem.Add(Item);
4255         for i := 0 to RoundList.RoundNameList.Count - 1 do begin
4256                 Item := TMenuItem.Create(Self);
4257                 Item.Caption := RoundList.RoundNameList[i];
4258                 Item.OnClick := SetSelectRoundName;
4259                 MenuItem.Add(Item);
4260         end;
4261 end;
4262
4263 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string);
4264 var
4265         threadItem : TThreadItem;
4266 begin
4267         if ParentName <> 'dummy1' then begin
4268                 SetSelectItemRound(RoundFlag, RoundName);
4269         end else begin
4270                 threadItem := GetActiveContent;
4271                 if threadItem <> nil then begin
4272                         threadItem.RoundName := RoundName;
4273                         if RoundFlag then
4274                                 RoundList.RoundNameList.Add(RoundName);
4275                         threadItem.Round := RoundFlag;
4276                 end;
4277         end;
4278 end;
4279
4280 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string);
4281 var
4282         i{, idx}: Integer;
4283         List: TList;
4284 begin
4285         List := TList.Create;
4286         try
4287                 SelectListItem(List);
4288                 for i := 0 to List.Count - 1 do begin
4289                         if TObject(List[i]) is TBoard then begin
4290                                 TBoard(List[i]).RoundName := RoundName;
4291                                 if RoundFlag then
4292                                         RoundList.RoundNameList.Add(RoundName);
4293                                 TBoard(List[i]).Round := RoundFlag;
4294                         end else if TObject(List[i]) is TThreadItem then begin
4295                                 if TThreadItem(List[i]).IsLogFile then begin
4296                                         TThreadItem(List[i]).RoundName := RoundName;
4297                                         if RoundFlag then
4298                                                 RoundList.RoundNameList.Add(RoundName);
4299                                         TThreadItem(List[i]).Round := RoundFlag;
4300                                 end;
4301                         end;
4302                 end;
4303         finally
4304                 List.Free;
4305         end;
4306 end;
4307
4308 procedure TGikoForm.SetSelectRoundName(Sender: TObject);
4309 var
4310         MenuItem: TMenuItem;
4311 begin
4312         if Sender is TMenuItem then begin
4313                 MenuItem := TMenuItem(Sender);
4314                 SetSelectItemRound(True, StripHotKey(MenuItem.Caption), TMenuItem(Sender).Parent.Name);
4315                 ListView.Refresh;
4316         end;
4317 end;
4318
4319 function TGikoForm.GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
4320 var
4321         i: Integer;
4322 begin
4323         Result := nil;
4324         if CoolBar = nil then
4325                 Exit;
4326         for i := 0 to CoolBar.Bands.Count - 1 do begin
4327                 if CoolBar.Bands[i].Control = Control then begin
4328                         Result := CoolBar.Bands[i];
4329                         Exit;
4330                 end;
4331         end;
4332 end;
4333
4334 procedure TGikoForm.BrowserTabToolBarResize(Sender: TObject);
4335 begin
4336         if BrowserTab.Parent = BrowserTabToolBar then
4337                 BrowserTab.Width := BrowserTabToolBar.Width;
4338 end;
4339
4340 procedure TGikoForm.WMSettingChange(var Message: TWMWinIniChange);
4341 begin
4342         SetMenuFont;
4343 end;
4344
4345 procedure TGikoForm.SetMenuFont;
4346 begin
4347 //      GikoSys.MenuFont(MenuToolBar.Font);
4348 //      MenuToolBar.Buttons[0].AutoSize := False;
4349 //      MenuToolBar.Buttons[0].AutoSize := True;
4350 //      MenuToolBar.Font.Color := clMenuText;
4351         GikoSys.MenuFont(MainCoolBar.Font);
4352         MenuToolBar.Buttons[0].AutoSize := False;
4353         MenuToolBar.Buttons[0].AutoSize := True;
4354         MainCoolBar.AutoSize := False;
4355         MainCoolBar.AutoSize := True;
4356         GikoSys.MenuFont(ListCoolBar.Font);
4357         GikoSys.MenuFont(BrowserCoolBar.Font);
4358 //      MenuToolBar.Font.Color := clMenuText;
4359 end;
4360
4361 procedure TGikoForm.FavoriteMenuClick(Sender: TObject);
4362 var
4363         NewMenu: TMenuItem;
4364 begin
4365         if FavoriteDM.Modified then begin
4366                 FavoriteMenu.Clear;
4367
4368                 //\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á
4369                 NewMenu := TMenuItem.Create(MainMenu);
4370                 NewMenu.Action := GikoDM.FavoriteAddAction;
4371                 FavoriteMenu.Add(NewMenu);
4372                 //\82¨\8bC\82É\93ü\82è\82Ì\90®\97\9d
4373                 NewMenu := TMenuItem.Create(FavoriteMenu);
4374                 NewMenu.Action := GikoDM.FavoriteArrangeAction;
4375                 FavoriteMenu.Add(NewMenu);
4376                 //\83Z\83p\83\8c\81[\83^
4377                 FavoriteMenu.InsertNewLineAfter(NewMenu);
4378                 CreateFavMenu(FavoriteDM.TreeView.Items.GetFirstNode, FavoriteMenu);
4379                 FavoriteDM.Modified := false;
4380         end;
4381 end;
4382
4383 procedure TGikoForm.CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
4384 var
4385         i: Integer;
4386         NewMenu: array of TMenuItem;
4387 begin
4388         SetLength(NewMenu, Node.Count);
4389         Node := Node.getFirstChild;
4390         i := 0;
4391         while ( Node <> nil ) do begin
4392                 NewMenu[i] := TFavoriteMenuItem.Create(nil);
4393                 NewMenu[i].AutoHotkeys := maAutomatic;
4394                 NewMenu[i].Caption := CustomStringReplace(Node.Text, '&', '&&');
4395                 TFavoriteMenuItem(NewMenu[i]).Data := Node.Data;
4396
4397                 if TObject(Node.Data) is TFavoriteFolder then begin
4398                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
4399                         CreateFavMenu(Node, NewMenu[i]);
4400                 end else if TObject(Node.Data) is TFavoriteBoardItem then begin
4401                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
4402                         NewMenu[i].OnClick := FavoriteClick;
4403                 end else if TObject(Node.Data) is TFavoriteThreadItem then begin
4404                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
4405                         NewMenu[i].OnClick := FavoriteClick;
4406                 end;
4407         Inc(i);
4408                 Node := Node.getNextSibling;
4409         end;
4410         MenuItem.Add(NewMenu);
4411 end;
4412
4413 procedure TGikoForm.ShowFavoriteAddDialog( Item : TObject );
4414 const
4415         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';
4416         TitleAdd: String =  '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á';
4417 var
4418         Dlg                     : TFavoriteAddDialog;
4419         ItemURL : string;
4420         Data            : Pointer;
4421         Node            : TTreeNode;
4422 begin
4423
4424         if Item is TFavoriteBoardItem then
4425                 Item := TFavoriteBoardItem( Item ).Item
4426         else if Item is TFavoriteThreadItem then
4427                 Item := TFavoriteThreadItem( Item ).Item;
4428
4429         Node := FavoriteTreeView.Items.GetFirstNode;
4430         if Item is TBoard then begin
4431                 ItemURL := TBoard( Item ).URL;
4432                 while Node <> nil do begin
4433                         Data := Node.Data;
4434                         if TObject( Data ) is TFavoriteBoardItem then begin
4435                                 if ItemURL = TFavoriteBoardItem( Data ).URL then begin
4436                                         if Application.MessageBox(PChar(MsgAdd) , PChar(TitleAdd), MB_YESNO ) = IDNO then
4437                                                 Exit;
4438                                         Break;
4439                                 end;
4440                         end;
4441                         Node := Node.GetNext;
4442                 end;
4443                 Dlg := TFavoriteAddDialog.Create(Self);
4444                 try
4445                         Dlg.SetBoard( TBoard( Item ) );
4446                         Dlg.ShowModal;
4447                 finally
4448                         Dlg.Release;
4449                 end;
4450         end else if Item is TThreadItem then begin
4451                 ItemURL := TThreadItem( Item ).URL;
4452                 while Node <> nil do begin
4453                         Data := Node.Data;
4454                         if TObject( Data ) is TFavoriteThreadItem then begin
4455                                 if ItemURL = TFavoriteThreadItem( Data ).URL then begin
4456                                         if Application.MessageBox( PChar(MsgAdd), PChar(TitleAdd), MB_YESNO ) = IDNO then
4457                                                 Exit;
4458                                         Break;
4459                                 end;
4460                         end;
4461                         Node := Node.GetNext;
4462                 end;
4463                 Dlg := TFavoriteAddDialog.Create(Self);
4464                 try
4465                         Dlg.SetThreadItem( TThreadItem( Item ) );
4466                         Dlg.ShowModal;
4467                 finally
4468                         Dlg.Release;
4469                 end;
4470         end;
4471
4472         SetLinkBar;
4473 end;
4474
4475 procedure TGikoForm.FavoriteClick(Sender: TObject);
4476 begin
4477         FavoriteClick( Sender, True );
4478 end;
4479
4480 procedure TGikoForm.FavoriteClick(Sender: TObject; ActiveTab: Boolean);
4481 var
4482         Board: TBoard;
4483         ThreadItem: TThreadItem;
4484         FavBoard: TFavoriteBoardItem;
4485         FavThread: TFavoriteThreadItem;
4486         Item: TObject;
4487 begin
4488 //      Item := nil;
4489         if Sender is TFavoriteMenuItem then
4490                 Item := TFavoriteMenuItem(Sender).Data
4491         else if Sender is TLinkToolButton then
4492                 Item := TLinkToolButton(Sender).Data
4493         else if Sender is TTreeNode then
4494                 Item := TTreeNode( Sender ).Data
4495         else
4496                 Exit;
4497
4498         if TObject(Item) is TFavoriteBoardItem then begin
4499                 FavBoard := TFavoriteBoardItem(Item);
4500                 Board := FavBoard.Item;
4501                 if Board <> nil then begin
4502                         if (FTreeType = gtt2ch) and (FActiveBBS <> Board.ParentCategory.ParenTBBS) then
4503                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4504                         SelectTreeNode(Board, True);
4505                 end;
4506         end else if TObject(Item) is TFavoriteThreadItem then begin
4507                 FavThread := TFavoriteThreadItem(Item);
4508                 ThreadItem := FavThread.Item;
4509                 if ThreadItem = nil then
4510                         Exit;
4511
4512                 InsertBrowserTab(ThreadItem, ActiveTab);
4513
4514                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
4515                         if GikoSys.Setting.ListWidthState = glsMin then begin
4516                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4517                         end;
4518                 end else begin
4519                         if GikoSys.Setting.ListHeightState = glsMin then begin
4520                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4521                         end;
4522                 end;
4523         end;
4524 end;
4525
4526 procedure TGikoForm.BBSMenuItemOnClick(
4527         Sender  : TObject
4528 );
4529 begin
4530
4531         if Sender is TBBSMenuItem then
4532                 ShowBBSTree( TBBSMenuItem( Sender ).Data );
4533
4534 end;
4535
4536 procedure TGikoForm.MainCoolBarResize(Sender: TObject);
4537 begin
4538         TopPanel.Height := Max(MainCoolBar.Height, AnimePanel.Height);
4539
4540 end;
4541 //! \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é)
4542 procedure TGikoForm.OpenThreadItem(Thread: TThreadItem; URL: String);
4543 var
4544         stRes, edRes : Int64;
4545         browserRec : TBrowserRecord;
4546         threadNumber : String;
4547         doc : Variant;
4548 begin
4549         stRes := 0;
4550         edRes := 0;
4551         Thread.JumpAddress := 0;
4552         // \83^\83u\82ð\90\90¬
4553         browserRec := InsertBrowserTab(Thread);
4554         if (browserRec <> nil) then begin
4555                 // JUMP\82·\82×\82«\83\8c\83X\94Ô\8d\86\82ª\82 \82é\82©\83`\83F\83b\83N\82·\82é
4556                 threadNumber := ChangeFileExt(Thread.FileName, '');
4557                 GikoSys.GetPopupResNumber( URL, stRes, edRes );
4558                 // \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
4559                 if (StrToInt64(threadNumber) = stRes) then begin
4560                         if not (AnsiEndsText(threadNumber + '/' + threadNumber, URL))
4561                                 and (Pos('&st=' + threadNumber , URL) = 0) then begin
4562                                 stRes := 0;
4563                         end;
4564                 end;
4565                 if ( stRes > 0 ) then begin
4566                         Thread.JumpAddress := stRes;
4567                 end;
4568                 // \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é
4569                 if (not Thread.IsLogFile) or (stRes > Thread.Count) then begin
4570                         DownloadContent(Thread);
4571                 end else if (not browserRec.Repaint) and (stRes > 0) then begin
4572                         browserRec.Move(IntToStr(stRes));
4573                         Thread.JumpAddress := 0;
4574                         try
4575                                 doc := Idispatch( OleVariant( browserRec.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4576                                 Thread.ScrollTop := doc.Body.ScrollTop;
4577                         except
4578                         end;
4579                 end;
4580         end;
4581 end;
4582
4583 procedure TGikoForm.MoveToURL(const inURL: string);
4584 var
4585         protocol, host, path, document, port, bookmark : string;
4586         URL, protocol2, host2, path2, document2, port2, bookmark2 : string;
4587         tmp1, tmp2: string;
4588         BBSID, BBSKey: string;
4589         {tmpBoard,} Board: TBoard;
4590         ThreadItem: TThreadItem;
4591         i, bi                                   : Integer;
4592         boardURL                        : string;
4593         tmpThread                       : TThreadItem;
4594         shiftDown                       : Boolean;
4595         ctrlDown                        : Boolean;
4596 begin
4597
4598         GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
4599         GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey );
4600
4601
4602         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
4603         ctrlDown        := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
4604         if shiftDown then begin
4605                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4606                 Exit;
4607         end else if ctrlDown then begin
4608                 GikoSys.OpenBrowser(inURL, gbtIE);
4609                 Exit;
4610         end;
4611
4612         //===== \83v\83\89\83O\83C\83\93
4613         try
4614                 //\8dì\8bÆ\92\86//
4615                 bi := Length(BoardGroups) - 1;
4616                 for i := 1 to bi do begin
4617                         if (BoardGroups[i].BoardPlugIn <> nil) and (Assigned(Pointer(BoardGroups[i].BoardPlugIn.Module))) then begin
4618                                 case BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) of
4619                                 atThread:
4620                                         begin
4621                                                 boardURL        := BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL );
4622                                                 Board           := BBSsFindBoardFromURL( boardURL );
4623
4624
4625                                                 if Board = nil then begin
4626                                                         //break;
4627                                                         // \81¦\8dì\82Á\82Ä\82à\92Ç\89Á\82·\82é\82Æ\82±\82ë\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82­\95Û\97¯
4628                                                         //GikoSys.OpenBrowser(inURL, gbtUserApp);
4629                                                         //Exit;
4630                                                         {
4631                                                         Board := GikoSys.GetUnknownBoard( tmpThread.BoardPlugIn, boardURL );
4632                                                         if (FTreeType = gtt2ch) and (FActiveBBS = BBSs[ 1 ]) then
4633                                                                 ShowBBSTree( BBSs[ 1 ] );
4634                                                         }
4635                                                 end else begin
4636                                                         tmpThread               := TThreadItem.Create( BoardGroups[i].BoardPlugIn, Board, inURL );
4637                                                         if not Board.IsThreadDatRead then begin
4638                                                                 GikoSys.ReadSubjectFile( Board );
4639                                                                 tmpThread.Free;
4640                                                                 Exit;
4641                                                         end;
4642                                                         ThreadItem := Board.FindThreadFromFileName( tmpThread.FileName );
4643                                                         if ThreadItem = nil then begin
4644                                                                 //tmpThread\82ð\82±\82Á\82¿\82Í\8aJ\95ú\82µ\82Ä\82Í\82¢\82¯\82È\82¢
4645                                                                 ThreadItem := tmpThread;
4646                                                                 Board.Insert( 0, ThreadItem );
4647                                                                 if ActiveList is TBoard then begin
4648                                                                         if TBoard(ActiveList) = Board then
4649                                                                                 ListView.Items.Count := ListView.Items.Count + 1;
4650                                                                 end;
4651                                                         end else begin
4652                                                                 tmpThread.Free;
4653                                                         end;
4654                                                         OpenThreadItem(ThreadItem, inURL);
4655                                                         Exit;
4656                                                 end;
4657                                         end;
4658
4659                                 atBoard:
4660                                         begin
4661                                                 Board := BBSsFindBoardFromURL(
4662                                                                         BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL )
4663                                                                         );
4664                                                 if Board <> nil then begin
4665                                                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4666                                                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4667                                                         SelectTreeNode( Board, True );
4668                                                         Exit;
4669                                                 end;
4670                                         end;
4671                                 end;
4672                         end;
4673                 end;
4674         except
4675                 // exception \82ª\94­\90\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
4676         end;
4677
4678
4679         if (Length( Trim(BBSKey) ) > 0) and (Length( Trim(BBSID) ) > 0) then begin
4680                 boardURL := GikoSys.Get2chThreadURL2BoardURL( inURL );
4681                 Board := BBSsFindBoardFromURL( boardURL );
4682                 if Board = nil then begin
4683                          // \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­
4684                          GikoSys.OpenBrowser(inURL, gbtUserApp);
4685                          Exit;
4686                 end else begin
4687                         // \8aO\95\94\82Ì\94Â\82È\82Ì\82É2ch\82ÌURL\82É\82³\82ê\82Ä\82µ\82Ü\82Á\82½\93z\82ð\82±\82±\82Å\8am\94F\82·\82é
4688                         URL :=  Board.URL;
4689                         GikoSys.ParseURI(URL , protocol2, host2, path2, document2, port2, bookmark2 );
4690                         tmp1 := Copy(host, AnsiPos('.', host) + 1, Length(host));
4691                         tmp2 := Copy(host2, AnsiPos('.', host2) + 1, Length(host2));
4692                         if ( not GikoSys.Is2chHost(tmp1)) and (tmp1 <> tmp2) then begin
4693                                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4694                                 Exit;
4695                         end;
4696                 end;
4697
4698                 if not Board.IsThreadDatRead then
4699                         GikoSys.ReadSubjectFile(Board);
4700                 URL := GikoSys.Get2chBrowsableThreadURL( inURL );
4701                 ThreadItem := Board.FindThreadFromURL( URL );
4702                 //\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)
4703                 if ThreadItem = nil then begin
4704                         ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
4705                 end;
4706                 try
4707                         // \83X\83\8c\83b\83h\83A\83C\83e\83\80\82ª\82È\82¢\82È\82ç\90\90¬\82·\82é\81B
4708                         if ThreadItem = nil then begin
4709                                 ThreadItem := TThreadItem.Create( nil, Board, URL );
4710                                 ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
4711                                 Board.Insert(0, ThreadItem);
4712                                 if ActiveList is TBoard then begin
4713                                         if TBoard(ActiveList) = Board then
4714                                                 ListView.Items.Count := ListView.Items.Count + 1;
4715                                 end;
4716                         end;
4717                         // \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é
4718                         if (not ThreadItem.IsLogFile) then begin
4719                                 if AnsiPos(Host, Board.URL) = 0 then
4720                                         ThreadItem.DownloadHost := Host
4721                                 else
4722                                         ThreadItem.DownloadHost := '';
4723                         end;
4724                         OpenThreadItem(ThreadItem, inURL);
4725                 except
4726                 end;
4727         end else begin
4728                 Board := BBSsFindBoardFromURL( inURL );
4729                 if Board = nil then begin
4730                         GikoSys.OpenBrowser(inURL, gbtAuto);
4731                 end else begin
4732                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4733                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4734                         SelectTreeNode( Board, True );
4735                 end;
4736         end;
4737 end;
4738
4739 procedure TGikoForm.AddressToolBarResize(Sender: TObject);
4740 begin
4741         AddressComboBox.Width := AddressToolBar.Width - MoveToToolButton.Width - 10;
4742         CoolBarResized( Sender, MainCoolBar );
4743 end;
4744
4745 procedure TGikoForm.AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
4746         Shift: TShiftState);
4747 begin
4748         if Key = VK_RETURN then
4749                 GikoDM.MoveToAction.Execute;
4750 end;
4751
4752 procedure TGikoForm.BrowserEnter(Sender: TObject);
4753 begin
4754     Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
4755 end;
4756
4757 procedure TGikoForm.WMCopyData(var Message: TWMCopyData);
4758 var
4759         CDS:PCopyDataStruct;
4760         PC:PChar;
4761         sURL: string;
4762 begin
4763         CDS := Message.CopyDataStruct;
4764         GetMem(PC, CDS^.cbData);
4765         try
4766                 lstrcpy(PC,CDS^.lpData);
4767                 SetString(sURL, PC,lstrlen(PC));
4768                 MoveToURL(sURL);
4769         finally
4770                 FreeMem(PC);
4771         end;
4772         Message.Result := 1;
4773 end;
4774
4775 procedure TGikoForm.WndProc(var Message: TMessage);
4776 var
4777         senderBrowser   : TWebBrowser;
4778         url                                             : OleVariant;
4779 begin
4780         try
4781                 case Message.Msg of
4782                 CM_DIALOGCHAR:
4783                         if not (ssAlt in KeyDataToShiftState(TWMChar(Message).KeyData)) then
4784                                 Exit;
4785                 WM_SYSCOMMAND:
4786                         if Message.WParam = SC_MINIMIZE then begin
4787                                 OnMinimize;
4788                 PostMessage(Handle, USER_MINIMIZED, 0, 0);
4789             end;
4790                 USER_TREECLICK:
4791                         TreeClick( TreeView.Selected );
4792                 USER_RESIZED:
4793                         OnResized;
4794                 USER_MINIMIZED:
4795             begin
4796                 if (GikoSys.Setting.StoredTaskTray) then begin
4797                     StoredTaskTray;
4798                 end;
4799                 OnMinimized;
4800             end;
4801                 USER_SETLINKBAR:
4802                         SetLinkBar;
4803                 USER_DOCUMENTCOMPLETE:
4804                         if (Message.WParam <> 0) and
4805                                  (TObject(Message.WParam) is TWebBrowser) then begin
4806                                 senderBrowser := TWebBrowser( Message.WParam );
4807                                 BrowserDocumentComplete( senderBrowser, senderBrowser.Parent, url );
4808                         end;
4809         USER_RESPOPUPCLEAR:
4810             if (TObject(Message.WParam) is TResPopupBrowser) then begin
4811                 try
4812                                 TResPopupBrowser( Message.WParam ).Clear;
4813                 except
4814                 end;
4815                         end;
4816                 end;
4817
4818                 inherited;
4819         except
4820         end;
4821 end;
4822
4823 procedure TGikoForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
4824 var
4825         handle: THandle;
4826 begin
4827         Handled := False;
4828         //\83A\83h\83\8c\83X\82à\82µ\82­\82Í\8di\82è\8d\9e\82Ý\83R\83\93\83{\83{\83b\83N\83X\82à\82µ\82­\82Í\82¨\8bC\82É\93ü\82è\82ª\95Ò\8fW\92\86\82Í
4829         //\83V\83\87\81[\83g\83J\83b\83g\82È\82Ç\82ð\96³\8cø\82É\82·\82é
4830         if ((FavoriteTreeView.Visible) and (FavoriteTreeView.IsEditing)) then begin
4831                 if Msg.CharCode in [VK_BACK] then begin
4832                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4833                         if Msg.KeyData > 0 then begin
4834                                 handle := GetFocus;
4835                                 if handle <> 0 then
4836                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4837                                 Handled := True;
4838                         end;
4839                 end else
4840                 //\82¨\8bC\82É\93ü\82è\82ÍESC\82Å\92E\8fo\82µ\82½\82¢\82Ì\82Å\81A\82»\82ê\82à\91\97\82é
4841                 if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_ESCAPE] then begin
4842                         handle := GetFocus;
4843                         if handle <> 0 then
4844                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4845                         Handled := True;
4846                 end;
4847         end     else if (AddressComboBox.Focused) or (SelectComboBox.Focused) then begin
4848                 if Msg.CharCode in [VK_BACK] then begin
4849                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4850                         if Msg.KeyData > 0 then begin
4851                                 handle := GetFocus;
4852                                 if handle <> 0 then
4853                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4854                                 Handled := True;
4855                         end;
4856                 end else if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT] then begin
4857                         handle := GetFocus;
4858                         if handle <> 0 then
4859                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4860                         Handled := True;
4861                 end;
4862         end else begin
4863                 Handled := GikoDM.GikoFormActionList.IsShortCut(Msg);
4864         end;
4865 end;
4866
4867 procedure TGikoForm.PreviewTimerTimer(Sender: TObject);
4868 var
4869         p: TPoint;
4870         ARect: TRect;
4871 begin
4872         PreviewTimer.Enabled := False;
4873
4874         GetCursorpos(p);
4875
4876     ARect := FPreviewBrowser.GetWindowRect(p);
4877
4878     FPreviewBrowser.PreviewImage(FPreviewURL);
4879
4880         if ARect.Bottom > Screen.DesktopHeight then begin
4881         OffsetRect(ARect, 0, -(ARect.Bottom - Screen.DesktopHeight));
4882     end;
4883         if (ARect.Right > Screen.DesktopWidth) then begin
4884         OffsetRect(ARect, -(ARect.Right - Screen.DesktopWidth), 0);
4885     end;
4886         if (ARect.Left < Screen.DesktopLeft) then begin
4887         OffsetRect(ARect, +(Screen.DesktopLeft - ARect.Left), 0);
4888     end;
4889         if (ARect.Top < Screen.DesktopTop) then begin
4890         OffsetRect(ARect, 0, (Screen.DesktopTop - ARect.Top));
4891     end;
4892
4893         SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST,
4894         ARect.Left, ARect.Top,
4895         (ARect.Right - ARect.Left), (ARect.Bottom - ARect.Top),
4896         SWP_NOACTIVATE or SWP_HIDEWINDOW);
4897
4898         ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);
4899         FPreviewBrowserRect := ARect;
4900 end;
4901
4902 procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
4903 var
4904         Pos : TPoint;
4905 begin
4906         if PreviewTimer.Enabled then
4907                 PreviewTimer.Enabled := False;
4908
4909         if (FResPopupBrowser <> nil) and (IsWindowVisible(FResPopupBrowser.Handle)) then begin
4910         FResPopupBrowser.Clear;
4911         end;
4912
4913         if (FPreviewBrowser <> nil)
4914                 and (IsWindowVisible(FPreviewBrowser.Handle)) then begin
4915         //\82±\82±\82Å\8fÁ\82³\82ê\82é\82Ì\82ª\96â\91è
4916         //\82½\82Ô\82ñ\82±\82ê\82Å\95\\8e¦\94Í\88Í\94»\92è\82Å\82«\82Ä\82¢\82é\82Í\82¸
4917                 Pos := Mouse.CursorPos;
4918                 Pos.X := Pos.X + Left;
4919                 Pos.Y := Pos.Y + Top;
4920                 if (FPreviewBrowserRect.Left > Pos.X) or
4921                         (FPreviewBrowserRect.Right < Pos.X) or
4922                         (FPreviewBrowserRect.Top > Pos.Y) or
4923                         (FPreviewBrowserRect.Bottom < Pos.Y) then begin
4924                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
4925                 end;
4926         end;
4927
4928         Message.Result := 1;
4929         inherited;
4930 end;
4931 procedure TGikoForm.MessageHideButtonClick(Sender: TObject);
4932 begin
4933         GikoDM.MsgBarCloseAction.Execute;
4934 end;
4935
4936 function TGikoForm.OnDocumentContextMenu(Sender: TObject): WordBool;
4937 var
4938         Doc: IHtmlDocument2;
4939         Range: IHTMLTxtRange;
4940         s: string;
4941         Num: Integer;
4942         ThreadItem: TThreadItem;
4943 begin
4944         Result := False;
4945         FactiveContent.IDAnchorPopup('');
4946         Doc := FactiveContent.Browser.Document as IHtmlDocument2;
4947         if Assigned(Doc) then begin
4948                 Range := Doc.selection.createRange as IHTMLTxtRange;
4949                 s := CustomStringReplace(Range.text, '\81@', ' ');//\91S\8ap\8bó\94\92\82ð\94¼\8ap\8bó\94\92\82É
4950                 s := ZenToHan(Trim(s));
4951                 if GikoSys.IsNumeric(s) then begin
4952                         Num := StrToInt64Def(s, -1);
4953                         ThreadItem := GetActiveContent(true);
4954                         if (ThreadItem <> nil) and (Num <= ThreadItem.Count)
4955                 and (Num > 0)then begin
4956                 CreateResPopupBrowser;
4957                 FResPopupBrowser.CreateNewBrowser.PopupType := gptThread;
4958                                 HTMLCreater.SetResPopupText(FResPopupBrowser.CreateNewBrowser, ThreadItem, Num, Num, False, False);
4959                 FResPopupBrowser.Popup;
4960                                 Result := False;
4961                         end else
4962                                 Result := True;
4963                 end else begin
4964                         Result := True;
4965                 end;
4966         end;
4967 end;
4968
4969 procedure TGikoForm.HistoryAllClearToolButtonClick(Sender: TObject);
4970 const
4971         DEL_MSG = '\91S\97\9a\97ð\82ð\8dí\8f\9c\82µ\82Ü\82·\81B\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
4972         DEL_TITLE = '\8dí\8f\9c\8am\94F';
4973 begin
4974         if FTreeType = gttHistory then begin
4975                 if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then
4976                         if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then
4977                                 Exit;
4978                 FHistoryList.Clear;
4979                 TreeView.Items.Clear;
4980         end;
4981 end;
4982
4983 procedure TGikoForm.SetLinkBar;
4984 var
4985         i: Integer;
4986         j: Integer;
4987         ToolButton: TLinkToolButton;
4988         MenuItem: TMenuItem;
4989         oldIgnoreResize : TResizeType;
4990 begin
4991         oldIgnoreResize := FIsIgnoreResize;
4992         FIsIgnoreResize := rtResizing;
4993         MainCoolBar.Bands.BeginUpdate;
4994         try
4995                 LinkBarPopupMenu.Items.Clear;
4996                 for i := LinkToolBar.ButtonCount - 1 downto 0 do
4997                         //LinkToolBar.RemoveControl(LinkToolBar.Buttons[i]);
4998                         LinkToolBar.Buttons[i].Free;
4999                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5000                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5001                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5002                                         ToolButton := TLinkToolButton.Create(LinkToolBar);
5003 //                    ToolButton.Parent := LinkToolBar;
5004                                         if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteFolder then begin
5005                                                 MenuItem := TMenuItem.Create(Self);
5006                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], MenuItem);
5007                                                 LinkBarPopupMenu.Items.Add(MenuItem);
5008                                                 ToolButton.MenuItem := MenuItem;
5009                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
5010                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteBoardItem then begin
5011                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
5012                                                 ToolButton.OnClick := FavoriteClick;
5013                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteThreadItem then begin
5014                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
5015                                                 ToolButton.OnClick := FavoriteClick;
5016                                         end;
5017                                         ToolButton.Caption := FavoriteTreeView.Items[i].Item[j].Text;
5018                                         ToolButton.Left := 10000;
5019                                         ToolButton.Data := FavoriteTreeView.Items[i].Item[j].Data;
5020                                         ToolButton.AutoSize := True;
5021                                         ToolButton.OnDragDrop := LinkToolButtonDragDrop;
5022                                         ToolButton.OnDragOver := FavoriteDragOver;
5023                                         ToolButton.OnMouseDown := LinkToolButtonOnMouseDown;
5024                                         ToolButton.OnMouseMove := LinkToolButtonOnMouseMove;
5025                                         ToolButton.OnMouseUp := LinkToolButtonOnMouseUp;
5026                                         ToolButton.OnStartDrag := LinkToolButtonStartDrag;
5027                                         //ToolButton.DragMode := dmAutomatic;
5028                                         ToolButton.DragMode := dmManual;
5029                                         ToolButton.PopupMenu := FavoriteTreePopupMenu;
5030
5031                                         LinkToolBar.InsertControl(ToolButton);
5032                                 end;
5033                                 break;
5034                         end;
5035                 end;
5036 {               if LinkToolBar.ButtonCount = 0 then begin
5037                         ToolButton := TLinkToolButton.Create(LinkToolBar);
5038                         ToolButton.Style := tbsButton;
5039                         ToolButton.ImageIndex := -1;
5040                         ToolButton.Caption := '';
5041                         LinkToolBar.InsertControl(ToolButton);
5042                 end;}
5043         finally
5044                 MainCoolBar.Bands.EndUpdate;
5045                 LoadCoolBarSettings;
5046                 FIsIgnoreResize := oldIgnoreResize;
5047         end;
5048 end;
5049
5050 procedure TGikoForm.FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5051 var
5052         Node: TTreeNode;
5053         bound: TRect;
5054         height: Integer;
5055         Change: Boolean;
5056 begin
5057
5058         if Sender = FavoriteTreeView then begin
5059                 Node := FavoriteTreeView.GetNodeAt(X, Y);
5060
5061                 if Node = nil then
5062                         Exit;
5063
5064                 bound := Node.DisplayRect( False );
5065                 height := bound.Bottom - bound.Top;
5066                 if (bound.Top + height / 2) <= Y then
5067                         Node := FavoriteTreeView.GetNodeAt(X, Y + height);
5068
5069                 if Node = nil then
5070                         Exit;
5071
5072                 if Node.IsFirstNode then
5073                         Exit;
5074
5075                 Change := True;
5076
5077                 if FDropSpaceNode <> nil then
5078                         if FDropSpaceNode.AbsoluteIndex = Node.AbsoluteIndex then
5079                                 Change := False;
5080
5081                 if Change then begin
5082                         if FDropSpaceNode <> nil then
5083                                 FDropSpaceNode.Free;
5084
5085                         FDropSpaceNode := FavoriteDM.TreeView.Items.AddChildObjectFirst(Node.Parent, '', nil );
5086                         FDropSpaceNode.MoveTo( Node, naInsert );
5087                         FDropSpaceNode.ImageIndex := -1;
5088                         FDropSpaceNode.SelectedIndex := -1;
5089                 end;
5090         end;
5091
5092         if Source = FavoriteTreeView then begin
5093                 if FavoriteTreeView.Selected = FavoriteTreeView.Items.GetFirstNode then begin
5094                         Accept := False;
5095                         Exit;
5096                 end;
5097                 Accept := True;
5098         end else if Source = BrowserTab then
5099                 Accept := True
5100         else if Source = ListView then
5101                 Accept := True
5102         else if Source is TLinkToolButton then
5103                 Accept := True
5104         else if Source = TreeView then
5105                 Accept := True
5106         else
5107                 Accept := False;
5108 end;
5109
5110 procedure TGikoForm.FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5111 begin
5112
5113         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
5114
5115 end;
5116 procedure TGikoForm.LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
5117 begin
5118          //     FDragging := true;
5119 end;
5120
5121 procedure TGikoForm.LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
5122 var
5123         SenderNode: TTreeNode;
5124         LinkToolButton: TLinkToolButton;
5125 begin
5126
5127         LinkToolButton := TLinkToolButton( Sender );
5128         SenderNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
5129         SenderNode.Selected := False;
5130         FavoriteDragDrop( SenderNode, Source );
5131
5132         SetLinkBar;
5133
5134 end;
5135
5136 procedure TGikoForm.LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5137 var
5138         favButton                       : TLinkToolButton;
5139         favThreadItem   : TFavoriteThreadItem;
5140 begin
5141
5142         case Button of
5143         mbMiddle:
5144                 begin
5145                         if Sender is TLinkToolButton then begin
5146                                 favButton := TLinkToolButton( Sender );
5147                                 if TObject( favButton.Data ) is TFavoriteThreadItem then begin
5148                                         favThreadItem := TFavoriteThreadItem( favButton.Data );
5149                                         if favThreadItem.Item <> nil then
5150                                                 InsertBrowserTab( favThreadItem.Item, False );
5151                                 end;
5152                         end;
5153                 end;
5154         end;
5155
5156 end;
5157
5158 procedure TGikoForm.LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
5159 var
5160         Now : Cardinal;
5161 begin
5162         TToolButton( Sender ).DragMode := dmManual;
5163         if ssLeft in Shift then begin
5164 //              TToolButton( Sender ).Down := true;   // \83\8a\83\93\83N\83c\81[\83\8b\83o\81[\82Ì\8b\93\93®\95s\90R\82Ì\8c´\88ö\82Ì\82æ\82¤\82È\82Ì\82Å\83R\83\81\83\93\83g\83A\83E\83g\82µ\82½(2003-dec-02)
5165                 if FDragTime = 0 then begin
5166                         FDragTime := GetTickCount();
5167                 end else begin
5168                         Now := GetTickCount();
5169                         if (Now - FDragTime) > 500 then begin
5170                                 if FDragButton <> TToolButton( Sender ) then begin
5171                                         try
5172                                                 FDragButton := TToolButton( Sender );
5173                                                 TToolButton(Sender).BeginDrag(false ,5);
5174                                                 FDragTime := 0;
5175                                         except
5176                                                 {$IF Defined(debug)}
5177                                                 ShowMessage('Error');
5178                                                 {$IFEND}
5179                                         end;
5180                                 end;
5181                         end;
5182                 end;
5183         end else begin
5184                 FDragTime := 0;
5185         end;
5186 end;
5187
5188 procedure TGikoForm.LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5189 begin
5190         FDragTime := 0;
5191 end;
5192
5193 function TGikoForm.GetWidthAllToolButton(ToolBar: TToolBar): Integer;
5194 var
5195         i: Integer;
5196 begin
5197         Result := 0;
5198         for i := 0 to ToolBar.ButtonCount - 1 do
5199                 if ToolBar.Buttons[i].Visible then
5200                         Result := Result + ToolBar.Buttons[i].Width;
5201 end;
5202
5203 procedure TGikoForm.MainCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5204 var
5205         Control : TWinControl;
5206         i, idx  : Integer;
5207 begin
5208         Control := FindControl(BandInfo^.hwndChild);
5209         if Control = nil then
5210                 Exit;
5211         idx := 0;
5212         for i := MainCoolBar.Bands.Count - 1 downto 0 do begin
5213                 if MainCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5214                         idx := MainCoolBar.Bands[ i ].ID;
5215                         Break;
5216                 end;
5217         end;
5218         Canvas.Font.Handle := GetStockObject( DEFAULT_GUI_FONT );
5219         if (Control = MenuToolBar) or (Control = StdToolBar) then begin
5220                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5221                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5222                 BandInfo^.cxMinChild    := 0;
5223                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth;
5224                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5225         end else if Control = LinkToolBar then begin
5226                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5227                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5228                 BandInfo^.cxMinChild    := 0;
5229                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83\8a\83\93\83N' );
5230                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5231         end else begin // AddressToolBar
5232                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5233                 BandInfo^.cxMinChild    := 0;
5234                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83A\83h\83\8c\83X' );
5235         end;
5236 end;
5237
5238 procedure TGikoForm.MainCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5239 var
5240         i : Integer;
5241         Idx: Integer;
5242         p: TPoint;
5243 begin
5244         ChevronPopupMenu.Items.Clear;
5245         Idx := 0;
5246         for i := 0 to MainCoolBar.Bands.Count - 1 do begin
5247                 if MainCoolBar.Bands[ i ].Visible then begin
5248                         if Idx = Int64(RebarChevron^.uBand) then begin
5249                                 Idx := i;
5250                                 break;
5251                         end;
5252                         Inc( Idx );
5253                 end;
5254         end;
5255         if (Idx >= 0) and (MainCoolBar.Bands.Count > Idx) then begin
5256                 if MainCoolBar.Bands[Idx].Control = MenuToolbar then begin
5257                         MenuBarChevronMenu;
5258                 end else if MainCoolBar.Bands[Idx].Control = StdToolbar then begin
5259                         ToolBarChevronMenu(StdToolBar);
5260                 end else if MainCoolBar.Bands[Idx].Control = LinkToolbar then begin
5261                         LinkBarChevronMenu;
5262                 end else
5263                         Exit;
5264                 p := MainCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5265                 ChevronPopupMenu.Popup(p.x, p.y);
5266         end;
5267 end;
5268
5269 procedure TGikoForm.MenuBarChevronMenu;
5270         procedure SetSubMenu(MenuItem: TMenuItem; PopupItem: TMenuItem);
5271         var
5272                 i: Integer;
5273                 Item: TMenuItem;
5274         begin
5275                 MenuItem.Click;
5276                 for i := 0 to MenuItem.Count - 1 do begin
5277 //                      Item := nil;
5278                         if MenuItem[i] is TFavoriteMenuItem then begin
5279                                 Item := TFavoriteMenuItem.Create(Self);
5280                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(MenuItem[i]).Data;
5281                         end else
5282                                 Item := TMenuItem.Create(Self);
5283                         Item.Caption := MenuItem[i].Caption;
5284                         Item.Action := MenuItem[i].Action;
5285                         Item.ImageIndex := MenuItem[i].ImageIndex;
5286                         Item.OnClick := MenuItem[i].OnClick;
5287                         PopupItem.Add(Item);
5288                         if MenuItem[i].Count > 0 then
5289                                 SetSubMenu(MenuItem[i], Item);
5290                 end;
5291         end;
5292 var
5293         i: Integer;
5294         w: Integer;
5295         bw: Integer;
5296         Item: TMenuItem;
5297 begin
5298         ChevronPopupMenu.Items.Clear;
5299         ChevronPopupMenu.Images := MainMenu.Images;
5300         bw := GetWidthAllToolButton(MenuToolBar);
5301         if MenuToolBar.Width < bw then begin
5302                 w := 0;
5303                 for i := 0 to MenuToolBar.ButtonCount - 1 do begin
5304                         w := w + MenuToolBar.Buttons[i].Width;
5305                         if MenuToolBar.Width <= w then begin
5306                                 Item := TMenuItem.Create(Self);
5307                                 Item.Caption := MenuToolBar.Buttons[i].MenuItem.Caption;
5308                                 //Item.Action := MenuToolBar.Buttons[i].MenuItem.Action;
5309                                 ChevronPopupMenu.Items.Add(Item);
5310                                 SetSubMenu(MenuToolbar.Buttons[i].MenuItem, Item);
5311                         end;
5312                 end;
5313         end;
5314 end;
5315
5316 procedure TGikoForm.ToolBarChevronMenu(ToolBar: TToolBar);
5317         procedure SetSubMenu(PopupMenu: TPopupMenu; PopupItem: TMenuItem);
5318         var
5319                 i: Integer;
5320                 Item: TMenuItem;
5321         begin
5322                 if Assigned(PopupMenu.OnPopup) then
5323                         PopupMenu.OnPopup(nil);
5324                 for i := 0 to PopupMenu.Items.Count - 1 do begin
5325 //                      Item := nil;
5326                         if PopupMenu.Items[i] is TFavoriteMenuItem then begin
5327                                 Item := TFavoriteMenuItem.Create(Self);
5328                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(PopupMenu.Items[i]).Data;
5329                         end else
5330                         Item := TMenuItem.Create(Self);
5331                         Item.Caption := PopupMenu.Items[i].Caption;
5332                         Item.Action := PopupMenu.Items[i].Action;
5333                         Item.ImageIndex := PopupMenu.Items[i].ImageIndex;
5334                         Item.OnClick := PopupMenu.Items[i].OnClick;
5335                         PopupItem.Add(Item);
5336                 end;
5337         end;
5338 var
5339         i: Integer;
5340         w: Integer;
5341         bw: Integer;
5342         Item: TMenuItem;
5343 begin
5344         ChevronPopupMenu.Items.Clear;
5345         ChevronPopupMenu.Images := ToolBar.HotImages;
5346         bw := GetWidthAllToolButton(ToolBar);
5347         if ToolBar.Width < bw then begin
5348                 w := 0;
5349                 for i := 0 to ToolBar.ButtonCount - 1 do begin
5350                         if ToolBar.Buttons[i].Visible then
5351                                 w := w + ToolBar.Buttons[i].Width;
5352                         if ToolBar.Width <= w then begin
5353                                 if ToolBar.Buttons[i].Tag = 0 then begin
5354                                         Item := TMenuItem.Create(Self);
5355                                         if ToolBar.Buttons[i].Style = tbsSeparator then
5356                                                 Item.Caption := '-'
5357                                         else begin
5358                                                 //\83X\83\8c\8di\8d\9e\82ÝComBox\82ÌTPanel\82ð\94r\8f\9c\82·\82é
5359                                                 if TObject(ToolBar.Buttons[i]) is TPanel then begin
5360                                                         Continue;
5361                                                 end else begin
5362                                                         Item.Caption := ToolBar.Buttons[i].Caption;
5363                                                         Item.Action := ToolBar.Buttons[i].Action;
5364                                                 end;
5365                                                 //Item.Visible := True;
5366                                         end;
5367                                         ChevronPopupMenu.Items.Add(Item);
5368                                         if ToolBar.Buttons[i].DropdownMenu <> nil then begin
5369                                                 Item.Action := nil;
5370                                                 Item.OnClick := nil;
5371                                                 SetSubMenu(ToolBar.Buttons[i].DropdownMenu, Item);
5372                                         end;
5373                                 end;
5374                         end;
5375                 end;
5376         end;
5377 end;
5378
5379 procedure TGikoForm.LinkBarChevronMenu;
5380 var
5381         i: Integer;
5382         j: Integer;
5383         w: Integer;
5384         Item: TFavoriteMenuItem;
5385         bw: Integer;
5386         Button: TLinkToolButton;
5387 begin
5388         ChevronPopupMenu.Items.Clear;
5389         ChevronPopupMenu.Images := LinkToolBar.Images;
5390         bw := GetWidthAllToolButton(LinkToolBar);
5391         if LinkToolBar.Width < bw then begin
5392                 w := 0;
5393                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5394                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5395                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5396                                         w := w + LinkToolBar.Buttons[j].Width;
5397                                         if LinkToolBar.Width <= w then begin
5398                                                 if LinkToolBar.Buttons[j] is TLinkToolButton then begin
5399                                                         Button := TLinkToolButton(LinkToolBar.Buttons[j]);
5400                                                         Item := TFavoriteMenuItem.Create(Self);
5401                                                         if TObject(Button.Data) is TFavoriteFolder then begin
5402                                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], Item);
5403                                                         end else if TObject(Button.Data) is TFavoriteBoardItem then begin
5404                                                                 Item.OnClick := FavoriteClick;
5405                                                         end else if TObject(Button.Data) is TFavoriteThreadItem then begin
5406                                                                 Item.OnClick := FavoriteClick;
5407                                                         end;
5408                                                         Item.Data := Button.Data;
5409                                                         Item.Caption := LinkToolBar.Buttons[j].Caption;
5410                                                         Item.ImageIndex := LinkToolBar.Buttons[j].ImageIndex;
5411                                                         ChevronPopupMenu.Items.Add(Item);
5412                                                 end;
5413                                         end;
5414                                 end;
5415                                 break;
5416                         end;
5417                 end;
5418         end;
5419 end;
5420
5421 {!
5422 \brief  \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
5423 \param  bar             \83o\83\93\83h\82ª\8f\8a\91®\82·\82é CoolBar
5424 \param  band    \8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é\83o\83\93\83h
5425
5426 \93Æ\8e©\82É\83o\83\93\83h\82É\94z\92u\82³\82ê\82Ä\82¢\82é\83R\83\93\83g\83\8d\81[\83\8b\82Ì\83T\83C\83Y\82ð\95Ï\8dX\82µ\82½\8fê\8d\87\82É
5427 \83V\83F\83u\83\8d\83\93\82Ì\95\\8e¦\88Ê\92u\82ð\8dÄ\90Ý\92è\82·\82é\82½\82ß\82É\8eg\97p\82µ\82Ü\82·\81B
5428 }
5429 procedure TGikoForm.ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
5430 var
5431         bandInfo        : tagREBARBANDINFOA;
5432         pBandInfo       : PReBarBandInfoA;
5433         lResult         : Integer;
5434         h                                       : HWND;
5435         i, idx          : Integer;
5436 begin
5437
5438         h                                                                               := band.Handle;
5439         pBandInfo := @bandInfo;
5440         ZeroMemory( pBandInfo, sizeof( bandInfo ) );
5441         bandInfo.cbSize                 := sizeof( bandInfo );
5442         bandInfo.hwndChild      := h;
5443         bandInfo.cyMinChild     := bar.Height;
5444         bar.OnBandInfo( nil, pBandInfo );
5445         // band \82Ì\83C\83\93\83f\83b\83N\83X\82ð\92T\82·
5446         idx := 0;
5447         for i := bar.Bands.Count - 1 downto 0 do begin
5448                 if bar.Bands[ i ].Control.Handle = h then begin
5449                         idx := i;
5450                         Break;
5451                 end;
5452         end;
5453         // \90Ý\92è
5454         lResult := SendMessage( bar.Handle, RB_SETBANDINFO, idx, Integer( pBandInfo ) );
5455
5456 end;
5457
5458 procedure TGikoForm.ListCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5459 var
5460         Control: TWinControl;
5461         i, idx  : Integer;
5462 begin
5463         Control := FindControl(BandInfo^.hwndChild);
5464         if Control = nil then
5465                 Exit;
5466         idx := 0;
5467         for i := ListCoolBar.Bands.Count - 1 downto 0 do begin
5468                 if ListCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5469                         idx := ListCoolBar.Bands[ i ].ID;
5470                         Break;
5471                 end;
5472         end;
5473         if Control = ListToolBar then begin
5474                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5475                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5476                 BandInfo^.cxMinChild    := 0;
5477                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5478                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5479         end else begin
5480                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5481                 BandInfo^.cxMinChild    := 0;
5482                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5483         end;
5484 end;
5485
5486 procedure TGikoForm.ListCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5487 var
5488         Idx: Integer;
5489         p: TPoint;
5490 begin
5491         ChevronPopupMenu.Items.Clear;
5492         Idx := RebarChevron^.uBand;
5493         if (Idx >= 0) and (ListCoolBar.Bands.Count > Idx) then begin
5494                 if ListCoolBar.Bands[Idx].Control = ListToolBar then begin
5495                         ToolBarChevronMenu(ListToolBar);
5496                 end else
5497                         Exit;
5498                 p := ListCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5499                 ChevronPopupMenu.Popup(p.x, p.y);
5500         end;
5501 end;
5502
5503 procedure TGikoForm.BrowserCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5504 var
5505         Control: TWinControl;
5506         i, idx  : Integer;
5507 begin
5508         Control := FindControl(BandInfo^.hwndChild);
5509         if Control = nil then
5510                 Exit;
5511         idx := 0;
5512         for i := BrowserCoolBar.Bands.Count - 1 downto 0 do begin
5513                 if BrowserCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5514                         idx := BrowserCoolBar.Bands[ i ].ID;
5515                         Break;
5516                 end;
5517         end;
5518         if Control = BrowserToolBar then begin
5519                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5520                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5521                 BandInfo^.cxMinChild    := 0;
5522                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5523                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5524         end else begin
5525                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5526                 BandInfo^.cxMinChild    := 0;
5527                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5528         end;
5529 end;
5530
5531 procedure TGikoForm.BrowserCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5532 var
5533         Idx: Integer;
5534         p: TPoint;
5535 begin
5536         ChevronPopupMenu.Items.Clear;
5537         Idx := RebarChevron^.uBand;
5538         if (Idx >= 0) and (BrowserCoolBar.Bands.Count > Idx) then begin
5539                 if BrowserCoolBar.Bands[Idx].Control = BrowserToolBar then
5540                         ToolBarChevronMenu(BrowserToolBar)
5541                 else
5542                         Exit;
5543                 p := BrowserCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5544                 ChevronPopupMenu.Popup(p.x, p.y);
5545         end;
5546 end;
5547
5548 procedure TGikoForm.ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
5549 begin
5550         if Column^.iImage = -1 then begin
5551                 Column^.mask := Column^.mask or LVCF_FMT;
5552         end else begin
5553                 Column^.mask := Column^.mask or LVCF_FMT or LVCF_IMAGE;
5554                 Column^.fmt := Column^.fmt or LVCFMT_IMAGE or LVCFMT_BITMAP_ON_RIGHT;
5555         end;
5556 end;
5557
5558 function TGikoForm.FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
5559 var
5560         i : Integer;
5561 begin
5562         Result := nil;
5563         for i := bar.ButtonCount - 1 downto 0 do begin
5564                 if bar.Buttons[ i ].Action = action then begin
5565                         Result := bar.Buttons[ i ];
5566                         Break;
5567                 end;
5568         end;
5569 end;
5570
5571 procedure TGikoForm.SetToolBarPopup;
5572 var
5573         i                                                                       : Integer;
5574         aIEButton                                       : TToolButton;
5575         aCabinetBBSButton       : TToolButton;
5576         aResRangeButton         : TToolButton;
5577         aThreadRangeButton:     TToolButton;
5578 begin
5579         for i := 0 to StdToolBar.ButtonCount - 1 do begin
5580         end;
5581         for i := 0 to ListToolBar.ButtonCount - 1 do begin
5582                 if ListToolBar.Buttons[i].Action = GikoDM.IconStyle then
5583                         ListToolBar.Buttons[i].DropdownMenu := ListIconPopupMenu;
5584                 if ListToolBar.Buttons[i].Action = GikoDM.SelectReservAction then
5585                         ListToolBar.Buttons[i].DropdownMenu := RoundNamePopupMenu;
5586         end;
5587         aIEButton                                       := FindToolBarButton( BrowserToolBar, GikoDM.IEAction );
5588         if aIEButton <> nil then
5589                 aIEButton.DropdownMenu                                  := BrowserPopupMenu;
5590         aCabinetBBSButton       := FindToolBarButton( StdToolBar, GikoDM.CabinetBBSAction );
5591         if aCabinetBBSButton <> nil then
5592                 aCabinetBBSButton.DropdownMenu  := BBSSelectPopupMenu;
5593         aResRangeButton         := FindToolBarButton( BrowserToolBar, GikoDM.ResRangeAction );
5594         if aResRangeButton <> nil then
5595                 aResRangeButton.DropdownMenu            := ResRangePopupMenu;
5596         aThreadRangeButton:= FindToolBarButton( ListToolBar, GikoDM.ThreadRangeAction );
5597         if aThreadRangeButton <> nil then
5598                 aThreadRangeButton.DropdownMenu := ThreadRangePopupMenu;
5599 end;
5600
5601 procedure TGikoForm.FormMouseWheel(Sender: TObject; Shift: TShiftState;
5602         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
5603 var
5604         Wnd: THandle;
5605         delta: Integer;
5606 //      browserPos : TPoint;
5607 const
5608         ICON_SIZE = 16;
5609 begin
5610         Wnd := WindowFromPoint(Mouse.CursorPos);
5611         Handled := True;
5612         if WheelDelta > 0 then
5613                 Delta := -1
5614         else
5615                 Delta := 1;
5616
5617         if (Wnd = BrowserTab.Handle) or
5618                  (Wnd = BrowserTab.Parent.Handle) then begin
5619                 BrowserTab.ScrollTabs(Delta);
5620         end else begin
5621                 if FIsHandledWheel then begin
5622                         FIsHandledWheel := False;
5623                         Handled := False;
5624                 end else begin
5625                         FIsHandledWheel := True;
5626                         if (Wnd = TreeView.Handle) or  (Wnd = FavoriteTreeView.Handle)
5627                         or (Wnd = ListView.Handle) or (Wnd = MessageListView.Handle)
5628                         then
5629                                 SendMessage( Wnd, WM_MOUSEWHEEL, WheelDelta shl 16, (Mouse.CursorPos.X shl 16) or Mouse.CursorPos.Y )
5630                         else
5631                                 Handled := False;
5632
5633                 end;
5634         end;
5635 end;
5636
5637 procedure TGikoForm.SetSelectWord( const text : string );
5638 begin
5639         // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
5640         ClearThreadRengeAction;
5641
5642         if Length( text ) = 0 then
5643         begin
5644                 GikoDM.AllItemAction.Checked := True;
5645                 SetListViewType( gvtAll )
5646         end else begin
5647                 SetListViewType( gvtUser, text, false );
5648         end;
5649 end;
5650
5651 procedure TGikoForm.SelectComboBoxChange(Sender: TObject);
5652 begin
5653
5654         SetSelectWord( SelectComboBox.Text );
5655
5656 end;
5657
5658 procedure TGikoForm.SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
5659         Shift: TShiftState);
5660 var
5661   IMC: HIMC;
5662   Len: integer;
5663   Str: string;
5664   tmp: string;
5665 begin
5666
5667         if Key = VK_Return then
5668         begin
5669                 ModifySelectList;
5670         end else if Key = 229 then begin
5671                 if GikoSys.Setting.UseUndecided then begin
5672                         IMC := ImmGetContext(SelectComboBox.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
5673                         Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5674                         SetLength(Str, Len + 1); //Buffer\82Ì\83\81\83\82\83\8a\82ð\90Ý\92è
5675                         ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5676                         ImmReleaseContext(SelectComboBox.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
5677                         SetLength(Str, Len);
5678                         if SelectComboBox.SelLength > 0 then begin //\91I\91ð\92\86\82Ì\95\8e\9a\97ñ\82ª\82 \82é\82©
5679                                 tmp := Copy(SelectComboBox.Text, 1, SelectComboBox.SelStart);
5680                                 Str := tmp + Str + Copy(SelectComboBox.Text, SelectComboBox.SelStart + SelectComboBox.SelLength + 1, Length(SelectComboBox.Text));
5681                         end else
5682                                 Str := SelectComboBox.Text + Str;
5683
5684                         if (Length(Str) > 0) then begin
5685                                 SetSelectWord(Str);
5686                         end;
5687                 end;
5688         end else if Length( SelectComboBox.Text ) = 0 then
5689         begin
5690                 {* SelectComboBox.Text\82ª\8bó\82Å\82à\81A\93ü\97Í\93r\92\86\82ÅEsc\82µ\82½\82Æ\82©
5691                  * \8bó\82Ì\82Æ\82«\82ÉDel\83L\81[\82ð\89\9f\82µ\82½\82Æ\82©\82È\82Ì\82Å\81A\83X\83\8c\82Ì\8di\8d\9e\82Ý\82ð\88Û\8e\9d\82·\82é\81B
5692                  * \81i\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢\81j
5693                  *}
5694         end else begin
5695         // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
5696                 ClearThreadRengeAction;
5697         end;
5698
5699 end;
5700 //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
5701 procedure TGikoForm.ClearThreadRengeAction;
5702 begin
5703         // \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é
5704         if GikoDM.AllItemAction.Checked then
5705                 GikoDM.AllItemAction.Checked := False;
5706         if GikoDM.LogItemAction.Checked then
5707                 GikoDM.LogItemAction.Checked := False;
5708         if GikoDM.NewItemAction.Checked then
5709                 GikoDM.NewItemaction.Checked := False;
5710         if GikoDM.LiveItemAction.Checked then
5711                 GikoDM.LiveItemAction.Checked := False;
5712         if GikoDM.ArchiveItemAction.Checked then
5713                 GikoDM.ArchiveItemAction.Checked := False;
5714
5715 end;
5716
5717 procedure TGikoForm.SelectComboBoxExit(Sender: TObject);
5718 begin
5719
5720         ModifySelectList;
5721
5722         if Length( SelectComboBox.Text ) = 0 then
5723         begin
5724                 SelectComboBox.Text := GikoDataModule.SELECTCOMBOBOX_NAME;
5725                 SelectComboBox.Color := GikoDataModule.SELECTCOMBOBOX_COLOR;
5726         end;
5727
5728 end;
5729
5730 // \8di\82è\8d\9e\82Ý\8c\9f\8dõ\82Ì\97\9a\97ð\8dX\90V
5731 procedure TGikoForm.ModifySelectList;
5732 var
5733         idx : Integer;
5734         oldText : string;
5735 begin
5736
5737         try
5738                 if not SelectComboBoxPanel.Visible then
5739                         exit;
5740
5741                 if Length( SelectComboBox.Text ) > 0 then
5742                 begin
5743                         oldText := SelectComboBox.Text;
5744                         idx := GikoSys.Setting.SelectTextList.IndexOf( oldText );
5745                         if idx <> -1 then
5746                                 GikoSys.Setting.SelectTextList.Delete( idx );
5747                         idx := SelectComboBox.Items.IndexOf( oldText );
5748                         if idx <> -1 then
5749                                 SelectComboBox.Items.Delete( idx );
5750                         GikoSys.Setting.SelectTextList.Insert( 0, oldText );
5751                         SelectComboBox.Items.Insert( 0, oldText );
5752                         SelectComboBox.Text := oldText;
5753                 end;
5754         except
5755         end;
5756
5757 end;
5758
5759
5760 procedure TGikoForm.SelectComboBoxSplitterMouseMove(Sender: TObject;
5761         Shift: TShiftState; X, Y: Integer);
5762 var
5763         pos                             : TPoint;
5764         w                                       : Integer;
5765 begin
5766         If (SelectComboBoxPanel.Visible) and (IsDraggingSelectComboBox) Then begin
5767                 pos.X := X;
5768                 pos.Y := Y;
5769                 pos := SelectComboBoxSplitter.ClientToScreen( pos );
5770                 //w := SelectComboBox.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5771                 w := SelectComboBoxPanel.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5772
5773                 If w <= 50 Then Begin
5774                         // \8e\9f\82Ì\88Ú\93®\82Ì\8aî\8f\80\82ª\81u\89ß\82¬\82Ä\82µ\82Ü\82Á\82½\88Ê\92u\81v\82Å\82Í\82È\82­
5775                         // \81u\8e~\82Ü\82Á\82½(50pixel)\88Ê\92u\81v\82É\82È\82é\82æ\82¤\82É
5776                         pos.X := pos.X + (50 - w);
5777
5778                         // \8f¬\82³\82­\82È\82è\82·\82¬\82È\82¢\82æ\82¤\82É
5779                         w := 50;
5780                 End;
5781
5782                 // \83`\83\89\82Â\82«\8cy\8c¸\82Ì\88×
5783                 //If SelectComboBox.Width <> w Then Begin
5784                 If SelectComboBoxPanel.Width <> w Then Begin
5785                         SelectComboBoxPanel.Width := w;
5786                         SelectComboBox.Width := SelectComboBoxPanel.Width - SelectComboBoxSplitter.Width;
5787                         GikoSys.Setting.SelectComboBoxWidth := w;
5788                         DraggingSelectComboBoxPosition := pos;
5789
5790                         // \83V\83F\83u\83\8d\83\93\88Ê\92u\82ª\95Ï\82í\82é\82Ì\82Å BandInfo \82Ì\8dÄ\90Ý\92è
5791                         ResetBandInfo( ListCoolBar, ListToolBar );
5792                 End;
5793         End;
5794
5795 end;
5796
5797 procedure TGikoForm.SelectComboBoxSplitterMouseDown(Sender: TObject;
5798         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5799 var
5800         pos : TPoint;
5801 begin
5802         IsDraggingSelectComboBox := True;
5803         pos.X := X;
5804         pos.Y := Y;
5805         DraggingSelectComboBoxPosition := SelectComboBoxSplitter.ClientToScreen( pos );
5806
5807 end;
5808
5809 procedure TGikoForm.SelectComboBoxSplitterMouseUp(Sender: TObject;
5810         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5811 begin
5812         IsDraggingSelectComboBox := False;
5813
5814 end;
5815
5816 procedure TGikoForm.StatusBarResize(Sender: TObject);
5817 begin
5818         StatusBar.Panels[1].Width := StatusBar.Width -
5819                                         StatusBar.Panels[0].Width -
5820                                         StatusBar.Panels[THREADSIZE_PANEL].Width -
5821                                         StatusBar.Panels[NGWORDNAME_PANEL].Width;
5822 end;
5823 procedure TGikoForm.SelectComboBoxEnter(Sender: TObject);
5824 begin
5825
5826         if (Length( SelectComboBox.Text ) = 0) or
5827                 (SelectComboBox.Text = GikoDataModule.SELECTCOMBOBOX_NAME) then
5828         begin
5829                 SelectComboBox.Text := '';
5830                 SelectComboBox.Color := clWindow;
5831         end;
5832
5833 end;
5834
5835 procedure TGikoForm.FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
5836 begin
5837
5838         if (SenderNode = nil) or (SourceNode = nil) or (SenderNode = SourceNode) then
5839                 Exit;
5840
5841         if TObject(SenderNode.Data) is TFavoriteFolder then
5842                 SourceNode.MoveTo(SenderNode, naAddChild)
5843         else
5844                 SourceNode.MoveTo(SenderNode, naInsert);
5845
5846 end;
5847
5848 procedure TGikoForm.FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
5849 var
5850         Node: TTreeNode;
5851         FavNode: TTreeNode;
5852         FavoBoardItem: TFavoriteBoardItem;
5853         FavoThreadItem: TFavoriteThreadItem;
5854         Board: TBoard;
5855         ThreadItem: TThreadItem;
5856 begin
5857
5858         if (SenderNode = nil) or (Source = nil) then
5859                 Exit;
5860
5861         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
5862                 FavNode := SenderNode.Parent
5863         else
5864                 FavNode := SenderNode;
5865
5866         Node := nil;
5867
5868         if Source is TBoard then begin
5869                 Board := TBoard( Source );
5870                 FavoBoardItem                           := TFavoriteBoardItem.CreateWithItem( Board );
5871                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, FavoBoardItem);
5872                 Node.ImageIndex := 15;
5873                 Node.SelectedIndex := 15;
5874         end else if Source is TFavoriteBoardItem then begin
5875                 FavoBoardItem := TFavoriteBoardItem( Source );
5876                 Board := FavoBoardItem.Item;
5877                 if Board <> nil then
5878                         if not Board.IsThreadDatRead then
5879                                 GikoSys.ReadSubjectFile(Board);
5880                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, Source);
5881                 Node.ImageIndex := 15;
5882                 Node.SelectedIndex := 15;
5883         end else if Source is TThreadItem then begin
5884                 ThreadItem := TThreadItem( Source );
5885                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
5886                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
5887                 Node.ImageIndex := 16;
5888                 Node.SelectedIndex := 16;
5889         end else if Source is TBrowserRecord then begin
5890                 ThreadItem := TBrowserRecord( Source ).Thread;
5891                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
5892                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
5893                 Node.ImageIndex := 16;
5894                 Node.SelectedIndex := 16;
5895         end else if Source is TFavoriteThreadItem then begin
5896                 FavoThreadItem := TFavoriteThreadItem( Source );
5897                 ThreadItem := FavoThreadItem.Item;
5898                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, Source);
5899                 Node.ImageIndex := 16;
5900                 Node.SelectedIndex := 16;
5901         end;
5902
5903         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
5904                 if Node <> nil then
5905                         FavoriteMoveTo( SenderNode, Node );
5906
5907 end;
5908
5909 procedure TGikoForm.FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
5910 var
5911         idx: Integer;
5912         SourceNode: TTreeNode;
5913         LinkToolButton: TLinkToolButton;
5914 begin
5915
5916         if SenderNode = nil then
5917                 Exit;
5918
5919         if not (TObject( SenderNode.Data ) is TFavoriteFolder) then
5920                 if FDropSpaceNode <> nil then
5921                         SenderNode := FDropSpaceNode;
5922
5923         if Source = FavoriteTreeView then begin
5924                 SourceNode := FavoriteTreeView.Selected;
5925                 FavoriteMoveTo( SenderNode, SourceNode );
5926         end else if Source is TLinkToolButton then begin
5927                 LinkToolButton := TLinkToolButton( Source );
5928                 SourceNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
5929                 FavoriteMoveTo( SenderNode, SourceNode );
5930         end else if Source = BrowserTab then begin
5931                 idx := BrowserTab.TabIndex;
5932                 FavoriteAddTo( SenderNode, BrowserTab.Tabs.Objects[idx] );
5933         end else if Source = ListView then begin
5934                 FavoriteAddTo( SenderNode, ListView.Selected.Data );
5935         end else if Source = TreeView then begin
5936                 FavoriteAddTo( SenderNode, TreeView.Selected.Data );
5937         end;
5938 end;
5939
5940 procedure TGikoForm.FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
5941         Y: Integer);
5942 var
5943         SenderNode: TTreeNode;
5944 begin
5945
5946         SenderNode := FavoriteTreeView.GetNodeAt(X, Y);
5947         if SenderNode <> nil then begin
5948                 FavoriteDragDrop( SenderNode, Source );
5949         end;
5950
5951         //\8bó\94\92\8d\80\96Ú\82ª\82¢\82½\82ç\8dí\8f\9c\82·\82é
5952         if FDropSpaceNode <> nil then begin
5953                 try
5954                         FDropSpaceNode.Delete;
5955                 finally
5956                         FDropSpaceNode := nil;
5957                 end;
5958         end;
5959         //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
5960         FavoriteDM.Modified := true;
5961
5962         SetLinkBar;
5963
5964 end;
5965
5966 procedure TGikoForm.FavoriteTreeViewEdited(Sender: TObject;
5967         Node: TTreeNode; var S: String);
5968 begin
5969         //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
5970         FavoriteDM.Modified := true;
5971
5972         FavoriteTreeView.ReadOnly := True;
5973         SetLinkBar;
5974
5975 end;
5976
5977 procedure TGikoForm.FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
5978         Shift: TShiftState);
5979 begin
5980         if not TTreeView(Sender).IsEditing then begin
5981                 Case Key of
5982                 VK_F2:
5983                         begin
5984                                 FClickNode := FavoriteTreeView.Selected;
5985                                 GikoDM.FavoriteTreeViewRenameActionExecute( Sender );
5986                         end;
5987                 VK_DELETE:
5988                         begin
5989                                 FClickNode := FavoriteTreeView.Selected;
5990                                 GikoDM.FavoriteTreeViewDeleteActionExecute( Sender );
5991                         end;
5992                 VK_RETURN:
5993                         begin
5994                         FavoriteClick( FavoriteTreeView.Selected );
5995                         FavoriteTreeView.Selected.Expanded := not FavoriteTreeView.Selected.Expanded;
5996                         end;
5997                 VK_SPACE:
5998                         begin
5999                         FClickNode := FavoriteTreeView.Selected;
6000                         GikoDM.FavoriteTreeViewReloadActionExecute( Sender );
6001                         end;
6002                 end;
6003         end else begin
6004                 //\95Ò\8fW\92\86\82ÉESC\82ð\89\9f\82µ\82½\82ç\81A\95Ò\8fW\82ð\8fI\97¹\82µ\82Ä\81A\8c³\82Ì\95\8e\9a\97ñ\82É\96ß\82·
6005                 if Key = VK_ESCAPE then begin
6006                         if (TTreeView(Sender).Selected <> nil) then begin
6007                                 TTreeView(Sender).Selected.Text := FOrigenCaption;
6008                         end;
6009                         TTreeView(Sender).Selected.Focused := False;
6010                 end;
6011         end;
6012
6013 end;
6014
6015 procedure TGikoForm.FavoriteTreePopupMenuPopup(Sender: TObject);
6016 var
6017         i: Integer;
6018         LinkToolButton: TLinkToolButton;
6019 begin
6020
6021         if FavoriteTreePopupMenu.PopupComponent = FavoriteTreeView then begin
6022         
6023                 FClickNode := FavoriteTreeView.Selected;
6024
6025         end else if FavoriteTreePopupMenu.PopupComponent is TLinkToolButton then begin
6026
6027                 LinkToolButton := TLinkToolButton( FavoriteTreePopupMenu.PopupComponent );
6028                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6029                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6030                                 FClickNode := FavoriteTreeView.Items[i];
6031                                 Break;
6032                         end;
6033                 end;
6034                 for i := 0 to FClickNode.Count - 1 do begin
6035                         if FClickNode.Item[i].Data = LinkToolButton.Data then begin
6036                                 FClickNode := FClickNode.Item[i];
6037                                 Break;
6038                         end;
6039                 end;
6040
6041         end;
6042
6043         if FClickNode = nil then begin
6044                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6045                 FavoriteTreeDeletePopupMenu.Visible := False;
6046                 FavoriteTreeRenamePopupMenu.Visible := False;
6047                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6048                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6049                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6050                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6051                 FavoriteTreeReloadPopupMenu.Visible := False;
6052                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6053                 FavoriteTreeItemNameCopyPopupMenu.Visible := False;
6054         end else if FClickNode.IsFirstNode then begin
6055                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6056                 FavoriteTreeDeletePopupMenu.Visible := False;
6057                 FavoriteTreeRenamePopupMenu.Visible := False;
6058                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6059                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6060                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6061                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6062                 FavoriteTreeReloadPopupMenu.Visible := False;
6063                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6064                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6065         end else if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
6066                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6067                 FavoriteTreeDeletePopupMenu.Visible := True;
6068                 FavoriteTreeRenamePopupMenu.Visible := False;
6069                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6070                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6071                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6072                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6073                 FavoriteTreeReloadPopupMenu.Visible := False;
6074                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6075                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6076         end else if TObject(FClickNode.Data) is TFavoriteFolder then begin
6077                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6078                 FavoriteTreeDeletePopupMenu.Visible := True;
6079                 FavoriteTreeRenamePopupMenu.Visible := True;
6080                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6081                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6082                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6083                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6084                 FavoriteTreeReloadPopupMenu.Visible := False;
6085                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6086                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6087         end else if TObject(FClickNode.Data) is TFavoriteThreadItem then begin
6088                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6089                 FavoriteTreeDeletePopupMenu.Visible := True;
6090                 FavoriteTreeRenamePopupMenu.Visible := True;
6091                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6092                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6093                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6094                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6095                 FavoriteTreeReloadPopupMenu.Visible := True;
6096                 FavoriteTreeLogDeletePopupMenu.Visible := True;
6097                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6098         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
6099                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6100                 FavoriteTreeDeletePopupMenu.Visible := True;
6101                 FavoriteTreeRenamePopupMenu.Visible := True;
6102                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6103                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6104                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6105                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6106                 FavoriteTreeReloadPopupMenu.Visible := True;
6107                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6108                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6109         end else begin
6110                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6111                 FavoriteTreeDeletePopupMenu.Visible := False;
6112                 FavoriteTreeRenamePopupMenu.Visible := False;
6113                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6114                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6115                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6116                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6117                 FavoriteTreeReloadPopupMenu.Visible := False;
6118                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6119                 FavoriteTreeItemNameCopyPopupMenu.Visible := False;
6120         end;
6121
6122 end;
6123
6124 procedure TGikoForm.FavoriteBrowseFolder( node: TTreeNode );
6125 var
6126         i: Integer;
6127 begin
6128
6129         if not (TObject(node.Data) is TFavoriteFolder) then
6130                 exit;
6131
6132         for i := 0 to node.Count - 1 do
6133         begin
6134                 if TObject(node.Item[i].Data) is TFavoriteFolder then
6135                         FavoriteBrowseFolder( node.Item[i] )
6136                 else if TObject(node.Item[i].Data) is TFavoriteThreadItem then
6137                         FavoriteClick( node.Item[i], False );
6138         end;
6139
6140 end;
6141 function TGikoForm.TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
6142 var
6143         Found: TTreeNode;
6144         i: Integer;
6145 begin
6146
6147         for i := 0 to Node.Count - 1 do begin
6148                 if Node.Item[i].Data = FindPointer then begin
6149                         Result := Node.Item[i];
6150                         Exit;
6151                 end else if Node.Item[i].Count > 0 then begin
6152                         Found := TreeNodeDataFind( Node.Item[i], FindPointer );
6153                         if Found <> nil then begin
6154                                 Result := Found;
6155                                 Exit;
6156                         end;
6157                 end;
6158         end;
6159
6160         Result := nil;
6161
6162 end;
6163
6164 procedure TGikoForm.LinkToolBarDragDrop(Sender, Source: TObject; X,
6165         Y: Integer);
6166 var
6167         i: Integer;
6168         SenderNode: TTreeNode;
6169 begin
6170
6171         SenderNode := nil;
6172         for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6173                 if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6174                         SenderNode := FavoriteTreeView.Items[i];
6175                         Break;
6176                 end;
6177         end;
6178         SenderNode.Selected := False;
6179         
6180         FavoriteDragDrop( SenderNode, Source );
6181
6182         SetLinkBar;
6183 end;
6184
6185 procedure TGikoForm.BrowserTabMouseUp(Sender: TObject;
6186         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6187 begin
6188         if FDragWFirst = true then
6189                 FDragWFirst := false;
6190
6191     if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6192         if GikoSys.Setting.ListWidthState = glsMin then begin
6193             GikoDM.BrowserMaxAndFocusAction.Execute;
6194         end;
6195     end else begin
6196         if GikoSys.Setting.ListHeightState = glsMin then begin
6197             GikoDM.BrowserMaxAndFocusAction.Execute;
6198         end;
6199     end;
6200 end;
6201
6202 procedure TGikoForm.LinkToolBarDragOver(Sender, Source: TObject; X,
6203         Y: Integer; State: TDragState; var Accept: Boolean);
6204 begin
6205
6206         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
6207
6208 end;
6209
6210 procedure TGikoForm.FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
6211         Y: Integer);
6212 begin
6213
6214         if FDropSpaceNode <> nil then begin
6215                 try
6216                         FDropSpaceNode.Delete;
6217                 finally
6218                         FDropSpaceNode := nil;
6219                 end;
6220                 //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
6221                 FavoriteDM.Modified := true;
6222                 SetLinkBar;
6223         end;
6224
6225 end;
6226
6227 procedure TGikoForm.SetListViewBackGroundColor(value: TColor);
6228 begin
6229         if FListViewBackGroundColor <> value then begin
6230                 FListViewBackGroundColor := value;
6231                 ListView.Color := FListViewBackGroundColor;
6232         end;
6233 end;
6234 procedure TGikoForm.FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
6235 var
6236         threadItem      : TThreadItem;
6237         boardItem               : TBoard;
6238 begin
6239
6240         if FClickNode = nil then Exit;
6241
6242         if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
6243
6244                 threadItem := TFavoriteThreadItem( FClickNode.Data ).Item;
6245                 if threadItem = nil then
6246                         Exit;
6247                 GikoSys.OpenBrowser( threadItem.ParentBoard.URL, gbtAuto );
6248
6249         end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin
6250
6251                 boardItem := TFavoriteBoardItem( FClickNode.Data ).Item;
6252                 if boardItem = nil then
6253                         Exit;
6254                 GikoSys.OpenBrowser( boardItem.URL, gbtAuto );
6255
6256         end;
6257
6258 end;
6259
6260 procedure TGikoForm.BrowserTabContextPopup(Sender: TObject;
6261         MousePos: TPoint; var Handled: Boolean);
6262 var
6263         idx : Integer;
6264 begin
6265                 idx := BrowserTab.IndexOfTabAt(MousePos.X, MousePos.Y);
6266                 if BrowserTab.TabIndex <> idx then begin
6267                 BrowserTab.TabIndex := idx;
6268                         BrowserTab.OnChange(nil);
6269                 end;
6270 end;
6271
6272 procedure TGikoForm.KonoresCopy(Number: Integer; ReplaceTag : Boolean);
6273 var
6274         ThreadItem: TThreadItem;
6275         tmp: string;
6276         FileName: string;
6277         Res: TResRec;
6278         Header: string;
6279         Body: string;
6280         boardPlugIn : TBoardPlugIn;
6281 begin
6282         if Number = 0 then Exit;
6283         ThreadItem := GetActiveContent(True);
6284
6285         if ThreadItem <> nil then begin
6286                 //if ThreadItem.IsBoardPlugInAvailable then begin
6287         if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6288                         //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
6289                         //boardPlugIn           := ThreadItem.BoardPlugIn;
6290             boardPlugIn         := ThreadItem.ParentBoard.BoardPlugIn;
6291
6292                         // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
6293                         // \95\8e\9a\83R\81[\83h\82Í\83v\83\89\83O\83C\83\93\82É\94C\82¹\82é
6294                         //\82±\82±\82Å\82Q\82¿\82á\82ñ\82Ë\82é\82Ìdat\82Ì\8c`\8e®\82Å\82P\8ds\93Ç\82Ý\8d\9e\82ß\82ê\82Î¥¥¥\81B
6295                         tmp := boardPlugIn.GetDat( DWORD( threadItem ), Number );
6296                 end else begin
6297       FileName := ThreadItem.FilePath;
6298       tmp := GikoSys.ReadThreadFile(FileName, Number);
6299                 end;
6300                 if tmp <> '' then begin
6301                         THTMLCreate.DivideStrLine(tmp, @Res);
6302
6303                         Header := IntToStr(Number) + ' \81F' + Res.FName + ' \81F' + Res.FDateTime + #13#10;
6304                         if ReplaceTag then begin
6305                                 Header := CustomStringReplace(Header, '</b>', '',true);
6306                                 Header := CustomStringReplace(Header, '<b>', '',true);
6307                                 Header := CustomStringReplace(Header, '<br>', '',true);
6308                                 Header := DeleteFontTag(Header);
6309                         end;
6310                         //if ThreadItem.IsBoardPlugInAvailable then begin
6311             if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6312                                 Body := CustomStringReplace(Res.FBody, '<br>', #13#10,true);
6313                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6314                         end else begin
6315                                 Body := CustomStringReplace(Res.FBody, ' <br> ', #13#10,true);
6316                                 Body := CustomStringReplace(Body, ' <br>', #13#10,true);
6317                                 Body := CustomStringReplace(Body, '<br> ', #13#10,true);
6318                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6319
6320                         end;
6321                         Body := CustomStringReplace(Body, '</a>', '',true);
6322
6323                         Body := HTMLCreater.DeleteLink(Body);
6324                         if ReplaceTag then begin
6325                                 Body := CustomStringReplace(Body, '&lt;', '<');
6326                                 Body := CustomStringReplace(Body, '&gt;', '>');
6327                                 Body := CustomStringReplace(Body, '&quot;', '"');
6328                                 Body := CustomStringReplace(Body, '&amp;', '&');
6329                                 //Body := CustomStringReplace(Body, '&nbsp;', ' ');
6330                         end;
6331
6332                         Header := Header + Body;
6333
6334                         Clipboard.SetTextBuf( PChar(Header) );
6335                 end;
6336         end;
6337 end;
6338
6339
6340 procedure TGikoForm.BrowserTabPopupMenuPopup(Sender: TObject);
6341 begin
6342         AddRoundNameMenu(dummy1);
6343     AddMenuSameBoardThread;
6344 end;
6345 //! \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Á
6346 procedure TGikoForm.AddMenuSameBoardThread;
6347 var
6348         i: Integer;
6349         Item: TMenuItem;
6350 begin
6351     SameBoardThreadItem.Clear;
6352     for i := 0 to BrowserTab.Tabs.Count - 1 do begin
6353         // \93¯\82\94Â\82©\82Ç\82¤\82©
6354         if (FActiveContent.Thread.ParentBoard =
6355             TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ParentBoard) then begin
6356             // \8e©\95ª\82Í\8aO\82·
6357             if FActiveContent.Thread <>
6358                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread then begin
6359                 Item := TMenuItem.Create(Self);
6360                 Item.Caption := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.Title;
6361                 Item.OnClick := SameBoardThreadSubItemOnClick;
6362                 SameBoardThreadItem.Add(Item);
6363             end;
6364         end;
6365     end;
6366     // \89½\82à\96³\82¢\82È\82ç\8eg\97p\82Å\82«\82È\82¢\82æ\82¤\82É\82·\82é
6367     SameBoardThreadItem.Enabled := SameBoardThreadItem.Count > 0;
6368 end;
6369 //!  \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
6370 procedure TGikoForm.SameBoardThreadSubItemOnClick(Sender: TObject);
6371 var
6372         i, j: Integer;
6373         MenuItem: TMenuItem;
6374 begin
6375         if Sender is TMenuItem then begin
6376         try
6377             j := 0;
6378             MenuItem := TMenuItem(Sender);
6379             for i := 0 to BrowserTab.Tabs.Count - 1 do begin
6380                 // \93¯\82\94Â\82©\82Ç\82¤\82©
6381                 if (FActiveContent.Thread.ParentBoard =
6382                     TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ParentBoard) then begin
6383                     if FActiveContent.Thread <>
6384                         TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread then begin
6385                         if (SameBoardThreadItem.Items[j] = MenuItem) then begin
6386                             MoveToURL( TBrowserRecord(BrowserTab.Tabs.Objects[i])
6387                                 .Thread.URL);
6388                             Exit;
6389                         end;
6390                         Inc(j);
6391                     end;
6392                 end;
6393             end;
6394         except
6395         end;
6396         end;
6397 end;
6398 procedure TGikoForm.FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
6399 begin
6400         FavoriteDM.URLReplace(oldURLs, newURLs);
6401 end;
6402
6403 procedure TGikoForm.RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
6404 begin
6405         RoundList.URLReplace(oldURLs, newURLs);
6406 end;
6407
6408 procedure TGikoForm.TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
6409 const
6410         Filename = 'tab.sav';
6411         bFilename = '~tab.sav';
6412 var
6413         i, j: Integer;
6414         tempString: string;
6415         tmpURL: string;
6416         oldHost: string;
6417         oldBoardName: string;
6418         newHost: string;
6419         newBoardName: string;
6420         TabList: TStringList;
6421 begin
6422
6423         if oldURLs.Count <> newURLs.Count then begin
6424                 Exit;
6425         end;
6426         if FileExists(GikoSys.GetAppDir + 'tab.sav') then begin
6427                 TabList := TStringList.Create;
6428                 try
6429                         TabList.LoadFromFile(GikoSys.GetAppDir + Filename);
6430
6431                         //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
6432                         //\96Ê\93|\82¾\82¯\82Çthread\82Í\82»\82ê\82¼\82êURL\82ð\83`\83\83\83b\83N\82µ\82È\82ª\82ç\82â\82Á\82Ä\82©\82È\82«\82á\82¢\82¯\82È\82¢\81B
6433                         for i := 0 to oldURLs.Count - 1 do begin
6434                                         tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
6435                                         oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6436                                         oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6437                                         tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
6438                                         newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6439                                         newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6440
6441                                         for j := 0 to TabList.Count - 1 do begin
6442                                                         tempString := TabList[j];
6443                                                         if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
6444                                                                 tempString := StringReplace(tempString, oldHost, newHost,[]);
6445                                                                 TabList[j] := tempString;
6446                                                         end;
6447                                         end;
6448                         end;
6449                         //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
6450
6451                         if FileExists( GikoSys.GetAppDir + Filename) then begin
6452                                 if FileExists( GikoSys.GetAppDir + bFilename) then
6453                                         DeleteFile(GikoSys.GetAppDir + bFilename);
6454
6455                                 //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
6456                                 RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
6457                         end;
6458
6459                         TabList.SaveToFile(GikoSys.GetAppDir + Filename);
6460                 finally
6461                         TabList.Free;
6462                 end;
6463         end;
6464
6465 end;
6466
6467 /// \8dÅ\8f¬\89»\82³\82ê\82é
6468 procedure TGikoForm.OnMinimize;
6469 begin
6470         if FActiveContent <> nil then begin
6471                 FIsMinimize := mtMinimizing;
6472                 FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
6473         end;
6474 end;
6475
6476 /// \8dÅ\8f¬\89»\82³\82ê\82½ (OnResized \82©\82ç\8cÄ\82Î\82ê\82é)
6477 procedure TGikoForm.OnMinimized;
6478 begin
6479         FIsMinimize := mtMinimized;
6480 end;
6481
6482
6483 procedure TGikoForm.BrowserTabResize(Sender: TObject);
6484 begin
6485         CoolBarResized( Sender, BrowserCoolBar );
6486 end;
6487
6488 // *************************************************************************
6489 // ExternalBoardPlugInMain
6490 // \83v\83\89\83O\83C\83\93\83\81\83j\83\85\81[\82Ì\8d\80\96Ú\82ª\8eÀ\8ds\82³\82ê\82½
6491 // *************************************************************************
6492 procedure TGikoForm.OnPlugInMenuItem( Sender : TObject );
6493 var
6494         item                            : TMenuItem;
6495         boardPlugIn     : TBoardPlugIn;
6496 begin
6497
6498         if not (Sender is TMenuItem) then
6499                 Exit;
6500
6501         item := TMenuItem( Sender );
6502         if not Assigned( Pointer( item.Tag ) ) then
6503                 Exit;
6504
6505         // \83v\83\89\83O\83C\83\93\82Ì\83\81\83j\83\85\81[\83n\83\93\83h\83\89\82ð\8cÄ\82Ñ\8fo\82·
6506         boardPlugIn := TBoardPlugIn( item.Tag );
6507         boardPlugIn.PlugInMenu( item.Handle );
6508
6509 end;
6510 // TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
6511 procedure TGikoForm.TreeClick( Node : TTreeNode );
6512 begin
6513
6514         if Node = nil then
6515                 Exit;
6516
6517         if FTreeType = gttHistory then begin
6518                 if Node <> nil then
6519                         if TObject( Node.Data ) is TFavoriteThreadItem then
6520                                 if GetActiveContent <> TFavoriteThreadItem( Node.Data ).Item then
6521                                         FavoriteClick( Node );
6522                 Exit;
6523         end;
6524     //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\82Ì\82Æ\93¯\82\82È\82ç\8dÄ\95`\89æ\82µ\82È\82¢
6525         if ActiveList = Node.Data then
6526                 Exit;
6527
6528         ActiveListColumnSave;
6529
6530         if TObject(Node.Data) is TBBS then begin
6531                 SetActiveList(Node.data);
6532         end else if TObject(Node.Data) is TCategory then begin
6533                 SetActiveList(Node.data);
6534         end else if TObject(Node.Data) is TBoard then begin
6535                 if not TBoard(Node.Data).IsThreadDatRead then begin
6536                         Screen.Cursor := crHourGlass;
6537                         try
6538                 if not TBoard(Node.Data).IsThreadDatRead then
6539                                         GikoSys.ReadSubjectFile(Node.Data);
6540                         finally
6541                                 Screen.Cursor := crDefault;
6542                         end;
6543                 end;
6544                 Sort.SetSortDate(Now());
6545                 SetActiveList(Node.data);
6546         end;
6547
6548         if TObject( Node.Data ) is TBoard then begin // not TCategory
6549                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6550                         if GikoSys.Setting.ListWidthState = glsMax then begin
6551                                 GikoDM.BrowserMinAction.Execute;
6552                                 if GikoForm.Visible then
6553                                         ListView.SetFocus;
6554                         end;
6555                 end else begin
6556                         if GikoSys.Setting.ListHeightState = glsMax then begin
6557                                 GikoDM.BrowserMinAction.Execute;
6558                                 if GikoForm.Visible then
6559                                         ListView.SetFocus;
6560                         end;
6561                 end;
6562         end;
6563
6564 end;
6565
6566 // TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
6567 procedure TGikoForm.TreeDoubleClick( Node : TTreeNode );
6568 var
6569         Board                           : TBoard;
6570         ThreadItem      : TThreadItem;
6571         shiftDown       : Boolean;
6572 begin
6573
6574         if Node = nil then Exit;
6575
6576         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
6577
6578         if FTreeType = gtt2ch then begin
6579                 if not (TObject(Node.Data) is TBoard) then Exit;
6580                 Board := TBoard(Node.Data);
6581                 DownloadList(Board, shiftDown);
6582         end else if FTreeType = gttHistory then begin
6583                 if not (TObject(Node.Data) is TFavoriteThreadItem) then Exit;
6584                 ThreadItem := TFavoriteThreadItem(Node.Data).Item;
6585                 DownloadContent(ThreadItem, shiftDown);
6586         end;
6587
6588 end;
6589 // *************************************************************************
6590 //! \83c\83\8a\81[\83r\83\85\81[\82ÌKeyDown\83C\83x\83\93\83g
6591 // *************************************************************************
6592 procedure TGikoForm.TreeViewKeyDown(Sender: TObject; var Key: Word;
6593         Shift: TShiftState);
6594 begin
6595         if Key = VK_BACK then begin
6596 //              UpFolderButtonClick(Sender);
6597         end else if Key = VK_SPACE then begin
6598                 TreeDoubleClick( TreeView.Selected );
6599         end else if Key = VK_RETURN then begin
6600                 TreeClick( TreeView.Selected );
6601         // \97\9a\97ð\82Ì\8fê\8d\87\81A\8fÁ\82³\82ê\82Ä\82¢\82é\82Ì\82Å\83`\83F\83b\83N\82·\82é
6602         if (TreeView.Selected <> nil) then begin
6603                 TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
6604         end;
6605         end;
6606 end;
6607 //! \82¨\8bC\82É\93ü\82è\82ÌMouseDown\83C\83x\83\93\83g
6608 procedure TGikoForm.FavoriteTreeViewMouseDown(Sender: TObject;
6609         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6610 var
6611         favItem                         : TTreeNode;
6612         favThreadItem   : TFavoriteThreadItem;
6613         rect: TRect;
6614 begin
6615         case Button of
6616         mbLeft:
6617                 begin
6618                         if not (ssAlt in Shift) and (FavoriteTreeView.Selected <> nil) and 
6619                                 (FavoriteTreeView.Selected = FavoriteTreeView.GetNodeAt(X, Y)) then begin
6620                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
6621                                 rect := FavoriteTreeView.Selected.DisplayRect(true);
6622                                 // \83A\83C\83R\83\93\95ª\8d\82É\82¸\82ç\82·
6623                                 if ((rect.Left - FavoriteTreeView.Indent <= X) and (rect.Right >= X)) and
6624                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
6625                                         if ssDouble in Shift then begin
6626                                                 FClickNode := FavoriteTreeView.Selected;
6627                                                 GikoDM.FavoriteTreeViewReloadActionExecute(Sender);
6628                                                 FClickNode := nil;
6629                                         end else begin
6630                                                 FavoriteClick(
6631                                                         TObject(FavoriteTreeView.Selected));
6632                                         end;
6633                                 end;
6634                         end;
6635                 end;
6636         mbMiddle:
6637                 begin
6638                         favItem := FavoriteTreeView.GetNodeAt( X, Y );
6639                         if favItem = nil then Exit;
6640
6641                         if TObject( favItem.Data ) is TFavoriteThreadItem then begin
6642                                 favThreadItem := TFavoriteThreadItem( favItem.Data );
6643                                 if favThreadItem.Item <> nil then
6644                                         InsertBrowserTab( favThreadItem.Item, False );
6645                         end;
6646                 end;
6647         end;
6648
6649 end;
6650
6651 procedure TGikoForm.MessagePanelResize(Sender: TObject);
6652 begin
6653
6654         if FIsIgnoreResize <> rtNone then
6655                 Exit;
6656
6657         if GikoSys.Setting.ListOrientation = gloVertical then begin
6658                 if GikoSys.Setting.ListHeightState = glsMin then begin
6659                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
6660                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
6661                 end;
6662         end;
6663
6664 end;
6665
6666 procedure TGikoForm.OnResized;
6667 var
6668         doc                                             : Variant;
6669 begin
6670
6671         FOldFormWidth := Width;
6672         FIsIgnoreResize := rtNone;
6673
6674         case FIsMinimize of
6675         mtMinimizing:
6676                 begin
6677                         // \8dÅ\8f¬\89»\92\86\82Å\82 \82é
6678                         PostMessage( Handle, USER_MINIMIZED, 0, 0 );
6679                 end;
6680
6681         mtMinimized:
6682                 begin
6683                         // \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)
6684                         if FActiveContent <> nil then begin
6685                                 doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
6686                                 doc.Body.ScrollTop := FActiveContent.Thread.ScrollTop;
6687                         end;
6688                         FIsMinimize := mtNone;
6689                 end;
6690         end;
6691
6692 end;
6693 // *************************************************************************
6694 //! \83X\83\8c\83b\83h\83u\83\89\83E\83U\83N\83\8a\83b\83N\83C\83x\83\93\83g
6695 // *************************************************************************
6696 function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
6697 const
6698     LIMIT = 20;
6699 var
6700         p : TPoint;
6701         e: IHTMLElement;
6702         AID: string;
6703         stlist : TStringList;
6704         i, count: Integer;
6705         body : String;
6706     limited : Integer;
6707     FOleInPlaceActiveObject: IOleInPlaceActiveObject;
6708 begin
6709   result := true;
6710   try
6711         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
6712         FOleInPlaceActiveObject := FActiveContent.Browser.ControlInterface as IOleInPlaceActiveObject;
6713         FOleInPlaceActiveObject.OnFrameWindowActivate(True);
6714                 try
6715                         GetCursorPos(p);
6716                         p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
6717                         p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
6718                         e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
6719                         if (Assigned(e)) then begin
6720                                 if (e.className = 'date') or (e.id = 'date') then begin
6721                                         AID := e.innerText;
6722                                         if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
6723                                                 AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
6724                         if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
6725                                 AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
6726                         end;
6727                                         end else begin
6728                                                 stlist := TStringList.Create;
6729                                                 try
6730                                                         stList.DelimitedText := AID;
6731                                                         AID := '';
6732                                                         for i := 0 to stList.Count - 1 do
6733                                                                 if Length(WideString(stList[i])) = 8 then begin
6734                                                                         if GikoSys.NotDateorTimeString(stList[i]) then begin
6735                                                                                 AID := stList[i];
6736                                                                                 break;
6737                                                                         end;
6738                                                                 end;
6739                                                 finally
6740                                                         stList.Free;
6741                                                 end;
6742                                         end;
6743                     count := GikoSys.GetSameIDResCount(AID, FActiveContent.Thread);
6744                     limited := LIMIT;
6745                     if not (GikoSys.Setting.LimitResCountMessage) then begin
6746                         limited := -1;
6747                     end else if (count > LIMIT) then begin
6748                         if (GikoUtil.MsgBox(Handle,
6749                                 IntToStr(LIMIT) + '\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
6750                                 'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
6751                                                                 MB_YESNO or MB_ICONQUESTION) = ID_YES) then begin
6752                             limited := -1;
6753                         end
6754                     end;
6755                                         body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
6756                                         FActiveContent.IDAnchorPopup(body);
6757                                 end;
6758                         end;
6759                 except
6760                 end;
6761   except
6762   end;
6763 end;
6764
6765 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
6766 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
6767 begin
6768         SelectTimer.Interval := 0;
6769         if not (ListView.Selected = nil) then
6770                 if( FActiveContent = nil) or
6771                                 (GetActiveContent <> TThreadItem(ListView.Selected.Data) ) then begin
6772                         ListClick;
6773                 end;
6774 end;
6775
6776 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
6777 procedure TGikoForm.ActiveListColumnSave;
6778 var
6779         ActivListObj    : TObject;
6780         i, id, idx              : Integer;
6781         BBSOrder                        : TGikoBBSColumnList;
6782         CategoryOrder   : TGikoCategoryColumnList;
6783         BoardOrder              : TGikoBoardColumnList;
6784 begin
6785
6786         ActivListObj := ActiveList;
6787         if ActivListObj is TBBS then begin
6788                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6789                 BBSOrder := TGikoBBSColumnList.Create;
6790                 try
6791                         for i := 0 to ListView.Columns.Count - 1 do begin
6792                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6793                                 idx := ListView.Column[ i ].Tag;
6794                                 id := Ord( GikoSys.Setting.BBSColumnOrder[ idx ] );
6795                                 BBSOrder.Add( TGikoBBSColumnID( id ) );
6796                                 // \95\9d\82Ì\95Û\91
6797                                 GikoSys.Setting.BBSColumnWidth[ id ] := ListView.Column[ i ].Width;
6798                         end;
6799                         for i := 0 to ListView.Columns.Count - 1 do
6800                                 // \8f\87\8f\98\82Ì\95Û\91
6801                                 GikoSys.Setting.BBSColumnOrder[ i ] := BBSOrder[ i ];
6802                 finally
6803                         BBSOrder.Free;
6804                 end;
6805         end else if ActivListObj is TCategory then begin
6806                 //===== \94Â\83\8a\83X\83g =====
6807                 CategoryOrder := TGikoCategoryColumnList.Create;
6808                 try
6809                         for i := 0 to ListView.Columns.Count - 1 do begin
6810                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6811                                 idx := ListView.Column[ i ].Tag;
6812                                 id := Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] );
6813                                 CategoryOrder.Add( TGikoCategoryColumnID( id ) );
6814                                 // \95\9d\82Ì\95Û\91
6815                                 GikoSys.Setting.CategoryColumnWidth[ id ] := ListView.Column[ i ].Width;
6816                         end;
6817                         for i := 0 to ListView.Columns.Count - 1 do
6818                                 // \8f\87\8f\98\82Ì\95Û\91
6819                                 GikoSys.Setting.CategoryColumnOrder[ i ] := CategoryOrder[ i ];
6820                 finally
6821                         CategoryOrder.Free;
6822                 end;
6823         end else if ActivListObj is TBoard then begin
6824                 //===== \83X\83\8c\83\8a\83X\83g =====
6825                 BoardOrder := TGikoBoardColumnList.Create;
6826                 try
6827                         for i := 0 to ListView.Columns.Count - 1 do begin
6828                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6829                                 idx := ListView.Column[ i ].Tag;
6830                                 id := Ord( GikoSys.Setting.BoardColumnOrder[ idx ] );
6831                                 BoardOrder.Add( TGikoBoardColumnID( id ) );
6832                                 // \95\9d\82Ì\95Û\91
6833                                 GikoSys.Setting.BoardColumnWidth[ id ] := ListView.Column[ i ].Width;
6834                         end;
6835                         for i := 0 to ListView.Columns.Count - 1 do
6836                                 // \8f\87\8f\98\82Ì\95Û\91
6837                                 GikoSys.Setting.BoardColumnOrder[ i ] := BoardOrder[ i ];
6838                 finally
6839                         BoardOrder.Free;
6840                 end;
6841         end;
6842
6843 end;
6844
6845 procedure TGikoForm.ListViewColumnRightClick(Sender: TObject;
6846         Column: TListColumn; Point: TPoint);
6847 var
6848         i, j    : Integer;
6849         item    : TMenuItem;
6850 begin
6851
6852         // \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82ð\83N\83\8a\83A
6853         for i := ListColumnPopupMenu.Items.Count - 1 downto 0 do
6854                 ListColumnPopupMenu.Items.Items[ i ].Free;
6855
6856         // \83\81\83j\83\85\81[\82Ì\8dì\90¬ (\83\81\83C\83\93\83J\83\89\83\80\82Í\95K\90{\82È\82Ì\82Å\83\81\83j\83\85\81[\82É\8aÜ\82ß\82È\82¢)
6857         if TObject( FActiveList ) is TBBS then begin
6858
6859                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6860                 for i := 1 to Length( GikoBBSColumnCaption ) - 1 do begin
6861                         item := TMenuItem.Create( ListColumnPopupMenu );
6862                         item.Caption := GikoBBSColumnCaption[ i ];
6863                         item.Tag := i;
6864                         item.OnClick := ListColumnPopupMenuOnClick;
6865                         for j := GikoSys.Setting.BBSColumnOrder.Count - 1 downto 0 do begin
6866                                 if GikoSys.Setting.BBSColumnOrder[ j ] = TGikoBBSColumnID( i ) then begin
6867                                         item.Checked := True;
6868                                         Break;
6869                                 end;
6870                         end;
6871                         ListColumnPopupMenu.Items.Add( item );
6872                 end;
6873
6874         end else if TObject( FActiveList ) is TCategory then begin
6875
6876                 //===== \94Â\83\8a\83X\83g =====
6877                 for i := 1 to Length( GikoCategoryColumnCaption ) - 1 do begin
6878                         item := TMenuItem.Create( ListColumnPopupMenu );
6879                         item.Caption := GikoCategoryColumnCaption[ i ];
6880                         item.Tag := i;
6881                         item.OnClick := ListColumnPopupMenuOnClick;
6882                         for j := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 0 do begin
6883                                 if GikoSys.Setting.CategoryColumnOrder[ j ] = TGikoCategoryColumnID( i ) then begin
6884                                         item.Checked := True;
6885                                         Break;
6886                                 end;
6887                         end;
6888                         ListColumnPopupMenu.Items.Add( item );
6889                 end;
6890
6891         end else if TObject( FActiveList ) is TBoard then begin
6892
6893                 //===== \83X\83\8c\83\8a\83X\83g =====
6894                 for i := 1 to Length( GikoBoardColumnCaption ) - 1 do begin
6895                         item := TMenuItem.Create( ListColumnPopupMenu );
6896                         item.Caption := GikoBoardColumnCaption[ i ];
6897                         item.Tag := i;
6898                         item.OnClick := ListColumnPopupMenuOnClick;
6899                         for j := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 0 do begin
6900                                 if GikoSys.Setting.BoardColumnOrder[ j ] = TGikoBoardColumnID( i ) then begin
6901                                         item.Checked := True;
6902                                         Break;
6903                                 end;
6904                         end;
6905                         ListColumnPopupMenu.Items.Add( item );
6906                 end;
6907
6908         end;
6909
6910         // \83\81\83j\83\85\81[\82Ì\95\\8e¦
6911         Point := ListView.ClientToScreen( Point );
6912         if ListColumnPopupMenu.Items.Count > 0 then
6913                 ListColumnPopupMenu.Popup( Point.X, Point.Y );
6914
6915 end;
6916
6917 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
6918 procedure       TGikoForm.ListColumnPopupMenuOnClick( Sender : TObject );
6919 var
6920         i                                       : Integer;
6921         orderList       : TList;
6922         item                    : TMenuItem;
6923 begin
6924
6925         if not (Sender is TMenuItem) then
6926                 Exit;
6927
6928         ActiveListColumnSave;
6929         item := TMenuItem( Sender );
6930
6931         if TObject( FActiveList ) is TBBS then
6932                 orderList := GikoSys.Setting.BBSColumnOrder
6933         else if TObject( FActiveList ) is TCategory then
6934                 orderList := GikoSys.Setting.CategoryColumnOrder
6935         else if TObject( FActiveList ) is TBoard then
6936                 orderList := GikoSys.Setting.BoardColumnOrder
6937         else
6938                 Exit;
6939
6940         if item.Checked then begin
6941                 // \83J\83\89\83\80\82Ì\8dí\8f\9c
6942                 for i := orderList.Count - 1 downto 0 do begin
6943                         if Integer( orderList[ i ] ) = item.Tag then begin
6944                                 orderList.Delete( i );
6945                                 Break;
6946                         end;
6947                 end;
6948         end else begin
6949                 // \83J\83\89\83\80\82Ì\92Ç\89Á
6950                 orderList.Add( Pointer( item.Tag ) );
6951         end;
6952
6953         SetActiveList( FActiveList );
6954
6955 end;
6956
6957 procedure TGikoForm.OnGestureStart(Sender: TObject);
6958 begin
6959 //
6960 end;
6961
6962 procedure TGikoForm.OnGestureMove(Sender: TObject);
6963 var
6964         s: string;
6965         Action: TAction;
6966         ActStr: string;
6967         P : TPoint;
6968 begin
6969         //\83}\83E\83X\88Ê\92u\82Ì\8eæ\93¾
6970         GetCursorPos(P);
6971         //\83R\83\93\83|\81[\83l\83\93\83g\96¼\8eæ\93¾
6972         s := MouseGesture.GetGestureStr;
6973         ActStr := '';
6974         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
6975         if Action <> nil then
6976                 ActStr := '\81i' + Action.Caption + '\81j';
6977         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
6978         StatusBar.Panels[1].Text := s;
6979 end;
6980
6981 procedure TGikoForm.OnGestureEnd(Sender: TObject);
6982 var
6983         s: string;
6984         Action: TAction;
6985 begin
6986         s := MouseGesture.GetGestureStr;
6987     MouseGesture.Clear;
6988         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
6989         if Action <> nil then
6990                 Action.Execute;
6991         StatusBar.Panels[1].Text := '';
6992 end;
6993
6994 procedure TGikoForm.ListViewCustomDrawItem(Sender: TCustomListView;
6995   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
6996 var
6997         ThreadItem: TThreadItem;
6998 begin
6999         DefaultDraw := true;
7000         if TObject(Item.Data) is TThreadItem then begin
7001                 ThreadItem := TThreadItem(Item.Data);
7002                 if ( FUseOddResOddColor ) and ( ThreadItem.Count <> 0 ) and ( ThreadItem.AllResCount <> ThreadItem.Count) then begin
7003                         ListView.Canvas.Brush.Color := FOddColor;
7004                         //\91I\91ð\82³\82ê\82Ä\82¢\82é\82¯\82Ç\81A\83t\83H\81[\83J\83X\82ª\82È\82¢\82Æ\81A\83O\83\8c\83C\82É\82È\82é\82Ì\82Å\81A\91¾\8e\9a\82É\95Ï\8dX
7005                         if (GikoSys.Setting.UnFocusedBold) and
7006                          (Item.Selected) and (not ListView.Focused) then begin
7007                                 ListView.Canvas.Font.Style := [fsBold];
7008                         end;
7009                 end else begin
7010                         ListView.Canvas.Brush.Color := FListViewBackGroundColor;
7011                 end;
7012
7013                 if ThreadItem.UnRead then
7014                         ListView.Canvas.Font.Style := [fsBold];
7015         end;
7016
7017 end;
7018
7019 procedure TGikoForm.FormActivate(Sender: TObject);
7020 begin
7021         if GikoSys.Setting.GestureEnabled then begin
7022                 GikoSys.Setting.Gestures.ClearGesture;
7023                 GikoSys.Setting.Gestures.LoadGesture(
7024                         GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
7025                 MouseGesture.UnHook;
7026                 MouseGesture.OnGestureStart := OnGestureStart;
7027                 MouseGesture.OnGestureMove := OnGestureMove;
7028                 MouseGesture.OnGestureEnd := OnGestureEnd;
7029                 MouseGesture.SetHook(Handle);
7030         end else begin
7031                 //MouseGesture.UnHook;
7032                 MouseGesture.OnGestureStart := nil;
7033                 MouseGesture.OnGestureMove := nil;
7034                 MouseGesture.OnGestureEnd := nil;
7035         end;
7036 end;
7037
7038 procedure TGikoForm.BrowserPanelResize(Sender: TObject);
7039 begin
7040     if (FIsMinimize <> mtMinimizing) then begin
7041         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
7042                 MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
7043         end;
7044     end;
7045 end;
7046 procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
7047 var
7048         coolSet                         : TCoolSet;
7049         toolbar                         : TToolBar;
7050         band                                    : TCoolBand;
7051         affectedBand    : TCoolBand;
7052         i                                                       : Integer;
7053 begin
7054         if (FOldFormWidth = Width) and not IsIconic( Handle ) and (FIsIgnoreResize = rtNone) then begin
7055                 FIsIgnoreResize := rtResizing;
7056                 PostMessage( Handle, USER_RESIZED, 0, 0 );
7057                 band := nil;
7058                 // \95Ï\8dX\82³\82ê\82½\83N\81[\83\8b\83o\81[\82Ì\92l\82ð\95Û\91
7059                 if CoolBar = MainCoolBar then begin
7060                         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
7061                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7062                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7063                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7064                                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
7065                         end;
7066                 end else if CoolBar = ListCoolBar then begin
7067                         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
7068                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7069                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7070                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7071                                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
7072                         end;
7073                 end else if CoolBar = BrowserCoolBar then begin
7074                         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
7075                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7076                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7077                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7078                                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
7079                         end;
7080                 end;
7081                 if not (Sender is TToolBar) or (CoolBar = nil) then
7082                         Exit;
7083                 toolbar := TToolBar( Sender );
7084                 // \95\9d\82Ì\95Ï\8dX\82³\82ê\82½\83o\83\93\83h\82ð\8c©\82Â\82¯\82é
7085                 affectedBand := nil;
7086                 for i := CoolBar.Bands.Count - 1 downto 0 do begin
7087                         if CoolBar.Bands[ i ].Control.Handle = toolbar.Handle then begin
7088                                 band    := CoolBar.Bands[ i ];
7089                                 if band.Break or (i = 0) then begin
7090                                         if i + 1 < CoolBar.Bands.Count then
7091                                                 if not CoolBar.Bands[ i + 1 ].Break then
7092                                                         affectedBand := CoolBar.Bands[ i + 1 ];
7093                                 end else begin
7094                                         if i > 0 then
7095                                                 affectedBand := CoolBar.Bands[ i - 1 ];
7096                                 end;
7097                                 Break;
7098                         end;
7099                 end;
7100                 // \83h\83\89\83b\83O\92\86\82Í band.Width \82ª\8dX\90V\82³\82ê\82È\82¢\82Ì\82Å\81A\93à\91¤\82Ì\83T\83C\83Y\82©\82ç\82Ð\82Ë\82è\8fo\82·
7101                 if CoolBar = MainCoolBar then begin
7102                         coolSet := GikoSys.Setting.MainCoolSet[ band.ID ];
7103                         coolSet.FCoolWidth := toolbar.Width + 25;
7104                         GikoSys.Setting.MainCoolSet[ band.ID ] := coolSet;
7105                         if affectedBand <> nil then begin
7106                                 coolSet := GikoSys.Setting.MainCoolSet[ affectedBand.ID ];
7107                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7108                                 GikoSys.Setting.MainCoolSet[ affectedBand.ID ] := coolSet;
7109                         end;
7110                 end else if CoolBar = ListCoolBar then begin
7111                         coolSet := GikoSys.Setting.ListCoolSet[ band.ID ];
7112                         coolSet.FCoolWidth := toolbar.Width + 25;
7113                         GikoSys.Setting.ListCoolSet[ band.ID ] := coolSet;
7114                         if affectedBand <> nil then begin
7115                                 coolSet := GikoSys.Setting.ListCoolSet[ affectedBand.ID ];
7116                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7117                                 GikoSys.Setting.ListCoolSet[ affectedBand.ID ] := coolSet;
7118                         end;
7119                 end else if CoolBar = BrowserCoolBar then begin
7120                         coolSet := GikoSys.Setting.BrowserCoolSet[ band.ID ];
7121                         coolSet.FCoolWidth := toolbar.Width + 25;
7122                         GikoSys.Setting.BrowserCoolSet[ band.ID ] := coolSet;
7123                         if affectedBand <> nil then begin
7124                                 coolSet := GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ];
7125                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7126                                 GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ] := coolSet;
7127                         end;
7128                 end;
7129         end;
7130 end;
7131
7132
7133 procedure TGikoForm.MenuToolBarResize(Sender: TObject);
7134 begin
7135         CoolBarResized( Sender, MainCoolBar );
7136 end;
7137
7138 procedure TGikoForm.ListToolBarResize(Sender: TObject);
7139 begin
7140         CoolBarResized( Sender, ListCoolBar );
7141 end;
7142
7143 procedure TGikoForm.BrowserToolBarResize(Sender: TObject);
7144 begin
7145         CoolBarResized( Sender, BrowserCoolBar );
7146 end;
7147
7148 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
7149 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
7150 var
7151         ThreadItem      : TThreadItem;
7152         ReadList                : TStringList;
7153         wordCount               : TWordCount;
7154 begin
7155         ThreadItem      := GetActiveContent(True);
7156         ReadList                := TStringList.Create;
7157         wordCount               := TWordCount.Create;
7158         try
7159                 ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7160 {$IFDEF SPAM_FILTER_ENABLED}
7161                 // \83X\83p\83\80\82É\90Ý\92è
7162                 ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7163                 GikoSys.SpamCountWord( ReadList[ ATag - 1 ], wordCount );
7164                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7165                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7166 {$ENDIF}
7167                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7168                 GikoSys.FAbon.AddIndividualAbon(Atag, Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7169         finally
7170                 wordCount.Free;
7171                 ReadList.Free;
7172         end;
7173         FActiveContent.Repaint := true;
7174         if ThreadItem <> nil then
7175                 InsertBrowserTab( ThreadItem, True );
7176 end;
7177 //\93¯\88êID\82ðNG\83\8f\81[\83h\82É\93o\98^
7178 procedure TGikoForm.AddIDtoNGWord(invisible : boolean);
7179 var
7180         ThreadItem : TThreadItem;
7181         No : Integer;
7182 {$IFDEF SPAM_FILTER_ENABLED}
7183         body : TStringList;
7184         ReadList                : TStringList;
7185         wordCount               : TWordCount;
7186 {$ENDIF}
7187     id, dateStr: String;
7188 begin
7189         No := KokoPopupMenu.Tag;
7190         if No = 0 then Exit;
7191         ThreadItem := GetActiveContent(True);
7192         if ThreadItem = nil then Exit;
7193
7194     id := GikoSys.GetResID(No, ThreadItem);
7195     if (id <> '') and (not IsNoValidID(id)) then begin
7196         // \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Á
7197         DateTimeToString(dateStr, 'yyyymmdd', Now);
7198         id := id + #9'>>add ' + dateStr + ',' + ThreadItem.Title;
7199         if (GikoSys.FAbon.AddToken(id, invisible)) then begin
7200             GikoSys.FAbon.ReLoadFromNGwordFile;
7201             FActiveContent.Repaint := True;
7202         end;
7203     end else begin
7204         ShowMessage('ID\82ð\8eæ\93¾\82Å\82«\82Ü\82¹\82ñ\82Å\82µ\82½\81B');
7205     end;
7206 {$IFDEF SPAM_FILTER_ENABLED}
7207     body := TStringList.Create;
7208     try
7209         GikoSys.GetSameIDRes(id, ThreadItem, body);
7210         ReadList                := TStringList.Create;
7211         wordCount               := TWordCount.Create;
7212         try
7213             // \83X\83p\83\80\82É\90Ý\92è
7214             ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7215             for i := 0 to body.Count - 1 do begin
7216                 GikoSys.SpamCountWord( ReadList[ i ], wordCount );
7217                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7218                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7219             end;
7220         finally
7221             wordCount.Free;
7222             ReadList.Free;
7223         end;
7224     finally
7225         body.Free;
7226     end;
7227 {$ENDIF}
7228     if (FActiveContent.Repaint) then begin
7229         ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7230         if ThreadItem <> nil then
7231             InsertBrowserTab( ThreadItem, True );
7232     end;
7233 end;
7234
7235 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
7236 procedure TGikoForm.IndividualAbonID(Atype : Integer);
7237 var
7238         ThreadItem : TThreadItem;
7239         i, No : Integer;
7240         body : TStringList;
7241         ReadList                : TStringList;
7242         wordCount               : TWordCount;
7243 begin
7244         No := KokoPopupMenu.Tag;
7245         if No = 0 then Exit;
7246         ThreadItem := GetActiveContent(True);
7247         if ThreadItem = nil then Exit;
7248         body := TStringList.Create;
7249         try
7250                 GikoSys.GetSameIDRes(No, ThreadItem, body);
7251
7252                 ReadList                := TStringList.Create;
7253                 wordCount               := TWordCount.Create;
7254                 try
7255                         ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7256 {$IFDEF SPAM_FILTER_ENABLED}
7257                         // \83X\83p\83\80\82É\90Ý\92è
7258                         ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7259 {$ENDIF}
7260                         for i := 0 to body.Count - 1 do begin
7261 {$IFDEF SPAM_FILTER_ENABLED}
7262                                 GikoSys.SpamCountWord( ReadList[ i ], wordCount );
7263                                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7264                                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7265 {$ENDIF}
7266                                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7267                                 GikoSys.FAbon.AddIndividualAbon(StrToInt(body[i]), Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7268                         end;
7269                 finally
7270                         wordCount.Free;
7271                         ReadList.Free;
7272                 end;
7273                 FActiveContent.Repaint := true;
7274                 if ThreadItem <> nil then
7275                         InsertBrowserTab( ThreadItem, True );
7276         finally
7277                 body.Free;
7278         end;
7279
7280 end;
7281
7282 procedure TGikoForm.KokoPopupMenuPopup(Sender: TObject);
7283 var
7284         firstElement: IHTMLElement;
7285         document: IHTMLDocument2;
7286 begin
7287         document := FActiveContent.Browser.Document as IHTMLDocument2;
7288         if Assigned(document) then
7289                 firstElement := document.all.item('idSearch', 0) as IHTMLElement;
7290                 if Assigned(firstElement) then
7291                         if firstElement.style.visibility <> 'hidden' then
7292                                 firstElement.style.visibility := 'hidden';
7293 end;
7294
7295 procedure TGikoForm.RepaintAllTabsBrowser();
7296 var
7297         i : Integer;
7298         ThreadItem: TThreadItem;
7299 begin
7300         for i := BrowserTab.Tabs.Count - 1 downto 0 do
7301                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
7302
7303         ThreadItem := GetActiveContent;
7304         if ThreadItem <> nil then
7305                 InsertBrowserTab( ThreadItem, True );
7306
7307 end;
7308
7309 //ListView\82Ì\91I\91ð\8fó\91Ô\82ð\89ð\8f\9c\82·\82é
7310 procedure TGikoForm.ListViewKeyUp(Sender: TObject; var Key: Word;
7311   Shift: TShiftState);
7312 begin
7313         //\83u\83\89\83E\83U\83^\83u\96³\82µ\82Å\81A\83L\81[\88Ú\93®\82Å\93Ç\82Ý\94ò\82Î\82µ\82ð\89Â\94\\82É\82·\82é\82½\82ß\82Ì
7314         //\96³\8cø\8e\9e\8aÔ\82ÌTimer\82Ì\8f\88\97\9d
7315         //\82Æ\82è\82 \82¦\82¸\81A\83^\83C\83}\81[\82ð\92â\8e~\82·\82é\81B
7316         SelectTimer.Interval := 0;
7317         if not (GikoSys.Setting.BrowserTabVisible) then begin
7318                 if (GetActiveList is TBoard) then begin
7319                         //Shift Alt Ctrl\82ª\98b\82³\82ê\82½\82Æ\82«\82Í\81A\95û\8cü\83L\81[\82ð\97£\82µ\82Ä\82¢\82Ä\82à\96³\8e\8b
7320                         if not ((ssShift in Shift) or (ssAlt in Shift) or (ssCtrl in Shift))  and
7321                                 (( Key = VK_LEFT) or (Key = VK_RIGHT) or
7322                                                 (Key = VK_UP) or (Key = VK_DOWN)) then
7323                                         SelectTimer.Interval := GikoSys.Setting.SelectInterval;
7324                 end;
7325         end;
7326 end;
7327 // *************************************************************************
7328 //! \82¨\8bC\82É\93ü\82è\82Ì\95Ò\8fW\8aJ\8en\83C\83x\83\93\83g
7329 // *************************************************************************
7330 procedure TGikoForm.FavoriteTreeViewEditing(Sender: TObject;
7331   Node: TTreeNode; var AllowEdit: Boolean);
7332 begin
7333         //\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ\82ð\88ê\8e\9e\95Û\91\82·\82é
7334         FOrigenCaption := Node.Text;
7335 end;
7336 // *************************************************************************
7337 //! Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
7338 // *************************************************************************
7339 function TGikoForm.GetMainForm(): TComponent;
7340 begin
7341         Result := Application.MainForm;
7342 end;
7343 // *************************************************************************
7344 //! \8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
7345 // *************************************************************************
7346 function TGikoForm.GetScreenCursor(): TCursor;
7347 begin
7348         Result := Screen.Cursor;
7349 end;
7350 // *************************************************************************
7351 //! \83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
7352 // *************************************************************************
7353 procedure TGikoForm.SetScreenCursor(Cursor : TCursor);
7354 begin
7355         if (Screen.Cursor <> Cursor) then
7356                 Screen.Cursor := Cursor;
7357 end;
7358 // *************************************************************************
7359 //! \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
7360 // *************************************************************************
7361 procedure TGikoForm.CabinetCloseSpeedButtonClick(Sender: TObject);
7362 begin
7363         //Action\82Å\90Ý\92è\82·\82é\82Æ\83L\83\83\83v\83V\83\87\83\93\82ª\8fÁ\82¹\82È\82¢\82Ì\82Å\81AOnClick\83C\83x\83\93\83g\82Å\82Ì
7364         //\8cÄ\82Ñ\8fo\82µ\82É\82µ\82½\81@by \82à\82\82ã
7365         if GikoDM.CabinetVisibleAction.Enabled then begin
7366                 GikoDM.CabinetVisibleAction.Execute;
7367         end;
7368 end;
7369 // *************************************************************************
7370 //! \82¨\8bC\82É\93ü\82è\83L\83\83\83r\83l\83b\83g\82Ì\90®\97\9d\83{\83^\83\93\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
7371 // *************************************************************************
7372 procedure TGikoForm.FavoriteArrangeToolButtonClick(Sender: TObject);
7373 begin
7374         if GikoDM.FavoriteArrangeAction.Enabled then begin
7375                 GikoDM.FavoriteArrangeAction.Execute;
7376         end;
7377 end;
7378 // *************************************************************************
7379 //! \83M\83R\83i\83r\82Ì\83\81\83b\83Z\81[\83W\83n\83\93\83h\83\8a\83\93\83O    (\92\8d\88Ó\81j\8f\88\97\9d\97Ê\82É\92\8d\88Ó\81I
7380 // *************************************************************************
7381 procedure TGikoForm.GikoApplicationEventsMessage(var Msg: tagMSG;
7382   var Handled: Boolean);
7383 var
7384         wmMsg: TWMKey;
7385 begin
7386         //GikoForm\82ª\83A\83N\83e\83B\83u\82È\82Æ\82«\82¾\82¯\8eó\82¯\8eæ\82é \91¼\82Ì\83t\83H\81[\83\80\82Ì\82ð\89¡\8eæ\82è\82µ\82È\82¢\82½\82ß
7387         if Self.Active then begin
7388                 case Msg.message of
7389                         //\83L\81[\93ü\97Í\82·\82×\82Ä
7390                         WM_KEYFIRST..WM_KEYLAST :
7391                         begin
7392                                 //\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ç
7393                                 if (Msg.message <> WM_KEYUP)
7394                     and (Msg.message <> WM_CHAR)
7395                     and (Msg.message <> WM_SYSKEYUP) then begin
7396                                         wmMsg.Msg := Msg.message;
7397                                         wmMsg.CharCode := Word(Msg.wParam);
7398                                         wmMsg.KeyData := Msg.lParam;
7399                                         //\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\82Ì\8f\88\97\9d\82É\93]\91\97
7400                                         Self.OnShortCut(wmMsg, Handled);
7401                                 end;
7402                         end;
7403                 end;
7404         end else begin
7405         // Explorer\82ÌD&D\82ð\8eó\82¯\82é\82Æ\82Ì\94ñ\83A\83N\83e\83B\83u
7406         if Msg.message = WM_DROPFILES then begin
7407             AcceptDropFiles(Msg);
7408             Handled := True;
7409         end;
7410     end;
7411 end;
7412 // *************************************************************************
7413 //! \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
7414 // *************************************************************************
7415 procedure TGikoForm.GikoApplicationEventsDeactivate(Sender: TObject);
7416 begin
7417         Application.ProcessMessages;
7418         if not Application.Terminated then begin
7419                 if PreviewTimer.Enabled then
7420                 PreviewTimer.Enabled := False;
7421                 //\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
7422         if (FResPopupBrowser <> nil) then
7423             FResPopupBrowser.Clear;
7424
7425                 //\83v\83\8c\83r\83\85\81[\82ð\89B\82·
7426                 if FPreviewBrowser <> nil then
7427                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
7428         end;
7429
7430 end;
7431 // *************************************************************************
7432 //! \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\8f\88\97\9d\82³\82ê\82È\82¢\97á\8aO\82ð\8fE\82Á\82½\82Æ\82«\82Ì\83C\83x\83\93\83g
7433 // *************************************************************************
7434 procedure TGikoForm.GikoApplicationEventsException(Sender: TObject;
7435   E: Exception);
7436 var
7437         s : String;
7438 begin
7439         if (Sender <> nil) then begin
7440                 s := ' [' + Sender.ClassName + ']' + #13#10;
7441         end else begin
7442                 s := ' [ Sender is nil ] ' + #13#10;
7443         end;
7444         s := s + E.Message;
7445         MsgBox(Handle, s, '\8f\88\97\9d\82³\82ê\82È\82©\82Á\82½\97á\8aO', MB_OK or MB_ICONSTOP);
7446 end;
7447 // *************************************************************************
7448 //! \83_\83E\83\93\83\8d\81[\83h\83R\83\93\83g\83\8d\81[\83\8b\83X\83\8c\83b\83h\82Ì\90\90¬
7449 // *************************************************************************
7450 procedure TGikoForm.CreateControlThread();
7451 begin
7452         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
7453         FControlThread := TThreadControl.Create(True);
7454         FControlThread.MaxThreadCount := 1;
7455         FControlThread.Resume;
7456         FControlThread.OnDownloadEnd := DownloadEnd;
7457         FControlThread.OnDownloadMsg := DownloadMsg;
7458         FControlThread.OnWork := Work;
7459         FControlThread.OnWorkBegin := WorkBegin;
7460         FControlThread.OnWorkEnd := WorkEnd;
7461 end;
7462 // *************************************************************************
7463 //! \83u\83\89\83E\83U\82Ì\90\90¬
7464 // *************************************************************************
7465 procedure TGikoForm.CreateBrowsers(count: Integer);
7466 var
7467         i: Integer;
7468         newBrowser: TWebBrowser;
7469 begin
7470         BrowserNullTab := TBrowserRecord.Create;
7471         BrowserNullTab.Browser := Browser;
7472         BrowserNullTab.Browser.Navigate(BLANK_HTML);
7473
7474         FBrowsers := TList.Create;
7475         for i := 0 to count -1 do begin
7476                 FBrowsers.Add(TWebBrowser.Create(BrowserPanel));
7477                 newBrowser := FBrowsers[FBrowsers.Count - 1];
7478                 TOleControl(newBrowser).Parent := BrowserPanel;
7479                 TOleControl(newBrowser).Align := alNone;
7480                 TOleControl(newBrowser).Left    := 0;
7481                 TOleControl(newBrowser).Top     := 0;
7482                 newBrowser.RegisterAsDropTarget := False;
7483                 newBrowser.OnDocumentComplete   := BrowserDocumentComplete;
7484                 newBrowser.OnBeforeNavigate2    := BrowserBeforeNavigate2;
7485                 newBrowser.OnEnter                              := BrowserEnter;
7486                 newBrowser.OnNewWindow2                 := BrowserNewWindow2;
7487                 newBrowser.OnStatusTextChange   := BrowserStatusTextChange;
7488                 newBrowser.Navigate(BLANK_HTML);
7489                 ShowWindow(newBrowser.Handle, SW_HIDE);
7490         end;
7491         BrowserNullTab.Browser.BringToFront;
7492         ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
7493
7494         //\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Ì
7495         //\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Å
7496         //\82±\82±\82Å\8fI\82í\82ç\82¹\82Ä\82¨\82­
7497         while (Browser.ReadyState <> READYSTATE_COMPLETE) and
7498                 (Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
7499                 Application.ProcessMessages;
7500         end;
7501 end;
7502 // *************************************************************************
7503 //! \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é
7504 // *************************************************************************
7505 procedure TGikoForm.SetSelectComboBox();
7506 const
7507         DUMMYCOMPNAME = 'SelectComboBoxDummy';
7508 var
7509         i: Integer;
7510         ToolButton: TToolButton;
7511 begin
7512         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
7513         SelectComboBoxPanel.Visible := False;
7514         try
7515                 for i := ListToolBar.ControlCount - 1 downto 0 do
7516                 begin
7517                         if ListToolBar.Controls[ i ].Action = GikoDM.SelectItemAction then
7518                         begin
7519                                 SelectComboBoxPanel.Left := ListToolBar.Controls[ i ].Left;
7520                                 SelectComboBoxPanel.Width := GikoSys.Setting.SelectComboBoxWidth;
7521                                 SelectComboBoxPanel.Parent := ListToolBar;
7522                                 SelectComboBoxPanel.Visible := True;
7523
7524                                 SelectComboBox.Left := 0;
7525                                 SelectComboBox.Top  := 0;
7526                                 SelectComboBox.Height := SelectComboBoxPanel.ClientHeight;
7527                                 SelectComboBox.Width := SelectComboBoxPanel.Width -
7528                                                                                 SelectComboBoxSplitter.Width;
7529
7530                                 //\88ê\82Â\8c©\82¦\82È\82¢\83{\83^\83\93\82ð\93Ë\82Á\8d\9e\82Þ
7531                                 ToolButton := TToolButton(ListToolBar.FindComponent(DUMMYCOMPNAME));
7532                                 if ToolButton = nil then begin
7533                                         ToolButton := TToolButton.Create(ListToolBar);
7534                                         ToolButton.Name := DUMMYCOMPNAME;
7535                                 end;
7536                                 ToolButton.Style := tbsSeparator;
7537                                 ToolButton.Width := 0;
7538                                 ToolButton.Left  := ListToolBar.Controls[ i ].Left;
7539                                 ListToolBar.InsertControl(ToolButton);
7540                                 ToolButton.Visible := False;
7541
7542                                 // \83X\83\8c\83b\83h\8di\8d\9e\82Ì\97×\82É\83Z\83p\83\8c\81[\83^\82ª\82 \82é\8fê\8d\87\82Í\89B\82·
7543                                 if (i + 1) < ListToolBar.ControlCount then
7544                                         if ListToolBar.Controls[ i + 1 ] is TToolButton then
7545                                                 if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
7546                                                         ListToolBar.Controls[ i + 1 ].Visible := False;
7547
7548
7549                                 // \83X\83\8c\83b\83h\8di\8d\9e\83{\83^\83\93\82ð\89B\82·
7550                                 ListToolBar.Controls[ i ].Visible := False;
7551
7552                                 break;
7553                         end;
7554                 end;
7555         except
7556         end;
7557 end;
7558 //! \83L\83\83\83r\83l\83b\83g\82Ì\83}\83E\83X\83_\83E\83\93\83C\83x\83\93\83g
7559 procedure TGikoForm.TreeViewMouseDown(Sender: TObject;
7560   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
7561 var
7562         rect : TRect;
7563 begin
7564         case Button of
7565         mbLeft:
7566                 begin
7567                         if (TreeView.Selected <> nil) and
7568                                 (TreeView.Selected = TreeView.GetNodeAt(X, Y)) then begin
7569                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
7570                                 rect := TreeView.Selected.DisplayRect(true);
7571                                 // \83A\83C\83R\83\93\95ª\82¾\82¯\8d\82É\82¸\82ç\82·
7572                                 if ((rect.Left - TreeView.Indent <= X) and (rect.Right >= X)) and
7573                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
7574                                         // \83N\83\8a\83b\83N\82Æ\83_\83u\83\8b\83N\83\8a\83b\83N\82ð\83R\83R\82Å\94»\92è
7575                                         if ssDouble in Shift then begin
7576                                                 TreeDoubleClick( TreeView.Selected );
7577                                         end else begin
7578                                                 TreeClick(TreeView.Selected);
7579                                         end;
7580                                 end;
7581                         end;
7582                 end;
7583         end;
7584 end;
7585 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
7586 procedure TGikoForm.GetGroupIndex(ActionList: TActionList);
7587 var
7588         i: Integer;
7589 begin
7590         if ActionList <> nil then begin
7591                 SetLength(FActionListGroupIndexes, ActionList.ActionCount);
7592
7593                 for i := 0 to ActionList.ActionCount - 1 do begin
7594                         try
7595                                 FActionListGroupIndexes[i] :=
7596                                         TCustomAction(ActionList.Actions[i]).GroupIndex;
7597                                 TCustomAction(ActionList.Actions[i]).GroupIndex
7598                                         := 0;
7599                         except
7600                                 ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7601                         end;
7602                 end;
7603
7604         end;
7605 end;
7606 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
7607 procedure TGikoForm.SetGroupIndex(ActionList: TActionList);
7608 var
7609         i: Integer;
7610 begin
7611         if ActionList <> nil then begin
7612                 if Length( FActionListGroupIndexes ) = ActionList.ActionCount then begin
7613                         for i := 0 to ActionList.ActionCount - 1 do begin
7614                                 try
7615                                         TCustomAction(ActionList.Actions[i]).GroupIndex
7616                                                 := FActionListGroupIndexes[i];
7617                                 except
7618                                         ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7619                                 end;
7620                         end;
7621                 end;
7622         end;
7623 end;
7624 //! \82±\82Ì\83\8c\83X\82ÌURL\8eæ\93¾
7625 procedure TGikoForm.GetResURLMenuClick(Sender: TObject);
7626 begin
7627 ;
7628 end;
7629 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
7630 procedure TGikoForm.RefreshListView(Thread: TThreadItem);
7631 begin
7632         //Thread\82Ì\94Â\82Æ\95\\8e¦\82µ\82Ä\82¢\82é\94Â\82ª\93¯\82\82È\82ç\95`\89æ\82ð\8dX\90V\82·\82é
7633         if (FActiveList is TBoard) and (TBoard(ActiveList) = Thread.ParentBoard) then begin
7634                 ListView.Refresh;
7635         end;
7636 end;
7637
7638 procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
7639   MousePos: TPoint; var Handled: Boolean);
7640 var
7641     pos : TPoint;
7642     coolBar: TGikoCoolBar;
7643 begin
7644     Handled := False;
7645     if (Sender <> nil) and (Sender is TGikoCoolBar) then begin
7646         coolBar := TGikoCoolBar(Sender);
7647         if (coolBar = MainCoolBar) then begin
7648             FToolBarSettingSender := tssMain;
7649         end else if (coolBar = ListCoolBar) then begin
7650             FToolBarSettingSender := tssList;
7651         end else if (coolBar = BrowserCoolBar) then begin
7652             FToolBarSettingSender := tssBrowser;
7653         end else begin
7654             FToolBarSettingSender := tssNone;
7655         end;
7656         pos := coolBar.ClientToScreen( MousePos );
7657         MainCoolBarPopupMenu.Popup( pos.X, pos.Y );
7658         Handled := True;
7659     end;
7660 end;
7661
7662 procedure TGikoForm.TaskTrayIconMessage(var Msg: TMsg);
7663 begin
7664     //  \8d\83N\83\8a\83b\83N\82È\82ç\95\9c\8c³\82·\82é
7665     if  (Msg.wParam = WM_LBUTTONUP) then  begin
7666         UnStoredTaskTray;
7667     end;
7668 end;
7669 //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
7670 procedure TGikoForm.StoredTaskTray;
7671 begin
7672     try
7673         if (FIconData.uID = 0) then begin
7674             FIconData.cbSize  :=  SizeOf(TNotifyIconData);
7675             FIconData.uID     :=  Self.Handle;
7676             FIconData.Wnd     :=  Handle;
7677             FIconData.uFlags  :=  NIF_MESSAGE or NIF_ICON or NIF_TIP;
7678             FIconData.uCallbackMessage  :=  USER_TASKTRAY;
7679             FIconData.hIcon   :=  Application.Icon.Handle;  {\83A\83C\83R\83\93\8ew\92è}
7680             FIconData.szTip   :=  '\83M\83R\83i\83r';      {\83q\83\93\83g\95\8e\9a\97ñ}
7681             Shell_NotifyIcon(NIM_ADD, @FIconData);
7682             ShowEditors(SW_HIDE);
7683             ShowWindow(Self.Handle, SW_HIDE);
7684         end;
7685     except
7686     end;
7687 end;
7688 //! \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¦
7689 procedure TGikoForm.UnStoredTaskTray;
7690 begin
7691     try
7692         try
7693             Shell_NotifyIcon(NIM_DELETE, @FIconData);
7694             SetForegroundWindow(Application.Handle);
7695         except
7696         end;
7697     finally
7698         FIconData.uID := 0;
7699         // Action\82©\82ç\8ai\94[\82µ\82½\82Æ\82«\82ÍTag\82Ì\92l\82Í0\88È\8aO
7700         if (GikoDM.StoredTaskTrayAction.Tag = 0) then begin
7701             ShowWindow(Self.Handle, SW_RESTORE);
7702         end else begin
7703             ShowWindow(Self.Handle, SW_SHOW);
7704         end;
7705         ShowEditors(SW_SHOW);
7706         GikoDM.StoredTaskTrayAction.Tag := 0;
7707     end;
7708 end;
7709 {
7710 \brief \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
7711 \param nCmdShow Windows.ShowWindow\82É\91\97\82é\83p\83\89\83\81\81[\83^\82Æ\93¯\82
7712 }
7713 procedure TGikoForm.ShowEditors(nCmdShow: Integer);
7714 var
7715     i : Integer;
7716 begin
7717     // \83\8c\83X\83G\83f\83B\83^\82ð\92T\82·
7718     for i := 0 to Screen.CustomFormCount - 1 do begin
7719         if TObject(Screen.CustomForms[i]) is TEditorForm then
7720             ShowWindow(Screen.CustomForms[i].Handle, nCmdShow);
7721
7722     end;
7723 end;
7724 //! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
7725 procedure TGikoForm.CreateResPopupBrowser;
7726 begin
7727     if (FResPopupBrowser = nil) then begin
7728         FResPopupBrowser := TResPopupBrowser.Create(BrowserPanel);
7729     end;
7730 end;
7731 //! ListView\82ÌD&D\8eó\82¯\8eæ\82è
7732 procedure TGikoForm.AcceptDropFiles(var Msg: TMsg);
7733 var
7734     FileName: Array[0..MAX_PATH] of Char;
7735     Cnt, K: Integer;
7736     Board: TBoard;
7737     LogFolder: String;
7738     datList: TStringList;
7739     p: TPoint;
7740 begin
7741     // \95\\8e¦\82µ\82Ä\82¢\82é\82Ì\94Â\82Ì\82Æ\82«\88È\8aO\82Í\8b\91\94Û
7742     if GetActiveList is TBoard then begin
7743         Board := TBoard(GetActiveList);
7744         if MsgBox(Handle, Board.Title
7745             + ' \94Â\82É\93ü\82ê\82Ä\82¢\82¢\82Å\82·\82©\81H', '\83M\83R\83i\83r', MB_YESNO or MB_ICONQUESTION) = IDYES       then begin
7746             // \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
7747             datList := TStringList.Create;
7748             try
7749                 Cnt := DragQueryFile(Msg.WParam, $FFFFFFFF, FileName, SizeOf(FileName));
7750                 for K := 0 to Cnt - 1 do begin
7751                     DragQueryFile(Msg.WParam, K, FileName, SizeOf(FileName));
7752                     // 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
7753                     // \83t\83@\83C\83\8b\82Ì\83`\83F\83b\83N
7754                     if (isValidFile(FileName)) then begin
7755                         LogFolder := ExtractFilePath(Board.FilePath);
7756                         if (FileExists( LogFolder + ExtractFileName(FileName))) then begin
7757                             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);
7758                         end else begin
7759                             if (not DirectoryExists(LogFolder)) then begin
7760                                 if (not GikoSys.ForceDirectoriesEx(LogFolder) ) then begin
7761                                     GikoUtil.MsgBox(Handle, LogFolder + '\82Ì\90\90¬\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
7762                                 end;
7763                             end;
7764                             if (not Windows.CopyFile(FileName,  PChar(LogFolder + ExtractFileName(FileName)), true)) then begin
7765                                 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);
7766                             end else begin
7767                                 datList.Add(ExtractFileName(FileName));
7768                             end;
7769                         end;
7770                     end;
7771                 end;
7772                 DragFinish(Msg.WParam);
7773                 if (datList.Count > 0) then begin
7774                     GikoSys.AddOutofIndexDat(Board, datList, False);
7775                     ShowMessage(IntToStr(datList.Count) + '\8cÂ\82Ìdat\83t\83@\83C\83\8b\82ª\83R\83s\81[\82³\82ê\82Ü\82µ\82½\81B' );
7776                         if GikoForm.TreeView.Visible then
7777                                 GikoForm.TreeView.Refresh;
7778                             if GikoForm.ListView.Visible then
7779                                 GikoForm.ListView.Refresh;
7780                 end else begin
7781                     ShowMessage('\88ê\82Â\82à\83R\83s\81[\82³\82ê\82Ü\82¹\82ñ\82Å\82µ\82½\81B' );
7782                 end;
7783             finally
7784                 datList.Free;
7785             end;
7786
7787         end;
7788     end else begin
7789         ShowMessage('\94Â\82ð\95\\8e¦\82µ\82Ä\82­\82¾\82³\82¢\81B');
7790     end;
7791 end;
7792
7793 //! \83t\83@\83C\83\8b\83`\83F\83b\83N
7794 function TGikoForm.isValidFile(FileName: String) : boolean;
7795 var
7796     dt: TDateTime;
7797 begin
7798     Result := True;
7799     // \91\8dÝ\82·\82é\82©\81A\8ag\92£\8eqdat\81A\83t\83@\83C\83\8b\96¼
7800     if ( not FileExists(FileName) ) then begin
7801         Result := False;
7802         GikoUtil.MsgBox(Handle, FileName + '\82Í\91\8dÝ\82µ\82Ü\82¹\82ñ\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
7803     end else if (ExtractFileExt(ExtractFileName(FileName)) <> '.dat' ) then begin
7804         Result := False;
7805         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);
7806     end else begin
7807         // \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
7808         try
7809             dt := GikoSys.GetCreateDateFromName(FileName);
7810             if ((UnixToDateTime(ZERO_DATE) + OffsetFromUTC) = dt) then begin
7811                 Result := False;
7812                 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);
7813             end;
7814         except
7815             Result := False;
7816             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);
7817         end;
7818     end;
7819 end;
7820
7821 procedure TGikoForm.ResPopupClearTimerTimer(Sender: TObject);
7822 begin
7823     ResPopupClearTimer.Enabled := False;
7824     if ResPopupClearTimer.Tag = 0 then begin
7825         FResPopupBrowser.Clear;
7826     end else begin
7827         FResPopupBrowser.CurrentBrowser.ChildClear;
7828     end;
7829 end;
7830
7831 initialization
7832                                 OleInitialize(nil);
7833 finalization
7834                                 OleUninitialize;
7835
7836 end.