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