OSDN Git Service

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