OSDN Git Service

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