OSDN Git Service

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