OSDN Git Service

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