OSDN Git Service

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