OSDN Git Service

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