OSDN Git Service

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