OSDN Git Service

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