OSDN Git Service

レス数1000越えで巡回登録を消すのを2chのみに限定
[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                 ListNameToolBar: TToolBar;
197                 ListNameLabel: TLabel;
198                 FolderImage: TImage;
199                 BrowserNameToolBar: TToolBar;
200                 ItemBoardImage: TImage;
201                 BrowserBoardNameLabel: TLabel;
202                 ItemImage: TImage;
203                 BrowserNameLabel: TLabel;
204                 D3: TMenuItem;
205                 N25: TMenuItem;
206                 N26: TMenuItem;
207                 D4: TMenuItem;
208                 S3: TMenuItem;
209                 R2: TMenuItem;
210                 TreeSelectNameURLPupupMenu: TMenuItem;
211                 N27: TMenuItem;
212                 H3: TMenuItem;
213                 I1: TMenuItem;
214                 BrowserTabToolBar: TToolBar;
215                 BrowserTab: TTabControl;
216                 About1: TMenuItem;
217                 N28: TMenuItem;
218                 S4: TMenuItem;
219                 N29: TMenuItem;
220                 N30: TMenuItem;
221                 N31: TMenuItem;
222                 L5: TMenuItem;
223                 L6: TMenuItem;
224                 A7: TMenuItem;
225                 R3: TMenuItem;
226                 FavoriteMenu: TMenuItem;
227                 N32: TMenuItem;
228                 BoardFavoriteAddMenu: TMenuItem;
229                 ThreadFavoriteAddMenu: TMenuItem;
230                 N33: TMenuItem;
231                 TreeSelectFavoriteAddPupupMenu: TMenuItem;
232                 FavoriteTreeView: TTreeView;
233                 StateIconImageList: TImageList;
234                 TopPanel: TPanel;
235                 TopRightPanel: TPanel;
236                 AnimePanel: TPanel;
237                 Animate: TAnimate;
238                 TopCoolPanel: TPanel;
239                 MainCoolBar: TGikoCoolBar;
240                 MenuToolBar: TToolBar;
241                 StdToolBar: TToolBar;
242                 AddressToolBar: TToolBar;
243                 AddressComboBox: TComboBox;
244                 MoveToToolButton: TToolButton;
245                 AddressImageList: TImageList;
246                 AddressToolBarMenu: TMenuItem;
247                 T4: TMenuItem;
248                 Show1: TMenuItem;
249                 N34: TMenuItem;
250                 T5: TMenuItem;
251                 B5: TMenuItem;
252                 N35: TMenuItem;
253                 A8: TMenuItem;
254                 U2: TMenuItem;
255                 F1: TMenuItem;
256                 PreviewTimer: TTimer;
257                 MonazillaWebPageAction1: TMenuItem;
258                 N36: TMenuItem;
259                 H4: TMenuItem;
260                 K3: TMenuItem;
261                 L7: TMenuItem;
262                 N37: TMenuItem;
263                 A9: TMenuItem;
264                 ChevronPopupMenu: TPopupMenu;
265                 N2N1: TMenuItem;
266                 N38: TMenuItem;
267                 F2: TMenuItem;
268                 LinkToolBar: TToolBar;
269                 a10: TMenuItem;
270                 N39: TMenuItem;
271                 T6: TMenuItem;
272                 N40: TMenuItem;
273                 LinkBarPopupMenu: TPopupMenu;
274                 T7: TMenuItem;
275                 ThreadPopupMenu: TPopupMenu;
276                 MenuItem4: TMenuItem;
277                 MenuItem5: TMenuItem;
278                 MenuItem6: TMenuItem;
279                 T8: TMenuItem;
280                 URLN3: TMenuItem;
281                 SelectItemNameCopyAction1: TMenuItem;
282                 B6: TMenuItem;
283                 T9: TMenuItem;
284     NameCopyPMenu: TMenuItem;
285                 SelectComboBox: TComboBox;
286                 MainCoolBarPopupMenu: TPopupMenu;
287                 StdToolBarVisiblePMenu: TMenuItem;
288                 AddressToolBarVisiblePMenu: TMenuItem;
289                 LinkToolBarVisiblePMenu: TMenuItem;
290                 NG1: TMenuItem;
291                 NG2: TMenuItem;
292                 N43: TMenuItem;
293                 N44: TMenuItem;
294                 L9: TMenuItem;
295                 I3: TMenuItem;
296                 N45: TMenuItem;
297                 B9: TMenuItem;
298                 R5: TMenuItem;
299                 T12: TMenuItem;
300                 Show3: TMenuItem;
301                 N46: TMenuItem;
302                 T13: TMenuItem;
303                 B10: TMenuItem;
304                 N47: TMenuItem;
305                 A12: TMenuItem;
306                 U4: TMenuItem;
307                 F4: TMenuItem;
308                 N48: TMenuItem;
309                 T14: TMenuItem;
310                 N50: TMenuItem;
311                 A11: TMenuItem;
312                 S5: TMenuItem;
313                 Reload: TMenuItem;
314                 GoBack: TMenuItem;
315                 GoFoward: TMenuItem;
316                 IndividualAbon1: TMenuItem;
317                 N41: TMenuItem;
318                 IndividualAbon2: TMenuItem;
319     AntiIndivAbonMenuItem: TMenuItem;
320                 AntiIndividualAbon: TMenuItem;
321                 N49: TMenuItem;
322                 N51: TMenuItem;
323                 N52: TMenuItem;
324                 SearchBoardName: TMenuItem;
325     TreeSelectLogDeleteSeparator: TMenuItem;
326                 N54: TMenuItem;
327                 A13: TMenuItem;
328                 FavoriteTreePopupMenu: TPopupMenu;
329                 FavoriteTreeRenamePopupMenu: TMenuItem;
330                 FavoriteTreeNewFolderPopupMenu: TMenuItem;
331                 N56: TMenuItem;
332                 FavoriteTreeDeletePopupMenu: TMenuItem;
333                 FavoriteToolBar: TToolBar;
334     FavoriteAddToolButton: TToolButton;
335     FavoriteArrangeToolButton: TToolButton;
336                 FavoriteTreeBrowseFolderPopupMenu: TMenuItem;
337                 N57: TMenuItem;
338                 FavoriteTreeReloadPopupMenu: TMenuItem;
339                 N58: TMenuItem;
340                 FavoriteTreeURLCopyPopupMenu: TMenuItem;
341                 FavoriteTreeNameCopyPopupMenu: TMenuItem;
342                 FavoriteTreeLogDeletePopupMenu: TMenuItem;
343                 N59: TMenuItem;
344                 FavoriteTreeNameURLCopyPopupMenu: TMenuItem;
345                 N60: TMenuItem;
346                 ExportFavoriteFileAction1: TMenuItem;
347                 N6: TMenuItem;
348                 N17: TMenuItem;
349     N18: TMenuItem;
350     N20: TMenuItem;
351         N24: TMenuItem;
352     N62: TMenuItem;
353         N61: TMenuItem;
354         N63: TMenuItem;
355     N64: TMenuItem;
356     dummy1: TMenuItem;
357         TreeSelectLogDeletePopupMenu: TMenuItem;
358         N65: TMenuItem;
359     BBSSelectPopupMenu: TPopupMenu;
360                 PlugInMenu: TMenuItem;
361         TreeSelectNamePupupMenu: TMenuItem;
362     BrowserPanel: TPanel;
363         SelectTimer: TTimer;
364     SelectThreadSave: TMenuItem;
365     N55: TMenuItem;
366     N66: TMenuItem;
367     dat1: TMenuItem;
368                 OpenLogFolder: TMenuItem;
369     Browser: TWebBrowser;
370     TabSave: TMenuItem;
371         TabOpen: TMenuItem;
372     ResRangePopupMenu: TPopupMenu;
373     ResRangeHundPMenuItem: TMenuItem;
374     ResRangeKokoPMenuItem: TMenuItem;
375     ResRangeNewPMenuItem: TMenuItem;
376     ResRangeAllPMenuItem: TMenuItem;
377         BrowsBoradHeadAction1: TMenuItem;
378     ThreadRangePopupMenu: TPopupMenu;
379     A15: TMenuItem;
380     L8: TMenuItem;
381         N67: TMenuItem;
382     N68: TMenuItem;
383     S6: TMenuItem;
384     N69: TMenuItem;
385     ResRangeSelectPMenuItem: TMenuItem;
386     ListColumnPopupMenu: TPopupMenu;
387     N70: TMenuItem;
388     ID1: TMenuItem;
389     ID2: TMenuItem;
390     N53: TMenuItem;
391     ID3: TMenuItem;
392     N71: TMenuItem;
393     N72: TMenuItem;
394     N73: TMenuItem;
395     SelectComboBoxPanel: TPanel;
396     SelectComboBoxSplitter: TImage;
397     N74: TMenuItem;
398     WikiFAQ: TMenuItem;
399     GikoApplicationEvents: TApplicationEvents;
400     N22: TMenuItem;
401     N42: TMenuItem;
402     DAT2: TMenuItem;
403     N75: TMenuItem;
404     DAT3: TMenuItem;
405     N76: TMenuItem;
406     FavoriteTreeItemNameCopyPopupMenu: TMenuItem;
407     N77: TMenuItem;
408     N78: TMenuItem;
409     SaveThreadFile: TMenuItem;
410     N79: TMenuItem;
411     HTML1: TMenuItem;
412     DAT4: TMenuItem;
413     N80: TMenuItem;
414     SameBoardThreadItem: TMenuItem;
415     N81: TMenuItem;
416     N82: TMenuItem;
417     IDNG1: TMenuItem;
418     IDNG2: TMenuItem;
419     ResPopupClearTimer: TTimer;
420                                 procedure FormCreate(Sender: TObject);
421                 procedure FormDestroy(Sender: TObject);
422                 procedure BrowserStatusTextChange(Sender: TObject;
423                         const Text: WideString);
424                 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
425                 procedure TreeViewChanging(Sender: TObject; Node: TTreeNode;
426                         var AllowChange: Boolean);
427                 procedure ListViewKeyDown(Sender: TObject; var Key: Word;
428                         Shift: TShiftState);
429                 procedure ListViewColumnClick(Sender: TObject; Column: TListColumn);
430                 procedure MenuToolBarCustomDrawButton(Sender: TToolBar;
431                         Button: TToolButton; State: TCustomDrawState;
432                         var DefaultDraw: Boolean);
433                 procedure BrowserBeforeNavigate2(Sender: TObject;
434                         const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
435                         Headers: OleVariant; var Cancel: WordBool);
436                 procedure TreeViewCustomDraw(Sender: TCustomTreeView;
437                         const ARect: TRect; var DefaultDraw: Boolean);
438                 procedure TreeViewCustomDrawItem(Sender: TCustomTreeView;
439                         Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
440                 procedure TreeViewExpanded(Sender: TObject; Node: TTreeNode);
441                 procedure ListViewCustomDraw(Sender: TCustomListView;
442                         const ARect: TRect; var DefaultDraw: Boolean);
443                 procedure ListViewMouseDown(Sender: TObject; Button: TMouseButton;
444                         Shift: TShiftState; X, Y: Integer);
445                 procedure TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
446                 procedure MessageListViewResize(Sender: TObject);
447                 procedure       CabinetVisible( isVisible : Boolean );
448                 procedure FormResize(Sender: TObject);
449                 procedure ListPopupMenuPopup(Sender: TObject);
450                 procedure TreePopupMenuPopup(Sender: TObject);
451                 procedure BrowserNewWindow2(Sender: TObject; var ppDisp: IDispatch;
452                         var Cancel: WordBool);
453                 procedure ListSplitterMoved(Sender: TObject);
454                 procedure BrowserTabChange(Sender: TObject);
455                 procedure BrowserTabMouseDown(Sender: TObject; Button: TMouseButton;
456                         Shift: TShiftState; X, Y: Integer);
457                 procedure BrowserTabDragOver(Sender, Source: TObject; X, Y: Integer;
458                         State: TDragState; var Accept: Boolean);
459                 procedure BrowserTabDragDrop(Sender, Source: TObject; X, Y: Integer);
460                 procedure BrowserTabMouseMove(Sender: TObject; Shift: TShiftState; X,
461                         Y: Integer);
462                 procedure BrowserDocumentComplete(Sender: TObject;
463                         const pDisp: IDispatch; var URL: OleVariant);
464                 procedure RoundNamePopupMenuPopup(Sender: TObject);
465                 procedure FormShow(Sender: TObject);
466                 procedure BrowserTabToolBarResize(Sender: TObject);
467                 procedure FavoriteMenuClick(Sender: TObject);
468                 procedure MainCoolBarResize(Sender: TObject);
469                 procedure AddressToolBarResize(Sender: TObject);
470                 procedure AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
471                         Shift: TShiftState);
472                 procedure BrowserEnter(Sender: TObject);
473                 procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
474                 procedure PreviewTimerTimer(Sender: TObject);
475                 procedure MessageHideButtonClick(Sender: TObject);
476                 procedure HistoryAllClearToolButtonClick(Sender: TObject);
477                 procedure MainCoolBarBandInfo(Sender: TObject;
478                         var BandInfo: PReBarBandInfoA);
479                 procedure MainCoolBarChevronClick(Sender: TObject;
480                         RebarChevron: PNMRebarChevron);
481                 procedure ListCoolBarBandInfo(Sender: TObject;
482                         var BandInfo: PReBarBandInfoA);
483                 procedure ListCoolBarChevronClick(Sender: TObject;
484                         RebarChevron: PNMRebarChevron);
485                 procedure BrowserCoolBarBandInfo(Sender: TObject;
486                         var BandInfo: PReBarBandInfoA);
487                 procedure BrowserCoolBarChevronClick(Sender: TObject;
488                         RebarChevron: PNMRebarChevron);
489                 procedure ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
490                 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
491                         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
492                 procedure SelectComboBoxChange(Sender: TObject);
493                 procedure SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
494                         Shift: TShiftState);
495                 procedure SelectComboBoxExit(Sender: TObject);
496                 procedure SelectComboBoxSplitterMouseMove(Sender: TObject;
497                         Shift: TShiftState; X, Y: Integer);
498                 procedure SelectComboBoxSplitterMouseDown(Sender: TObject;
499                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
500                 procedure SelectComboBoxSplitterMouseUp(Sender: TObject;
501                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
502                 procedure StatusBarResize(Sender: TObject);
503                 procedure SelectComboBoxEnter(Sender: TObject);
504                 procedure FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
505                         Y: Integer);
506                 procedure FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
507                 procedure FavoriteTreeViewEdited(Sender: TObject; Node: TTreeNode;
508                         var S: String);
509                 procedure FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
510                         Shift: TShiftState);
511                 procedure FavoriteTreePopupMenuPopup(Sender: TObject);
512                 procedure LinkToolBarDragDrop(Sender, Source: TObject; X, Y: Integer);
513                 procedure BrowserTabMouseUp(Sender: TObject; Button: TMouseButton;
514                         Shift: TShiftState; X, Y: Integer);
515                 procedure LinkToolBarDragOver(Sender, Source: TObject; X, Y: Integer;
516                         State: TDragState; var Accept: Boolean);
517                 procedure FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
518                         Y: Integer);
519                 procedure FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
520     procedure BrowserTabContextPopup(Sender: TObject; MousePos: TPoint;
521       var Handled: Boolean);
522     procedure BrowserTabPopupMenuPopup(Sender: TObject);
523     procedure BrowserTabResize(Sender: TObject);
524     procedure TreeViewKeyDown(Sender: TObject; var Key: Word;
525       Shift: TShiftState);
526     procedure FavoriteTreeViewMouseDown(Sender: TObject;
527                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
528     procedure MessagePanelResize(Sender: TObject);
529                 procedure OnResized;
530         procedure SelectTimerTimer(Sender: TObject);
531                 procedure ListViewColumnRightClick(Sender: TObject;
532       Column: TListColumn; Point: TPoint);
533         procedure ListViewCustomDrawItem(Sender: TCustomListView;
534       Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
535     procedure FormActivate(Sender: TObject);
536     procedure BrowserPanelResize(Sender: TObject);
537     procedure MenuToolBarResize(Sender: TObject);
538     procedure ListToolBarResize(Sender: TObject);
539     procedure BrowserToolBarResize(Sender: TObject);
540         procedure KokoPopupMenuPopup(Sender: TObject);
541         procedure ListViewKeyUp(Sender: TObject; var Key: Word;
542           Shift: TShiftState);
543     procedure FavoriteTreeViewEditing(Sender: TObject; Node: TTreeNode;
544       var AllowEdit: Boolean);
545         procedure CabinetCloseSpeedButtonClick(Sender: TObject);
546     procedure FavoriteArrangeToolButtonClick(Sender: TObject);
547     procedure GikoApplicationEventsMessage(var Msg: tagMSG;
548           var Handled: Boolean);
549     procedure GikoApplicationEventsDeactivate(Sender: TObject);
550     procedure GikoApplicationEventsException(Sender: TObject; E: Exception);
551     procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
552       Shift: TShiftState; X, Y: Integer);
553     procedure GetResURLMenuClick(Sender: TObject);
554     procedure MainCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
555       var Handled: Boolean);
556     procedure ResPopupClearTimerTimer(Sender: TObject);
557         private
558                 { Private \90é\8c¾ }
559                 FEnabledCloseButton: Boolean;
560                 FClickNode: TTreeNode;
561                 FHttpState: Boolean;
562                 FPreviewBrowser: TPreviewBrowser;
563                 FPreviewURL: string;
564                 FBrowserSizeHeight: Integer;
565                 FBrowserSizeWidth: Integer;
566                 FTabHintIndex: Integer;
567                 FListStyle: TViewStyle;                         //\83\8a\83X\83g\83A\83C\83R\83\93\83X\83^\83C\83\8b
568                 FItemNoVisible: Boolean;                        //\83\8a\83X\83g\94Ô\8d\86\95\\8e¦\83t\83\89\83O
569                 FViewType: TGikoViewType;                       //\83\8a\83X\83g\83A\83C\83e\83\80\95\\8e¦\83^\83C\83v
570                 FActiveList: TObject;
571                 FActiveContent: TBrowserRecord; //
572                 FActiveBBS : TBBS;
573                 FHistoryList: THistoryList;                                     //\83q\83X\83g\83\8a\83\8a\83X\83g
574                 FTreeType: TGikoTreeType;
575                 FWorkCount: Integer;
576                 FNameCookie: string;
577                 FMailCookie: string;
578                 FDownloadTitle: string;                         //\83_\83E\83\93\83\8d\81[\83h\92\86\82Ì\83^\83C\83g\83\8b\96¼
579                 FDownloadMax: Integer;                          //\83_\83E\83\93\83\8d\81[\83h\92\86\82Ì\8dÅ\91å\83T\83C\83Y
580                 FEvent: THTMLDocumentEventSink;//\83u\83\89\83E\83U\83h\83L\83\85\83\81\83\93\83g\83C\83x\83\93\83g
581                 IsDraggingSelectComboBox : Boolean;
582                 DraggingSelectComboBoxPosition : TPoint;
583                 FSearchDialog: TSearchDialog;
584                 FDropSpaceNode: TTreeNode;
585                 FDragTime : Cardinal;                                                           ///< \83\8a\83\93\83N\82ÌD&D\97p
586                 FDragButton : TToolButton;                                      ///< \83\8a\83\93\83N\82ÌD&D\97p\82ÉDrag\82µ\82Ä\82éButton\95Û\91
587                 FDragWFirst : Boolean;                                                  ///< WebTab\82ÌD&D\97p
588                 FListViewBackGroundColor : TColor;      ///< ListView\82ÌBackGroundColor
589                 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¦
590                 FOddColor : TColor;                                                                     ///< \82»\82Ì\90F
591                 FSelectResWord  : string;                                               ///< \83\8c\83X\8di\8d\9e\83\8f\81[\83h
592                 FIsIgnoreResize : TResizeType;                  ///< \83\8a\83T\83C\83Y\83C\83x\83\93\83g\82ð\96³\8e\8b\82·\82é\82©\82Ç\82¤\82©
593                 FIsMinimize                     : TMinimizeType;                ///< \8dÅ\8f¬\89»\82µ\82Ä\82¢\82é\8dÅ\92\86\82©
594                 FOldFormWidth           : Integer;                                      ///< \92¼\91O\82Ì\83E\83B\83\93\83h\83E\82Ì\95\9d
595                 FToolBarSettingSender : TToolBarSettingSenderType;      ///< \83c\81[\83\8b\83o\81[\90Ý\92è\82ð\83N\83\8a\83b\83N\82µ\82½\83N\81[\83\8b\83o\81[
596                 FMouseDownPos           : TPoint;                                       ///< \83u\83\89\83E\83U\83^\83u\82Å\83}\83E\83X\82ð\89\9f\82µ\82½\82Æ\82«\82Ì\8dÀ\95W
597                 FBrowsers: TList;
598                 FResRangeMenuSelect     : Longint;                      ///< ResRangeButton \82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\8d\80\96Ú (\83t\83H\81[\83}\83b\83g\82Í ResRange \8cÝ\8a·)
599                 FStartUp : Boolean;
600                 FIsHandledWheel : Boolean;                      ///< \8aù\82É\8eó\82¯\8eæ\82Á\82½ WM_MOUSEWHEEL \82©\82Ç\82¤\82©
601                                 DiffComp: Boolean;                      //Add by Genyakun \83X\83\8c\82ª\8dX\90V\82³\82ê\82½\82Æ\82«\82ÉTrue\82É\82È\82é
602                 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ñ
603                 FPreviewBrowserRect: TRect;                     ///< \83v\83\8c\83r\83\85\81[\82Ì\95\\8e¦\88Ê\92u\82ð\8bL\89¯\82·\82é
604                 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ñ
605         FResPopupBrowser: TResPopupBrowser;
606                 procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
607                 procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
608                 procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
609                 procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
610                 procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
611                 procedure ListClick;
612                 procedure ListDoubleClick(Shift: TShiftState);
613                 function Hook(var Message: TMessage): Boolean;
614                 procedure AddRoundNameMenu(MenuItem: TMenuItem);
615                 procedure SetMenuFont;
616                 procedure CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
617                 procedure FavoriteClick(Sender: TObject; ActiveTab: Boolean); overload;
618                 procedure FavoriteClick(Sender: TObject); overload;
619                 procedure FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
620                 function OnDocumentContextMenu(Sender: TObject): WordBool;
621                 function GetWidthAllToolButton(ToolBar: TToolBar): Integer;
622                 procedure MenuBarChevronMenu;
623                 procedure LinkBarChevronMenu;
624                 procedure ToolBarChevronMenu(ToolBar: TToolBar);
625                 procedure LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
626                 procedure LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
627                 procedure LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
628                 procedure LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
629                 procedure LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
630                 function TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
631                 procedure FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
632                 procedure FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
633                 procedure FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
634                 //
635                 procedure SetListViewBackGroundColor(value: TColor);
636                 procedure BBSMenuItemOnClick( Sender : TObject );
637                 /// CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
638                 procedure       SaveCoolBarSettings;
639                 procedure       SaveMainCoolBarSettings;
640                 procedure       SaveBoardCoolBarSettings;
641                 procedure       SaveBrowserCoolBarSettings;
642                 /// CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82©\82ç\95\9c\8c³
643                 procedure       LoadCoolBarSettings;
644                 /// \8dÅ\8f¬\89»\82³\82ê\82é
645                 procedure OnMinimize;
646                 /// \8dÅ\8f¬\89»\82³\82ê\82½
647                 procedure OnMinimized;
648                 /// TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
649                 procedure TreeClick( Node : TTreeNode );
650                 /// TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
651                 procedure TreeDoubleClick( Node : TTreeNode );
652                 /// \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
653                 procedure SetBBSMenu;
654                 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
655                 procedure       ListColumnPopupMenuOnClick( Sender : TObject );
656                 //! \8di\82è\8d\9e\82Ý\95\8e\9a\97ñ\90Ý\92è
657                 procedure SetSelectWord( const text : string );
658                 //\8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
659                 function GetScreenCursor(): TCursor;
660                 //\83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
661                 procedure SetScreenCursor(Cursor : TCursor);
662                 //! \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¬
663                 procedure CreateControlThread();
664                 //! \83u\83\89\83E\83U\82Ì\90\90¬
665                 procedure CreateBrowsers(count: Integer);
666                 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
667                 procedure GetGroupIndex(ActionList: TActionList);
668                 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
669                 procedure SetGroupIndex(ActionList: TActionList);
670                 //! \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é)
671                 procedure OpenThreadItem(Thread: TThreadItem; URL: String);
672                 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
673                 procedure RefreshListView(Thread: TThreadItem);
674                 //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
675                 procedure ClearThreadRengeAction;
676         //! \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¦
677         procedure UnStoredTaskTray;
678         //! \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
679         procedure ShowEditors(nCmdShow: Integer);
680         //! \82à\82Á\82Æ\82à\8cÃ\82¢Browser\82Ì\8aJ\95ú
681         procedure ReleaseOldestBrowser;
682         //! \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Á
683         procedure AddMenuSameBoardThread;
684         //!  \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
685         procedure SameBoardThreadSubItemOnClick(Sender: TObject);
686         //! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
687         procedure CreateResPopupBrowser;
688         //! \83t\83@\83C\83\8b\83`\83F\83b\83N
689         function isValidFile(FileName: String) : boolean;
690         //! ListView\82ÌD&D\8eó\82¯\8eæ\82è
691         procedure AcceptDropFiles(var Msg: TMsg);
692         protected
693                 procedure CreateParams(var Params: TCreateParams); override;
694                 procedure WndProc(var Message: TMessage); override;
695                 procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;
696                 procedure WMSettingChange(var Message: TWMWinIniChange); message WM_SETTINGCHANGE;
697                 procedure WMCopyData(var Message: TWMCopyData); message WM_COPYDATA;
698         public
699                 { Public \90é\8c¾ }
700                 LastRoundTime: TDateTime;
701                 BrowserNullTab: TBrowserRecord;
702                 FControlThread: TThreadControl;
703         FIconData : TNotifyIconData;
704                 procedure MoveToURL(const inURL: string);
705                 function InsertBrowserTab(ThreadItem: TThreadItem; ActiveTab: Boolean = True) : TBrowserRecord;
706                 procedure ReloadBBS;
707                 function GetHttpState: Boolean;
708                 procedure SetEnabledCloseButton(Enabled: Boolean);
709                 function GetTreeNode(Data: TObject): TTreeNode;
710                 procedure ListViewAllSelect;
711                 property ListStyle: TViewStyle read FListStyle write FListStyle;
712                 property ItemNoVisible: Boolean read FItemNoVisible write FItemNoVisible;
713                 property ViewType: TGikoViewType read FViewType write FViewType;
714                 property NameCookie: string read FNameCookie write FNameCookie;
715                 property MailCookie: string read FMailCookie write FMailCookie;
716                 property ClickNode: TTreeNode read FClickNode write FClickNode;
717                 property TreeType: TGikoTreeType read FTreeType write FTreeType;
718                 property ActiveContent: TBrowserRecord read FActiveContent write FActiveContent;
719                 property ResRangeMenuSelect: Longint read FResRangeMenuSelect write FResRangeMenuSelect;
720                 property SelectResWord  : string read FSelectResWord write FSelectResWord;
721                 property BrowserSizeWidth: Integer read FBrowserSizeWidth write FBrowserSizeWidth;
722                 property BrowserSizeHeight: Integer read FBrowserSizeHeight write FBrowserSizeHeight;
723                 property SearchDialog: TSearchDialog read FSearchDialog write FSearchDialog;
724                 property ToolBarSettingSender : TToolBarSettingSenderType
725                                                  read FToolBarSettingSender write FToolBarSettingSender;
726                 property ScreenCursor : TCursor read GetScreenCursor write SetScreenCursor;
727                 property ActiveBBS : TBBS read FActiveBBS write FActiveBBS;
728                 property WorkCount: Integer read FWorkCount write FWorkCount;
729                 procedure SetContent(inThread: TBrowserRecord);
730                 function GetActiveContent(popup :Boolean = false): TThreadItem;
731                 function GetActiveList: TObject;
732
733                 procedure SetListViewType(AViewType: TGikoViewType); overload;
734                 procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;
735                 procedure PlaySound(SoundEventName: string);
736                 procedure ShowBBSTree( inBBS : TBBS );
737                 procedure ShowBBSTreeOld( inBBS : TBBS );
738                 procedure ShowHistoryTree;
739                 procedure AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
740                 procedure SetBrowserTabState;
741                 procedure SetToolBarPopup;
742                 procedure ShowFavoriteAddDialog( Item : TObject );
743                 procedure FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
744                 procedure RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
745                 property ListViewBackGroundColor: TColor read FListViewBackGroundColor write SetListViewBackGroundColor;
746                 property UseOddResOddColor : Boolean read FUseOddResOddColor write FUseOddResOddColor;
747                 property OddColor : TColor read FOddColor write FOddColor;
748                 function FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
749                 procedure OnPlugInMenuItem( Sender : TObject );
750                 procedure TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
751                 /// 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Å
752                 procedure ActiveListColumnSave;
753                 procedure SetActiveList(Obj: TObject);
754                 property ActiveList: TObject read GetActiveList write SetActiveList;
755                 /// CoolBar \82ª\83T\83C\83Y\95Ï\8dX\82³\82ê\82½
756                 procedure       CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
757                 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
758                 procedure IndividualAbonID(Atype : Integer);
759                 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
760                 procedure IndividualAbon(Atag, Atype : Integer);
761         //\93¯\88êID\82ðNG\83\8f\81[\83h\82É\93o\98^
762         procedure AddIDtoNGWord(invisible : boolean);
763                 //\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Ý
764                 procedure RepaintAllTabsBrowser();
765                 //\83\8a\83\93\83N\83o\81[\90Ý\92è
766                 procedure SetLinkBar;
767                 procedure FavoriteBrowseFolder( node: TTreeNode );
768                 //\83X\83\8c\83b\83h\82Ì\83_\83E\83\93\83\8d\81[\83h
769                 procedure DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
770                 //\94Â\82Ì\83_\83E\83\93\83\8d\81[\83h
771                 procedure DownloadList(Board: TBoard; ForceDownload: Boolean = False);
772                 //\97\9a\97ð\82©\82ç\8dí\8f\9c
773                 procedure DeleteHistory( threadItem: TThreadItem );
774                 //\83^\83u\82ð\8dí\8f\9c \83X\83\8c\83b\83h\8ew\92è
775                 procedure DeleteTab(ThreadItem: TThreadItem); overload;
776                 //\83^\83u\82ð\8dí\8f\9c \83u\83\89\83E\83U\83\8c\83R\81[\83h\81i\83^\83u\81j\8ew\92è
777                 procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
778         // \83^\83u\8dí\8f\9c\81i\8eÀ\91\95\95\94\81j
779         procedure DeleteTab(index, selectIndex: Integer); overload;
780                 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
781                 procedure BrowserMovement(const AName: string); overload;
782                 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
783                 procedure BrowserMovement(scroll: Integer); overload;
784                 //Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
785                 function GetMainForm(): TComponent;
786                 procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
787                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\8en
788                 procedure OnGestureStart(Sender: TObject);
789                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\92\86
790                 procedure OnGestureMove(Sender: TObject);
791                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8fI\97¹
792                 procedure OnGestureEnd(Sender: TObject);
793                 /// \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
794                 procedure ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
795                 //ListView\82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é
796                 procedure SelectListItem(List: TList);
797                 //\8ew\92è\82µ\82½\83\8c\83X\82ð\83R\83s\81[\82·\82é
798                 procedure KonoresCopy(Number: Integer; ReplaceTag : Boolean);
799                 //
800                 procedure ModifySelectList;
801                 //
802                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string); overload;
803                 //
804                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string); overload;
805                 //
806                 procedure SetSelectRoundName(Sender: TObject);
807                 //
808                 function GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
809                 //
810                 function WebBrowserClick(Sender: TObject): WordBool;
811                 //! \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é
812                 procedure SetSelectComboBox();
813
814         //! \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
815         procedure TaskTrayIconMessage(var Msg : TMsg); message WM_USER + 2010;
816         //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
817         procedure StoredTaskTray;
818         published
819                 property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
820         end;
821
822         TFavoriteMenuItem = class(TMenuItem)
823         private
824                 FData : Pointer;
825         public
826                 property Data: Pointer read FData write FData;
827         end;
828
829         TBBSMenuItem = class(TMenuItem)
830         private
831                 FData : Pointer;
832         public
833                 property Data: Pointer read FData write FData;
834         end;
835
836         TLinkToolButton = class(TToolButton)
837         private
838                 FData : Pointer;
839         public
840                 property Data: Pointer read FData write FData;
841         end;
842
843 var
844         GikoForm: TGikoForm;
845
846 implementation
847
848 uses
849         GikoUtil, IndividualAbon, Math, Kotehan, KeySetting,
850         YofUtils, ToolBarUtil, ToolBarSetting,
851         GikoXMLDoc, RoundName, IniFiles, FavoriteAdd,
852         FavoriteArrange, AddressHistory, Gesture,
853         About, Option, Round, Splash, Sort, ListSelect, Imm,
854         NewBoard, MojuUtils, Clipbrd, GikoBayesian,Y_TextConverter,
855         HTMLCreate, ListViewUtils, GikoDataModule, GikoMessage,
856   InputAssistDataModule, Types, ReplaceDataModule;
857
858 const
859         BLANK_HTML: string = 'about:blank';
860         BROWSER_COUNT           = 5;    //\83u\83\89\83E\83U\82Ì\90\94
861         //D&D臒l
862         DandD_THRESHOLD = 5;    //D&D\82Ìè\87\92l\81ipixcel)
863         //\83v\83\8c\83r\83\85\81[\83t\83@\83C\83\8b\96¼
864         HTML_FILE_NAME  = 'temp_preview.html';
865         //\83\81\83b\83Z\81[\83WID
866         USER_TREECLICK                                  = WM_USER + 2000;
867         USER_RESIZED            = WM_USER + 2001;
868         USER_MINIMIZED                                  = WM_USER + 2002;
869         USER_SETLINKBAR                                 = WM_USER + 2003;
870         USER_DOCUMENTCOMPLETE           = WM_USER + 2004;       ///< wParam : TWebBrowser
871     USER_TASKTRAY               = WM_USER + 2010;
872 {$R *.DFM}
873
874 procedure TGikoForm.CreateParams(var Params: TCreateParams);
875 begin
876         inherited;
877         if FormStyle in [fsNormal, fsStayOnTop] then begin
878                 if BorderStyle in [bsSingle, bsSizeable] then begin
879                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
880                         Params.WndParent := 0;
881                 end;
882         end;
883 end;
884
885 procedure TGikoForm.FormCreate(Sender: TObject);
886 const
887         TVS_NOTOOLTIPS = $0080;
888 var
889         FileName: string;
890         Style: DWORD;
891         msg: string;
892         i: Integer;
893         wp: TWindowPlacement;
894 begin
895 {$IFDEF DEBUG}
896         AllocConsole;
897         Writeln('============================================================');
898         Writeln(' \83M\83R\83i\83r\83f\83o\83b\83\83R\83\93\83\\81[\83\8b');
899         Writeln('');
900         Writeln(' \82±\82Ì\89æ\96Ê\82ð\95Â\82\82È\82¢\82Å\82­\82¾\82³\82¢\81B');
901         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¢');
902         Writeln('============================================================');
903 {$ENDIF}
904 //try
905         Sort.SetSortDate(Now());
906         
907         FTreeType := gttNone;
908         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô
909         FStartUp := true;
910         Application.HookMainWindow(Hook);
911         FIsIgnoreResize := rtResizing;
912         //ActionList\82ÌGuoupIndex\82ð\95Û\91\82µ\82Ä\81A0\82É\83N\83\8a\83A\82·\82é\81B
913         //(\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¢)
914         //\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
915         GetGroupIndex(GikoDM.GikoFormActionList);
916         FSearchDialog := nil;
917     FResPopupBrowser := nil;
918         CreateBrowsers(BROWSER_COUNT);
919     FIconData.uID := 0;
920
921         //\83\81\83j\83\85\81[\83t\83H\83\93\83g
922         SetMenuFont;
923
924         //\8eè\82Ì\83J\81[\83\\83\8b
925         Screen.Cursors[5] := LoadCursor(HInstance, 'GIKOHAND');
926
927         //\83A\83h\83\8c\83X\97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
928         AddressHistoryDM.ReadHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
929
930         EnabledCloseButton := True;
931
932         //\83\8a\83X\83g\83X\83^\83C\83\8b
933         ListView.ViewStyle := GikoSys.Setting.ListStyle;
934
935         //\83A\83j\83\81\83p\83l\83\8b\88Ê\92u
936         AnimePanel.Top := 0;
937         AnimePanel.Left := 0;
938
939         //\8ae\8eí\89Â\8e\8b\8fó\91Ô\82È\82Ç\90Ý\92è
940
941         //\83L\83\83\83r\83l\83b\83g
942         CabinetPanel.Width := GikoSys.Setting.CabinetWidth;
943
944         //\83\81\83b\83Z\81[\83W\83o\81[
945         GikoDM.MsgBarVisibleAction.Checked := GikoSys.Setting.MessageBarVisible;
946         GikoDM.MsgBarVisibleActionExecute(nil);
947         MessagePanel.Height := GikoSys.Setting.MessegeBarHeight;
948
949         //\83X\83e\81[\83^\83X\83o\81[
950         GikoDM.StatusBarVisibleAction.Checked := GikoSys.Setting.StatusBarVisible;
951         GikoDM.StatusBarVisibleActionExecute(nil);
952
953         //\83t\83H\83\93\83g\81E\90F\90Ý\92è
954         TreeView.Items.BeginUpdate;
955         FavoriteTreeView.Items.BeginUpdate;
956         ListView.Items.BeginUpdate;
957         try
958                 TreeView.Font.Name := GikoSys.Setting.CabinetFontName;
959                 TreeView.Font.Size := GikoSys.Setting.CabinetFontSize;
960                 TreeView.Font.Color := GikoSys.Setting.CabinetFontColor;
961                 TreeView.Color := GikoSys.Setting.CabinetBackColor;
962                 FavoriteTreeView.Font.Assign(TreeView.Font);
963                 FavoriteTreeView.Color := GikoSys.Setting.CabinetBackColor;
964
965                 ListView.Font.Name := GikoSys.Setting.ListFontName;
966                 ListView.Font.Size := GikoSys.Setting.ListFontSize;
967                 ListView.Font.Color := GikoSys.Setting.ListFontColor;
968                 ListView.Font.Style := [];
969                 if GikoSys.Setting.ListFontBold then
970                         ListView.Font.Style := [fsbold];
971                 if GikoSys.Setting.ListFontItalic then
972                         ListView.Font.Style := ListView.Font.Style + [fsitalic];
973
974                 ListViewBackGroundColor := clWhite;                                                                                             // \83f\83t\83H\83\8b\83g\82É\90Ý\92è\82µ\82½\82Ì\82¿
975                 ListViewBackGroundColor := GikoSys.Setting.ListBackColor;       // \83\86\81[\83U\92è\8b`\82É\95Ï\8dX
976                 FUseOddResOddColor := GikoSys.Setting.UseOddColorOddResNum;
977                 FOddColor := GikoSys.Setting.OddColor;
978
979         finally
980                 TreeView.Items.EndUpdate;
981                 FavoriteTreeView.Items.EndUpdate;
982                 ListView.Items.EndUpdate;
983         end;
984         //ViewNoButton.Down := GikoSys.Setting.ListViewNo;
985         GikoDM.ListNumberVisibleAction.Checked := GikoSys.Setting.ListViewNo;
986
987         //\83~\83\85\81[\83g\82Ì\8fó\91Ô\82ð\90Ý\92è
988         GikoDM.MuteAction.Checked := GikoSys.Setting.Mute;
989
990         // \83\8c\83X\95\\8e¦\94Í\88Í
991         FResRangeMenuSelect := GikoSys.ResRange;
992         case GikoSys.ResRange of
993         Ord( grrAll ):
994                 begin
995                         GikoDM.AllResAction.Execute;
996                 end;
997         Ord( grrSelect ):
998                 begin
999                         SelectComboBox.Text := SelectComboBox.Items[ 1 ];
1000                         GikoDM.SelectResAction.Checked := True;
1001                 end;
1002         else
1003                 case FResRangeMenuSelect of
1004                 Ord( grrKoko ): GikoDM.OnlyKokoResAction.Checked        := True;
1005                 Ord( grrNew ):  GikoDM.OnlyNewResAction.Checked := True;
1006                 100:                    GikoDM.OnlyAHundredResAction.Checked            := True;
1007                 end;
1008         end;
1009
1010         // \83X\83\8c\83b\83h\88ê\97\97\95\\8e¦\94Í\88Í
1011         case GikoSys.Setting.ThreadRange of
1012         gtrAll:
1013                 begin
1014                         GikoDM.AllItemAction.Checked := True;
1015                         ViewType := gvtAll;
1016                 end;
1017         gtrLog:
1018                 begin
1019                         GikoDM.LogItemAction.Checked := True;
1020                         ViewType := gvtLog;
1021                 end;
1022         gtrNew:
1023                 begin
1024                         GikoDM.NewItemAction.Checked := True;
1025                         ViewType := gvtNew;
1026                 end;
1027         gtrLive:
1028                 begin
1029                         GikoDM.LiveItemAction.Checked := True;
1030                         ViewType := gvtLive;
1031                 end;
1032         gtrArch:
1033                 begin
1034                         GikoDM.ArchiveItemAction.Checked := True;
1035                         ViewType := gvtArch;
1036                 end;
1037         end;
1038
1039
1040         //\83u\83\89\83E\83U\83^\83u\83t\83H\83\93\83g
1041         BrowserTab.Font.Name := GikoSys.Setting.BrowserTabFontName;
1042         BrowserTab.Font.Size := GikoSys.Setting.BrowserTabFontSize;
1043         BrowserTab.Font.Style := [];
1044         if GikoSys.Setting.BrowserTabFontBold then
1045                 BrowserTab.Font.Style := [fsBold];
1046         if GikoSys.Setting.BrowserTabFontItalic then
1047                 BrowserTab.Font.Style := GikoForm.BrowserTab.Font.Style + [fsItalic];
1048
1049         BrowserTab.DoubleBuffered := True;
1050         FDragWFirst := false;
1051         SetContent(BrowserNullTab);                                                                                                     //\83u\83\89\83E\83U\82ð\8bó\94\92\95\\8e¦
1052
1053         //\83u\83\89\83E\83U\83^\83u
1054         GikoDM.BrowserTabVisibleAction.Checked := GikoSys.Setting.BrowserTabVisible;
1055
1056         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
1057                 GikoDM.BrowserTabTopAction.Checked := True;
1058         end else begin
1059                 GikoDM.BrowserTabBottomAction.Checked := True;
1060         end;
1061
1062         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
1063                 GikoDM.BrowserTabTabStyleAction.Checked := True;
1064         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
1065                 GikoDM.BrowserTabButtonStyleAction.Checked := True;
1066         end else begin
1067                 GikoDM.BrowserTabFlatStyleAction.Checked := True;
1068         end;
1069
1070         //\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\8f\89\8aú\89»
1071         ProgressBar.Parent := StatusBar;
1072         ProgressBar.Top := 2;
1073         ProgressBar.Left := 0;
1074         ProgressBar.Width := StatusBar.Panels[0].Width;
1075         ProgressBar.Height := StatusBar.Height - 2;
1076         ProgressBar.Position := 0;
1077
1078         // \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Æ)
1079         InitializeBoardPlugIns;
1080
1081         // \83{\81[\83h\83t\83@\83C\83\8b\97ñ\8b\93(ReadFavorite \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1082         GikoSys.ListBoardFile;
1083         //\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É
1084         try
1085         // \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è
1086                 if (SplashWindow <> nil) then begin
1087                         SplashWindow.ProgressBar.Max := Length(BBSs) * 20;
1088                 end;
1089         except
1090         end;
1091         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1092         for i := Length(BBSs) - 1 downto 0 do begin
1093                 if not BBSs[i].IsBoardFileRead then
1094                         GikoSys.ReadBoardFile(BBSs[i]);
1095
1096                 if SplashWindow <> nil then begin
1097                         SplashWindow.ProgressBar.StepBy(20);
1098                         SplashWindow.Update;
1099                 end;
1100         end;
1101
1102         //\8f\84\89ñ\83f\81[\83^\93Ç\82Ý\8d\9e\82Ý
1103         RoundList := TRoundList.Create;
1104         RoundList.LoadRoundBoardFile;
1105         RoundList.LoadRoundThreadFile;
1106
1107         //TreeView\82Ì\8e×\96\82\8fL\82¢ToolTip\82ð\94ñ\95\\8e¦
1108         Style := GetWindowLong(TreeView.Handle, GWL_STYLE);
1109         Style := Style or TVS_NOTOOLTIPS;
1110         SetWindowLong(TreeView.Handle, GWL_STYLE, Style);
1111
1112         // \83c\83\8a\81[\82ð\83\81\83C\83\93\82¾\82¯\95\\8e¦\82É\82µ\82Ä\8dÅ\91å\89»
1113         TreeView.Align := alClient;
1114         FavoriteTreeView.Align := alClient;
1115         FavoriteTreeView.Visible := False;
1116
1117         // \83\81\83j\83\85\81[\82É\92Ç\89Á
1118         SetBBSMenu;
1119
1120         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95\9c\8c³
1121         wp.length := sizeof(wp);
1122         wp.rcNormalPosition.Top := GikoSys.Setting.WindowTop;
1123         wp.rcNormalPosition.Left := GikoSys.Setting.WindowLeft;
1124         wp.rcNormalPosition.Bottom := GikoSys.Setting.WindowTop + GikoSys.Setting.WindowHeight;
1125         wp.rcNormalPosition.Right := GikoSys.Setting.WindowLeft + GikoSys.Setting.WindowWidth;
1126         wp.showCmd := SW_HIDE;
1127         SetWindowPlacement(Handle, @wp);
1128         //Self.Update;
1129
1130         if GikoSys.Setting.WindowMax then
1131                 WindowState := wsMaximized;
1132
1133         //\83M\83R\83A\83j\83\81
1134         try
1135                 FileName := GikoSys.GetAppDir + 'gikoNavi.avi';
1136                 if FileExists(FileName) then
1137                         Animate.FileName := FileName;
1138         except
1139         end;
1140
1141         //\83N\83b\83L\81[
1142         FNameCookie := '';
1143         FMailCookie := '';
1144
1145         //\83u\83\89\83E\83U\83T\83C\83Y\95Ï\8dX\82Ì\8f\89\8aú\89»
1146         FBrowserSizeHeight := GikoSys.Setting.ListHeight;
1147         FBrowserSizeWidth := GikoSys.Setting.ListWidth;
1148
1149
1150         // \83q\83X\83g\83\8a\83\8a\83X\83g(LoadHistory \82æ\82è\82à\90æ\82É\8ds\82¤\82±\82Æ)
1151         FHistoryList := THistoryList.Create;
1152
1153         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1154         FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1155         TreeView, FTreeType);
1156
1157         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1158         FavoriteDM.SetFavTreeView(FavoriteTreeView);
1159         FavoriteDM.ReadFavorite;
1160
1161         GikoDM.ArrangeAction.Checked := not (GikoSys.Setting.ListOrientation = gloVertical);
1162         GikoDM.ArrangeAction.Execute;
1163
1164         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
1165                 case GikoSys.Setting.ListWidthState of
1166                         glsMax: begin
1167                                 ViewPanel.Width := 1;
1168                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1169                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1170                         end;
1171                         glsMin: begin
1172                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1173                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1174                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1175                         end;
1176                         else begin
1177                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1178                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1179                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1180                         end;
1181                 end;
1182         end else begin
1183                 case GikoSys.Setting.ListHeightState of
1184                         glsMax: begin
1185                                 ViewPanel.Height := 1;
1186                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1187                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1188                         end;
1189                         glsMin: begin
1190                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1191                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1192                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1193                         end;
1194                         else begin
1195                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1196                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1197                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1198                         end;
1199                 end;
1200         end;
1201
1202         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
1203         CreateControlThread();
1204
1205         // \8di\8d\9e\8c\9f\8dõ\97\9a\97ð
1206         SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
1207
1208         //\83u\83\89\83E\83U\83^\83u\90Ý\92è
1209         SetBrowserTabState;
1210
1211         BrowserBoardNameLabel.Caption := '';
1212         BrowserNameLabel.Caption := '';
1213         FWorkCount := 0;
1214
1215         FTabHintIndex := -1;
1216
1217         //\83c\81[\83\8b\83o\81[Wrapable
1218         ListToolBar.Wrapable := GikoSys.Setting.ListToolBarWrapable;
1219         BrowserToolBar.Wrapable := GikoSys.Setting.BrowserToolBarWrapable;
1220
1221         MakeDefaultINIFile();
1222         //\83c\81[\83\8b\83{\83^\83\93\93Ç\82Ý\8d\9e\82Ý
1223         ReadToolBarSetting(GikoDM.GikoFormActionList, StdToolBar);
1224         ReadToolBarSetting(GikoDM.GikoFormActionList, ListToolBar);
1225         ReadToolBarSetting(GikoDM.GikoFormActionList, BrowserToolBar);
1226         SetToolBarPopup;
1227
1228         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
1229         SetSelectComboBox();
1230
1231         //\83A\83h\83\8c\83X\83o\81[
1232         AddressComboBox.TabStop := GikoSys.Setting.AddressBarTabStop;
1233
1234         //\83\8a\83\93\83N\83o\81[
1235         SetLinkBar;
1236         //\83N\81[\83\8b\83o\81[\95\9c\8c³\82ÍFormShow\82É\88Ú\93®\82µ\82½
1237
1238         //\83{\81[\83h\83t\83@\83C\83\8b\82ª\96³\82¢\8fê\8d\87\82Í\83\81\83b\83Z\81[\83W\95\\8e¦
1239         if not FileExists(GikoSys.GetBoardFileName) then begin
1240                 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
1241                                  + '\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
1242                                  + '\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';
1243                 MsgBox(SplashWindow.Handle, msg, '\83M\83R\83i\83r', MB_OK or MB_ICONINFORMATION);
1244                 GikoDM.NewBoardAction.Execute;
1245         end;
1246
1247         //\83L\81[\90Ý\92è\93Ç\82Ý\8d\9e\82Ý
1248         GikoSys.LoadKeySetting(GikoDM.GikoFormActionList, GikoSys.GetMainKeyFileName);
1249
1250         //\8dÅ\8fI\8f\84\89ñ\8e\9e\8aÔ
1251 //      FLastRoundTime := 0;
1252
1253         ListView.OnData := TListViewUtils.ListViewData;
1254
1255         // \8dÅ\8cã\82É\91I\91ð\82³\82ê\82½\83L\83\83\83r\83l\83b\83g\82Ì\95\9c\8c³
1256         CabinetVisible( False );
1257         if GikoSys.Setting.CabinetVisible then begin
1258                 i := CabinetSelectPopupMenu.Items.Count - 1;
1259                 if GikoSys.Setting.CabinetIndex = i - 1 then
1260                         GikoDM.CabinetHistoryAction.Execute
1261                 else if GikoSys.Setting.CabinetIndex = i then
1262                         GikoDM.CabinetFavoriteAction.Execute
1263                 else begin
1264                         if GikoSys.Setting.CabinetIndex < Length( BBSs ) then
1265                                 ShowBBSTree( BBSs[ GikoSys.Setting.CabinetIndex ] );
1266                         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô 2
1267                         FIsIgnoreResize := rtResizing;
1268                         GikoDM.CabinetBBSAction.Execute;
1269                 end;
1270         end else begin
1271                 ShowBBSTreeOld( BBSs[ 0 ] );
1272                 PostMessage( Handle, USER_TREECLICK, 0, 0 );
1273         end;
1274
1275         //\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
1276         for i := 1 to ParamCount do     begin
1277                 MoveToURL(ParamStr(i));
1278         end;
1279
1280         GikoDM.RepaintStatusBar;
1281         StatusBarResize(Sender);
1282
1283         dummy1.Caption  := ItemReservPMenu.Caption;
1284         dummy1.Hint     := ItemReservPMenu.Hint;
1285
1286     // \83}\83E\83X\83W\83F\83X\83`\83\83\81[
1287     MouseGesture := TMouseGesture.Create;
1288
1289 {$IFDEF SPAM_FILTER_ENABLED}
1290         // \83X\83p\83\80\83t\83B\83\8b\83^\8aw\8fK\97\9a\97ð
1291         GikoSys.Bayesian.LoadFromFile( GikoSys.Setting.GetSpamFilterFileName );
1292 {$ENDIF}
1293
1294         //2ch\8c¾\8cê\93Ç\82Ý\8fo\82µ
1295         GikoSys.SetGikoMessage;
1296
1297         //\83I\81[\83g\83\8d\83O\83C\83\93
1298         if GikoSys.Setting.AutoLogin then
1299                 GikoDM.LoginAction.Execute;
1300
1301         GikoSys.Setting.BeLogin := GikoSys.Setting.BeAutoLogin;
1302
1303         //\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è
1304         FavoriteAddToolButton.Caption := '\92Ç\89Á...';
1305         AntiIndivAbonMenuItem.Caption := '\8cÂ\95Ê\82 \82Ú\81`\82ñ\89ð\8f\9c';
1306
1307         //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\8f\89\8aú\89»
1308         InputAssistDM.Init(GikoSys.GetInputAssistFileName);
1309
1310     //\92u\8a·\90Ý\92è\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
1311     ReplaceDM.LoadFromFile(GikoSys.GetReplaceFileName);
1312
1313     //\83\8c\83X\83|\83b\83v\83A\83b\83v\8fÁ\8b\8e\83^\83C\83}\81[
1314     ResPopupClearTimer.Interval := GikoSys.Setting.RespopupWait;
1315
1316     // D&D\82ð\8eó\82¯\8eæ\82é
1317     DragAcceptFiles(ListView.Handle, True);
1318
1319     // \8f\89\8aú\89»\82É\8e¸\94s\82µ\82½\83\82\83W\83\85\81[\83\8b\83`\83F\83b\83N
1320     if (FavoriteDM.AbEnd) then begin
1321         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',
1322             '\8f\89\8aú\89»\88Ù\8fí');
1323         Self.Close;
1324     end;
1325
1326 end;
1327
1328 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
1329 procedure TGikoForm.SaveCoolBarSettings;
1330 begin
1331
1332         if IsIconic( Handle ) or (FIsIgnoreResize <> rtNone) then
1333                 Exit;
1334         SaveMainCoolBarSettings;
1335         SaveBoardCoolBarSettings;
1336         SaveBrowserCoolBarSettings;
1337
1338 end;
1339 procedure TGikoForm.SaveMainCoolBarSettings;
1340 var
1341         i : Integer;
1342         CoolSet : TCoolSet;
1343 begin
1344         //\83N\81[\83\8b\83o\81[\95Û\91¶(Main)
1345         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
1346                 CoolSet.FCoolID := MainCoolBar.Bands[i].ID;
1347                 CoolSet.FCoolWidth := MainCoolBar.Bands[i].Width;
1348                 CoolSet.FCoolBreak := MainCoolBar.Bands[i].Break;
1349                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
1350         end;
1351 end;
1352 procedure TGikoForm.SaveBoardCoolBarSettings;
1353 var
1354         i : Integer;
1355         CoolSet : TCoolSet;
1356 begin
1357         //\83N\81[\83\8b\83o\81[\95Û\91¶(Board)
1358         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
1359                 CoolSet.FCoolID := ListCoolBar.Bands[i].ID;
1360                 CoolSet.FCoolWidth := ListCoolBar.Bands[i].Width;
1361                 CoolSet.FCoolBreak := ListCoolBar.Bands[i].Break;
1362                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
1363         end;
1364 end;
1365 procedure TGikoForm.SaveBrowserCoolBarSettings;
1366 var
1367         i : Integer;
1368         CoolSet : TCoolSet;
1369 begin
1370         //\83N\81[\83\8b\83o\81[\95Û\91¶(Browser)
1371         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
1372                 CoolSet.FCoolID := BrowserCoolBar.Bands[i].ID;
1373                 CoolSet.FCoolWidth := BrowserCoolBar.Bands[i].Width;
1374                 CoolSet.FCoolBreak := BrowserCoolBar.Bands[i].Break;
1375                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
1376         end;
1377 end;
1378 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82©\82ç\95\9c\8c³
1379 procedure TGikoForm.LoadCoolBarSettings;
1380 var
1381         i                               : Integer;
1382         CoolSet : TCoolSet;
1383 begin
1384
1385         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Main)
1386         MainCoolBar.Bands.BeginUpdate;
1387         try
1388 //              for i := 0 to MainCoolBar.Bands.Count - 1 do begin
1389                 for i := MAIN_COOLBAND_COUNT - 1 downto 0 do begin
1390                         CoolSet := GikoSys.Setting.MainCoolSet[i];
1391                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1392                                 FIsIgnoreResize := rtNone;
1393                                 SaveCoolBarSettings;
1394                                 Exit;
1395                         end;
1396                         MainCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1397                         MainCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1398                         MainCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1399                 end;
1400         finally
1401                 MainCoolBar.Bands.EndUpdate;
1402         end;
1403
1404         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Board)
1405         ListCoolBar.Bands.BeginUpdate;
1406         try
1407 //              for i := 0 to ListCoolBar.Bands.Count - 1 do begin
1408                 for i := LIST_COOLBAND_COUNT - 1 downto 0 do begin
1409                         CoolSet := GikoSys.Setting.ListCoolSet[i];
1410                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1411                                 FIsIgnoreResize := rtNone;
1412                                 SaveCoolBarSettings;
1413                                 Exit;
1414                         end;
1415                         ListCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1416                         ListCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1417                         ListCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1418                 end;
1419         finally
1420                 ListCoolBar.Bands.EndUpdate;
1421         end;
1422
1423         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Browser)
1424         BrowserCoolBar.Bands.BeginUpdate;
1425         try
1426 //              for i := 0 to BrowserCoolBar.Bands.Count - 1 do begin
1427                 for i := BROWSER_COOLBAND_COUNT - 1 downto 0 do begin
1428                         CoolSet := GikoSys.Setting.BrowserCoolSet[i];
1429                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1430                                 FIsIgnoreResize := rtNone;
1431                                 SaveCoolBarSettings;
1432                                 Exit;
1433                         end;
1434                         BrowserCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1435                         BrowserCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1436                         BrowserCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1437                 end;
1438         finally
1439                 BrowserCoolBar.Bands.EndUpdate;
1440         end;
1441
1442 end;
1443 //
1444 procedure TGikoForm.FormShow(Sender: TObject);
1445 var
1446         item        : TThreadItem;
1447 begin
1448         if FStartUp then begin
1449                 ShowWindow(Application.Handle, SW_HIDE);
1450
1451                 //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½
1452                 //\83c\81[\83\8b\83o\81[\95\\8e¦
1453                 GikoDM.StdToolBarVisibleAction.Checked := GikoSys.Setting.StdToolBarVisible;
1454                 GikoDM.StdToolBarVisibleActionExecute( nil );
1455                 GikoDM.AddressBarVisibleAction.Checked := GikoSys.Setting.AddressBarVisible;
1456                 GikoDM.AddressBarVisibleActionExecute( nil );
1457                 GikoDM.LinkBarVisibleAction.Checked := GikoSys.Setting.LinkBarVisible;
1458                 GikoDM.LinkBarVisibleActionExecute( nil );
1459                 GikoDM.ListToolBarVisibleAction.Checked := GikoSys.Setting.ListToolBarVisible;
1460                 GikoDM.ListToolBarVisibleActionExecute( nil );
1461                 GikoDM.ListNameBarVisibleAction.Checked := GikoSys.Setting.ListNameBarVisible;
1462                 GikoDM.ListNameBarVisibleActionExecute( nil );
1463                 GikoDM.BrowserToolBarVisibleAction.Checked := GikoSys.Setting.BrowserToolBarVisible;
1464                 GikoDM.BrowserToolBarVisibleActionExecute( nil );
1465                 GikoDM.BrowserNameBarVisibleAction.Checked := GikoSys.Setting.BrowserNameBarVisible;
1466                 GikoDM.BrowserNameBarVisibleActionExecute( nil );
1467
1468                 // CoolBar \95\9c\8c³
1469                 LoadCoolBarSettings;
1470
1471                 //\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é
1472 //              ResetBandInfo( ListCoolBar, ListToolBar );
1473                 FIsIgnoreResize := rtNone;
1474
1475                 //FormCrete\82©\82ç\88Ú\93®\81B
1476                 if GikoSys.Setting.TabAutoLoadSave then begin
1477             GikoDM.TabsOpenAction.Tag := 1;
1478                         GikoDM.TabsOpenAction.Execute;
1479             GikoDM.TabsOpenAction.Tag := 0;
1480             if (GikoSys.Setting.LastCloseTabURL <> '') then begin
1481                 PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( FActiveContent.Browser ), 0 );
1482                 if ( FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
1483                         while (FActiveContent.Browser.ReadyState <> READYSTATE_COMPLETE) and
1484                                 (FActiveContent.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
1485                                 Application.ProcessMessages;
1486                     end;
1487                         end;
1488                 item := BBSsFindThreadFromURL( GikoSys.Setting.LastCloseTabURL );
1489                 if (item <> nil) and (item.IsLogFile) then begin
1490                     OpenThreadItem(item, item.URL);
1491                 end;
1492                 GikoSys.Setting.LastCloseTabURL := '';
1493             end;
1494                 end;
1495
1496         //ActionList\82ÌGroupIndex\82ð\8c³\82É\96ß\82·
1497                 SetGroupIndex(GikoDM.GikoFormActionList);
1498
1499                 FStartUp := false;
1500         end;
1501 end;
1502
1503 procedure TGikoForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
1504 begin
1505 //      if GikoForm.WindowState <> wsMinimized then
1506 //              SaveCoolBarSettings;
1507         CanClose := True;
1508         if ( GikoSys.Setting.ShowDialogForEnd ) and
1509                         (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
1510                 CanClose := false;
1511                         Exit;
1512         end;
1513
1514     GikoSys.Setting.LastCloseTabURL := '';
1515         if GikoSys.Setting.TabAutoLoadSave then begin
1516                 GikoDM.TabsSaveAction.Execute;
1517         if (GetActiveContent <> nil) and
1518             (GetActiveContent.IsLogFile) then begin
1519             GikoSys.Setting.LastCloseTabURL := GetActiveContent.URL;
1520         end;
1521         end;
1522
1523         if (SearchDialog <> nil) then begin
1524                 if (SearchDialog.Visible) then begin
1525                         SearchDialog.Close;
1526                 end;
1527         try
1528             SearchDialog.Release;
1529         except
1530         end;
1531         SearchDialog := nil;
1532         end;
1533
1534         //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\95Â\82\82é
1535     GikoDM.CloseAllEditorAction.Execute;
1536
1537         Application.UnhookMainWindow(Hook);
1538     //\83A\83v\83\8a\83P\81[\83V\83\87\83\93\8fI\97¹\82Ì\91O\82É\83_\83E\83\93\83\8d\81[\83h\83X\83\8c\83b\83h\82É\90³\8fí\8fI\97¹\82ð\91£\82·
1539     FControlThread.Terminate;
1540         Application.Terminate;
1541 end;
1542
1543 procedure TGikoForm.FormDestroy(Sender: TObject);
1544 var
1545         i                               : Integer;
1546         wp                      : TWindowPlacement;
1547         tmpBool : Boolean;
1548 begin
1549         // \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\95ú
1550         try
1551         if GikoSys.Setting.GestureEnabled then begin
1552                 MouseGesture.OnGestureStart := nil;
1553                     MouseGesture.OnGestureMove := nil;
1554                     MouseGesture.OnGestureEnd := nil;
1555         end;
1556         MouseGesture.Clear;
1557                 MouseGesture.UnHook;
1558         MouseGesture.Free;
1559         except
1560         end;
1561         try
1562                 ActiveListColumnSave;
1563         except
1564         end;
1565         try
1566                 //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
1567                 wp.length := sizeof(wp);
1568                 GetWindowPlacement(Handle, @wp);
1569                 GikoSys.Setting.WindowTop := wp.rcNormalPosition.Top;
1570                 GikoSys.Setting.WindowLeft := wp.rcNormalPosition.Left;
1571                 GikoSys.Setting.WindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
1572                 GikoSys.Setting.WindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
1573                 GikoSys.Setting.WindowMax := WindowState = wsMaximized;
1574
1575                 GikoSys.Setting.ListStyle := ListView.ViewStyle;
1576                 GikoSys.Setting.CabinetVisible := GikoDM.CabinetVisibleAction.Checked;
1577                 GikoSys.Setting.CabinetWidth := CabinetPanel.Width;
1578                 GikoSys.Setting.ListHeight := FBrowserSizeHeight;
1579                 GikoSys.Setting.ListWidth := FBrowserSizeWidth;
1580                 if GikoDM.ArrangeAction.Checked then
1581                         GikoSys.Setting.ListOrientation := gloVertical
1582                 else
1583                         GikoSys.Setting.ListOrientation := gloHorizontal;
1584                 GikoSys.Setting.MessegeBarHeight := MessagePanel.Height;
1585         except
1586         end;
1587
1588         try
1589                 // \83\8c\83X\95\\8e¦\94Í\88Í
1590                 if not GikoSys.Setting.ResRangeHold then
1591                         GikoSys.Setting.ResRange := FResRangeMenuSelect;
1592         except
1593         end;
1594         if WindowState <> wsNormal then
1595                 WindowState := wsNormal;
1596         SaveCoolBarSettings;
1597         try
1598                 GikoSys.Setting.WriteWindowSettingFile;
1599                 GikoSys.Setting.WriteNameMailSettingFile;
1600         except
1601         end;
1602         // \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è
1603         // \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¢
1604
1605                 // \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
1606         // CoolBar \95Û\91
1607         //if (GikoForm.WindowState <> wsMinimized) and (GikoForm.WindowState <> wsMaximized) then
1608
1609         //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\90Ý\92è\82Ì\95Û\91
1610         InputAssistDM.SaveToFile(GikoSys.GetInputAssistFileName);
1611
1612         //\82¨\8bC\82É\93ü\82è\95Û\91
1613         try
1614                 //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é
1615         // \8f\89\8aú\89»\88Ù\8fí\8e\9e\82©\82ç\82Ì\8fI\97¹\82Å\82Í\95Û\91\82µ\82È\82¢
1616         if not (FavoriteDM.AbEnd) then begin
1617                 FavoriteDM.WriteFavorite;
1618         end;
1619                 FavoriteDM.Clear;
1620         except
1621         end;
1622         //LockWindowUpdate(Self.Handle);
1623         try
1624                 //\83^\83u\83N\83\8d\81[\83Y
1625                 tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
1626                 GikoSys.Setting.ShowDialogForAllTabClose := false;
1627                 GikoDM.AllTabCloseAction.Execute;
1628                 GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
1629         except
1630         end;
1631         try
1632                 for i := FBrowsers.Count - 1 downto 0 do begin
1633                         TWebBrowser(FBrowsers[i]).Free;
1634                 end;
1635                 FBrowsers.Clear;
1636                 FBrowsers.Capacity := 0;
1637         finally
1638                 FBrowsers.Free;
1639         end;
1640         try
1641                 if BrowserNullTab <> nil then begin
1642                         BrowserNullTab.Browser := nil;  {*BrowserNullTab\82ÌBrowser\82Í\90Ý\8cv\8e\9e\82É\93\\82è\95t\82¯\82Ä\82é\93z
1643                                                                                          *\82È\82Ì\82Å\82±\82±\82ÅFree\82³\82ê\82é\82Æ\8d¢\82é\82Ì\82Å\82Í\82¸\82µ\82Ä\82µ\82Ü\82¤\81B
1644                                                                                          *}
1645                         BrowserNullTab.Free;
1646                 end;
1647         except
1648         end;
1649
1650         try
1651                 TreeView.Items.BeginUpdate;
1652                 TreeView.Items.GetFirstNode.Free;
1653                 TreeView.Items.Clear;
1654                 TreeView.Items.EndUpdate;
1655         except
1656         end;
1657
1658         //\83A\83h\83\8c\83X\97\9a\97ð\95Û\91
1659         try
1660                 //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
1661                 AddressHistoryDM.WriteHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
1662         except
1663         end;
1664
1665         //\83q\83X\83g\83\8a\83\8a\83X\83g\95Û\91
1666         try
1667                 FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1668         except
1669         end;
1670         try
1671                 try
1672                         FHistoryList.Clear;
1673                 except
1674                 end;
1675         finally
1676                 FHistoryList.Free;
1677         end;
1678
1679         //\8f\84\89ñ\83\8a\83X\83g\95Û\91¶&\94j\8aü
1680         try
1681                 RoundList.SaveRoundFile;
1682         except
1683         end;
1684         try
1685                 try
1686                         RoundList.Clear;
1687                 except
1688                 end;
1689         finally
1690                 RoundList.Free;
1691          end;
1692
1693         try
1694         try
1695             FControlThread.DownloadAbort;
1696             FControlThread.Terminate;
1697             FControlThread.WaitFor;
1698         except
1699         end;
1700     finally
1701         FControlThread.Free;
1702         end;
1703     // \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é
1704     for i := GikoForm.PlugInMenu.Count - 1 downto 0 do begin
1705                 GikoForm.PlugInMenu.items[i].Free;
1706         end;
1707     GikoForm.PlugInMenu.Clear;
1708
1709
1710         // TBBS \82Í\95Û\8e\9d\82µ\82Ä\82¢\82é TCategory, TBoard, TThreadItem \82·\82×\82Ä\82ð\8aJ\95ú\82·\82é
1711         // 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Å
1712         // BoardPluteIns \82Ì\8aJ\95ú\82æ\82è\90æ\82É\8ds\82¤\82±\82Æ
1713         for i := Length(BoardGroups) - 1 downto 0 do begin
1714                 //BoardGroups[i].Clear;
1715                 BoardGroups[i].Free;
1716         end;
1717
1718         try
1719                 for i := Length( BBSs ) - 1 downto 0 do begin
1720                         if BBSs[ i ] <> nil then
1721                                 BBSs[ i ].Free;
1722                         BBSs[ i ] := nil;
1723                 end;
1724         except
1725         end;
1726
1727         try
1728                 if FEvent <> nil then
1729                         FEvent.Free;
1730
1731         try
1732             if FResPopupBrowser <> nil then  begin
1733                 TOleControl(FResPopupBrowser).Parent := nil;
1734                 FResPopupBrowser.Free;
1735             end;
1736
1737         except
1738         end;
1739                 //Preview\94j\8aü
1740                 if FPreviewBrowser <> nil then begin
1741                         FPreviewBrowser.Free;
1742                         FPreviewBrowser := nil;
1743                 end;
1744         except
1745         end;
1746         //LockWindowUpdate(0);
1747 end;
1748
1749 // \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
1750 procedure TGikoForm.SetBBSMenu;
1751 var
1752         i                       : Integer;
1753         item    : TBBSMenuItem;
1754 begin
1755
1756         // \83\81\83j\83\85\81[\82ð\8dí\8f\9c
1757         for i := CabinetSelectPopupMenu.Items.Count - 1 downto 0 do begin
1758                 try
1759                         if CabinetSelectPopupMenu.Items[ i ] is TBBSMenuItem then begin
1760                                 CabinetSelectPopupMenu.Items[ i ].Free;
1761                                 CabinetMenu.Items[ i ].Free;
1762                                 BBSSelectPopupMenu.Items[ i ].Free;
1763                         end;
1764                 except
1765                 end;
1766         end;
1767
1768         // \83\81\83j\83\85\81[\82ð\90Ý\92è
1769         for i := Length( BBSs ) - 1 downto 0 do begin
1770                 try
1771                         item                                    := TBBSMenuItem.Create( PopupMenu );
1772                         item.Caption    := BBSs[ i ].Title;
1773                         item.Data                       := BBSs[ i ];
1774                         item.OnClick    := BBSMenuItemOnClick;
1775                         CabinetSelectPopupMenu.Items.Insert( 0, item );
1776                         item                                    := TBBSMenuItem.Create( PopupMenu );
1777                         item.Caption    := BBSs[ i ].Title;
1778                         item.Data                       := BBSs[ i ];
1779                         item.OnClick    := BBSMenuItemOnClick;
1780                         CabinetMenu.Insert( 0, item );
1781                         item                                    := TBBSMenuItem.Create( PopupMenu );
1782                         item.Caption    := BBSs[ i ].Title;
1783                         item.Data                       := BBSs[ i ];
1784                         item.OnClick    := BBSMenuItemOnClick;
1785                         BBSSelectPopupMenu.Items.Insert( 0, Item );
1786                 except
1787                 end;
1788         end;
1789
1790 end;
1791
1792 procedure TGikoForm.ReloadBBS;
1793 var
1794         i                       : Integer;
1795         tmpBool: Boolean;
1796 begin
1797     LockWindowUpdate(Self.Handle);
1798
1799         //\83^\83u\83N\83\8d\81[\83Y
1800         tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
1801         GikoSys.Setting.ShowDialogForAllTabClose := false;
1802         GikoDM.AllTabCloseAction.Execute;
1803         GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
1804         SetContent(BrowserNullTab);
1805         //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
1806         TreeView.Items.Clear;
1807
1808         //\8f\84\89ñ\83\8a\83X\83g\95Û\91
1809         try
1810                 RoundList.SaveRoundFile;
1811         except
1812         end;
1813         //\8f\84\89ñ\83\8a\83X\83g\82ð\94j\8aü
1814         try
1815                 RoundList.Clear;
1816         except
1817         end;
1818
1819         //\97\9a\97ð\82Ì\95Û\91\82Æ\94j\8aü
1820         try
1821                 FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1822                 FHistoryList.Clear;
1823         except
1824         end;
1825
1826         //\82¨\8bC\82É\93ü\82è\82Ì\95Û\91\82Æ\94j\8aü
1827         try
1828                 FavoriteDM.WriteFavorite;
1829                 FavoriteDM.Clear;
1830         except
1831         end;
1832
1833         //\94Â\81E\83X\83\8c\81EPLUGIN\82Ì\94j\8aü
1834         for i := Length(BoardGroups) - 1 downto 0 do begin
1835                 try
1836                         BoardGroups[i].Free;
1837                 except
1838                 end;
1839         end;
1840         //BBS\94j\8aü
1841         try
1842                 for i := Length( BBSs ) - 1 downto 0 do begin
1843                         if BBSs[ i ] <> nil then
1844                                 BBSs[ i ].Free;
1845                         BBSs[ i ] := nil;
1846                 end;
1847         except
1848         end;
1849
1850         ActiveList := nil;
1851
1852         FTreeType := gttNone;
1853
1854         //============\82±\82±\82©\82ç\89º\82Å\81A\8dÄ\90¶================================//
1855
1856         // \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Æ)
1857         InitializeBoardPlugIns;
1858
1859         GikoSys.ListBoardFile;          //\83{\81[\83h\83t\83@\83C\83\8b\93Ç\8d\9e
1860
1861         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1862         for i := Length(BBSs) - 1 downto 0 do begin
1863                 if not BBSs[i].IsBoardFileRead then
1864                         GikoSys.ReadBoardFile(BBSs[i]);
1865         end;
1866
1867         // BBS \83\81\83j\83\85\81[\82Ì\8dX\90V
1868         SetBBSMenu;
1869
1870         ShowBBSTree( BBSs[ 0 ] );
1871
1872         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1873     FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1874         TreeView, FTreeType);
1875
1876         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1877         FavoriteDM.ReadFavorite;
1878
1879         SetLinkBar;
1880
1881         //\8f\84\89ñ\82Ì\93Ç\82Ý\8d\9e\82Ý
1882         RoundList.LoadRoundBoardFile;
1883         RoundList.LoadRoundThreadFile;
1884
1885         LockWindowUpdate(0);
1886 end;
1887
1888 {!
1889 \todo \89½\8cÌ IE 7 \82Å\82Í about:.. \82É\82È\82é\82Ì\82©
1890       (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©)
1891       \92²\8d¸\82·\82é\82±\82Æ
1892 }
1893 procedure TGikoForm.BrowserStatusTextChange(Sender: TObject; const Text: WideString);
1894 var
1895         p: TPoint;
1896         s: string;
1897         tmp2: string;
1898         URL: string;
1899         ATitle: Boolean;
1900
1901         threadItem      : TThreadItem;
1902         board                           : TBoard;
1903         Protocol, Host, Path, Document, Port, Bookmark: string;
1904
1905         wkInt: Integer;
1906         wkIntSt: Integer;
1907         wkIntTo: Integer;
1908         ActiveFileName: string;
1909         e: IHTMLElement;
1910         Ext: string;
1911         PathRec: TPathRec;
1912   Text2: string;
1913     cResPopup: TResPopupBrowser;
1914 begin
1915         // \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ª
1916   // 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è)
1917         if Pos('about:..', Text) = 1 then
1918         Text2 := 'about:blank..' + Copy( Text, Length('about:..')+1, Length(Text) )
1919   else
1920         Text2 := Text;
1921         if not( TObject(Sender) is TWebBrowser )then
1922                 Exit;
1923         try
1924                 try
1925                         if (TWebBrowser(Sender) <> nil) and (not TWebBrowser(Sender).Busy) and (Assigned(TWebBrowser(Sender).Document)) then begin
1926                                 if LowerCase(OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset) <> 'shift_jis' then begin
1927                                         OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset := 'shift_jis';
1928                                 end;
1929                         end;
1930                 except
1931                 end;
1932         finally
1933         end;
1934         if PreviewTimer.Enabled then
1935                 PreviewTimer.Enabled := False;
1936         Application.CancelHint;
1937         try
1938                 if GetActiveContent <> nil then
1939                         ActiveFileName := ChangeFileExt(ExtractFileName(GetActiveContent.FileName), '')
1940                 else
1941                         ActiveFileName := '';
1942         except
1943                 FActiveContent := nil;
1944                 Exit;
1945         end;
1946     // \91O\89ñ\82Æ\93¯\82\8fê\8d\87\8fI\97¹
1947     if (StatusBar.Panels[1].Text = Text2) then begin
1948         if Text2 = '' then begin
1949             if FResPopupBrowser <> nil then begin
1950                 if not(Sender is TResPopupBrowser) then
1951                     FResPopupBrowser.Clear
1952                 else begin
1953                     TResPopupBrowser(Sender).ChildClear;
1954                 end;
1955             end;
1956         end;
1957         Exit;
1958     end;
1959         StatusBar.Panels[1].Text := Text2;
1960
1961
1962         if FPreviewBrowser <> nil then
1963                 ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
1964
1965     if FResPopupBrowser <> nil then begin
1966         if not(Sender is TResPopupBrowser) then begin
1967             if (FResPopupBrowser.Visible) then begin
1968                 if ResPopupClearTimer.Interval > 0 then begin
1969                     ResPopupClearTimer.Enabled := True;
1970                     ResPopupClearTimer.Tag := 0;
1971                 end else begin
1972                     FResPopupBrowser.Clear;
1973                 end;
1974             end;
1975         end else begin
1976             if ResPopupClearTimer.Interval > 0 then begin
1977                 ResPopupClearTimer.Enabled := True;
1978                 ResPopupClearTimer.Tag := 1;
1979             end else begin
1980                 TResPopupBrowser(Sender).ChildClear;
1981             end;
1982         end;
1983     end;
1984     cResPopup := nil;
1985     
1986     if not(Sender is TResPopupBrowser) then
1987         if not GikoSys.Setting.UnActivePopup then
1988                 if not GikoForm.Active then
1989                         Exit;
1990
1991
1992
1993 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10
1994 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10-15
1995
1996         s := '';
1997         Ext := AnsiLowerCase(ExtractFileExt(Text2));
1998         if (Pos('http://', Text2) = 1) and (GikoSys.Setting.PreviewVisible) and
1999                         ((Ext = '.jpg') or (Ext = '.jpeg') or (Ext = '.gif') or (Ext = '.png')) then begin
2000                 if FPreviewBrowser = nil then begin
2001                         FPreviewBrowser := TPreviewBrowser.Create(Self);
2002                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
2003                         TOleControl(FPreviewBrowser).Parent := nil;
2004                 end;
2005                 FPreviewBrowser.Navigate(BLANK_HTML);//\91O\89ñ\82Ì\83v\83\8c\83r\83\85\81[\89æ\91\9c\8fÁ\8b\8e\97p
2006                 FPreviewURL := Text2;
2007                 PreviewTimer.Interval := GikoSys.Setting.PreviewWait;
2008                 PreviewTimer.Enabled := True;
2009         end else if (Pos('about:blank', Text2) = 1) or (Pos('http://', Text2) = 1) or (Pos('mailto:', Text2) = 1) then begin
2010                 if (Pos('mailto:', Text2) = 1) and (GikoSys.Setting.RespopupMailTo) then begin
2011                         s := StringReplace(Text2, 'mailto:', '', [rfIgnoreCase]);
2012                         //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g3\82Ì466\8e\81\82É\8a´\8eÓ
2013                         GetCursorPos(p);
2014                         p.x := p.x - TWebBrowser(Sender).ClientOrigin.x;
2015                         p.y := p.y - TWebBrowser(Sender).ClientOrigin.y;
2016                         e := IHTMLDocument2(TWebBrowser(Sender).Document).elementFromPoint(p.x, p.y);
2017                         if (Assigned(e)) then begin
2018                 CreateResPopupBrowser;
2019
2020                 if not(Sender is TResPopupBrowser) then begin
2021                     if (FResPopupBrowser.Visible) then begin
2022                         FResPopupBrowser.Clear;
2023                     end;
2024                 end else begin
2025                     TResPopupBrowser(Sender).ChildClear;
2026                 end;
2027
2028                 cResPopup := FResPopupBrowser.CreateNewBrowser;
2029                                 tmp2 := ZenToHan(e.Get_outerText);
2030                                 if (GikoSys.IsNumeric(tmp2)) then begin
2031                                         //\82\93\82Í\83\8c\83X\94Ô\8d\86\82Á\82Û\82¢\82Á\82·\81B
2032                                         wkIntSt := StrToInt64(tmp2);
2033                                         wkIntTo := StrToInt64(tmp2);
2034                     cResPopup.PopupType := gptThread;
2035                                         HTMLCreater.SetResPopupText(cResPopup, GetActiveContent(true), wkIntSt, wkIntTo, False, False);
2036                                 end else begin
2037                     cResPopup.PopupType := gptRaw;
2038                     cResPopup.Title := s;
2039                                 end;
2040                         end;
2041                 end else begin
2042             CreateResPopupBrowser;
2043
2044             if not(Sender is TResPopupBrowser) then begin
2045                 if (FResPopupBrowser.Visible) then begin
2046                     FResPopupBrowser.Clear;
2047                 end;
2048             end else begin
2049                 TResPopupBrowser(Sender).ChildClear;
2050             end;
2051
2052                         threadItem := GetActiveContent(true);
2053                         URL := THTMLCreate.GetRespopupURL(Text2, threadItem.URL);
2054                         PathRec := Gikosys.Parse2chURL2(URL);
2055                         if (PathRec.FNoParam) then begin
2056                                 PathRec.FSt := 1;
2057                                 PathRec.FTo := 1;
2058                         end else begin
2059                                 Gikosys.GetPopupResNumber(URL,PathRec.FSt,PathRec.FTo);
2060                         end;
2061                         GikoSys.ParseURI( URL, Protocol, Host, Path, Document, Port, Bookmark );
2062
2063                         if PathRec.FDone or (not GikoSys.Is2chHost( Host )) then begin
2064
2065                                 URL := GikoSys.GetBrowsableThreadURL( URL );
2066                                 wkIntSt := PathRec.FSt;
2067                                 wkIntTo := PathRec.FTo;
2068
2069                                 if (wkIntSt = 0) and (wkIntTo = 0) then begin
2070                                         wkIntSt := 1;
2071                                         wkIntTo := 1;
2072                                 end else if (wkIntSt = 0) and (wkIntTo > 0) then begin
2073                                         wkIntSt := wkIntTo;
2074                                 end else if (wkIntSt > 0) and (wkIntTo = 0) then begin
2075                                         wkIntTo := wkIntSt;
2076                                 end else if wkIntSt > wkIntTo then begin
2077                                         wkInt := wkIntTo;
2078                                         wkIntTo := wkIntSt;
2079                                         wkIntSt := wkInt;
2080                                 end;
2081                                 if (FActiveContent <> nil) and (FActiveContent.Thread.URL = URL) then
2082                                         ATitle := false
2083                                 else
2084                                         ATitle := true;
2085
2086                                 threadItem := BBSsFindThreadFromURL( URL );
2087
2088                                 if (threadItem = nil) and GikoSys.Is2chHost( Host ) then begin
2089                                         board := BBSs[ 0 ].FindBBSID( PathRec.FBBS );
2090                                         if board <> nil then begin
2091                                                 if not board.IsThreadDatRead then
2092                                                         GikoSys.ReadSubjectFile( board );
2093                                                 threadItem := board.FindThreadFromFileName( PathRec.FKey + '.dat' );
2094                                         end;
2095                                 end;
2096
2097                                 if threadItem <> nil then begin
2098                                         //HintData := GetThreadText(PathRec.FBBS, PathRec.FKey, wkIntSt, wkIntTo, ATitle, PathRec.FFirst);
2099                                         //URL\82Ì\8dÅ\8cã\82É/\82ª\95t\82¢\82Ä\82¢\82È\82¢\82Æ\82«\97p
2100                                         if ( IntToStr(wkIntSt) = ChangeFileExt(threadItem.FileName, '') ) then begin
2101                                                 wkIntSt := 1;
2102                                                 wkIntTo := 1;
2103                                         end;
2104                     cResPopup := FResPopupBrowser.CreateNewBrowser;
2105                     cResPopup.PopupType := gptThread;
2106                                         HTMLCreater.SetResPopupText(cResPopup, threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
2107                                 end;
2108                         end;
2109                 end;
2110         if (cResPopup <> nil) then begin
2111             ResPopupClearTimer.Enabled := False;
2112
2113             if cResPopup.PopupType = gptRaw then begin
2114                 if cResPopup.Title <> '' then begin
2115                     cResPopup.TitlePopup;
2116                 end;
2117             end else begin
2118                 if cResPopup.RawDocument <> '' then begin
2119                     cResPopup.Popup;
2120                 end else if cResPopup.Title <> '' then begin
2121                     cResPopup.TitlePopup;
2122                 end;
2123             end;
2124         end;
2125         end;
2126 end;
2127
2128 procedure TGikoForm.SetEnabledCloseButton(Enabled: Boolean);
2129 var
2130         SysMenu: HMenu;
2131 begin
2132         FEnabledCloseButton := Enabled;
2133         SysMenu := GetSystemMenu(Handle, False);
2134
2135         if Enabled then begin
2136                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
2137         end else begin
2138                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
2139         end;
2140
2141         DrawMenuBar(Handle);
2142 end;
2143
2144 procedure TGikoForm.TreeViewChanging(Sender: TObject; Node: TTreeNode;
2145         var AllowChange: Boolean);
2146 begin
2147 //\83\\81[\83g\8f\87\82ð\95Û\91\82·\82é\82æ\82¤\82É\82µ\82½\82Ì\82Å\8dí\8f\9c
2148 //      if FTreeType = gtt2ch then
2149 //              FSortIndex := -1;
2150 end;
2151
2152 procedure TGikoForm.ListViewKeyDown(Sender: TObject; var Key: Word;
2153         Shift: TShiftState);
2154 var
2155         pos     : TPoint;
2156 begin
2157         if GetActiveList is TBoard then begin
2158                 case Key of
2159                 VK_BACK:;       //      UpFolderButtonClick(Sender);
2160                 VK_SPACE:                       ListDoubleClick(Shift);
2161                 VK_RETURN:              ListClick;
2162                 VK_APPS:
2163                         begin
2164                                 if ListView.Selected <> nil then begin
2165                                         pos.X := ListView.Column[ 0 ].Width;
2166                                         pos.Y := ListView.Selected.Top;
2167                                 end else begin
2168                                         pos.X := ListView.Left;
2169                                         pos.Y := ListView.Top;
2170                                 end;
2171                                 Windows.ClientToScreen( ListView.Handle, pos );
2172                                 ListPopupMenu.Popup( pos.X, pos.Y );
2173                         end;
2174                 end;
2175         end else begin // TBBS, TCategory
2176                 case Key of
2177                 VK_BACK:;       //      UpFolderButtonClick(Sender);
2178                 VK_SPACE:                       ListClick;
2179                 VK_RETURN:              ListDoubleClick(Shift);
2180                 VK_APPS:
2181                         begin
2182                                 if ListView.Selected <> nil then begin
2183                                         pos.X := ListView.Column[ 0 ].Width;
2184                                         pos.Y := ListView.Selected.Top;
2185                                 end else begin
2186                                         pos.X := ListView.Left;
2187                                         pos.Y := ListView.Top;
2188                                 end;
2189                                 Windows.ClientToScreen( ListView.Handle, pos );
2190                                 ListPopupMenu.Popup( pos.X, pos.Y );
2191                         end;
2192                 end;
2193         end;
2194 end;
2195
2196 function TGikoForm.GetHttpState: Boolean;
2197 begin
2198         Result := FHttpState;
2199 end;
2200
2201 procedure TGikoForm.ListViewColumnClick(Sender: TObject;
2202         Column: TListColumn);
2203 var
2204         id, idx                 : Integer;
2205         orderList               : TList;
2206         vSortIndex              : Integer;
2207         vSortOrder              : Boolean;
2208 begin
2209         idx := TListViewUtils.ActiveListTrueColumn( Column ).Tag;
2210         if TObject( FActiveList ) is TBBS then begin
2211                 orderList := GikoSys.Setting.BBSColumnOrder;
2212                 vSortIndex := GikoSys.Setting.BBSSortIndex;
2213                 vSortOrder := GikoSys.Setting.BBSSortOrder;
2214         end else if TObject( FActiveList ) is TCategory then begin
2215                 orderList := GikoSys.Setting.CategoryColumnOrder;
2216                 vSortIndex := GikoSys.Setting.CategorySortIndex;
2217                 vSortOrder := GikoSys.Setting.CategorySortOrder;
2218         end else if TObject( FActiveList ) is TBoard then begin
2219                 orderList := GikoSys.Setting.BoardColumnOrder;
2220                 vSortIndex := GikoSys.Setting.BoardSortIndex;
2221                 vSortOrder := GikoSys.Setting.BoardSortOrder;
2222         end else
2223                 Exit;
2224
2225         id := Integer( orderList[ idx ] );
2226
2227
2228         if vSortIndex = id then
2229                 vSortOrder := not vSortOrder
2230         else begin
2231                 vSortOrder := id = 0;
2232         end;
2233
2234         TListViewUtils.ListViewSort(Sender, ListView, Column, GikoDM.ListNumberVisibleAction.Checked, vSortOrder);
2235 end;
2236
2237 procedure TGikoForm.MenuToolBarCustomDrawButton(Sender: TToolBar;
2238         Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);
2239 var
2240         ARect: TRect;
2241 begin
2242         DefaultDraw := True;
2243 // \82È\82º\82©\96³\8fð\8c\8f\82ÅExit\82µ\82Ä\82¢\82é
2244         Exit;
2245         DefaultDraw := False;
2246         if (cdsSelected in State) or (cdsHot in State) then begin
2247                 Sender.Canvas.Brush.Color := clHighlight;
2248                 Sender.Canvas.Font.Color := clHighlightText;
2249         end else begin
2250                 Sender.Canvas.Brush.Color := clBtnFace;
2251                 Sender.Canvas.Font.Color := clBtnText;
2252         end;
2253         ARect := Rect(Button.Left, Button.Top, Button.Left + Button.Width, Button.Top + Button.Height);
2254         Sender.Canvas.FillRect(ARect);
2255         DrawText(Sender.Canvas.Handle, PChar(Button.Caption), -1, ARect, DT_SINGLELINE or DT_VCENTER or DT_CENTER);
2256 end;
2257
2258 function TGikoForm.GetTreeNode(Data: TObject): TTreeNode;
2259 var
2260         Nodes: TTreeNodes;
2261         i: integer;
2262 begin
2263         Nodes := TreeView.Items;
2264
2265         for i := 0 to Nodes.Count - 1 do begin
2266                 if Nodes.Item[i].Data = Data then begin
2267                         Result := Nodes.Item[i];
2268                         Exit;
2269                 end;
2270         end;
2271         Result := nil;
2272 end;
2273
2274 procedure TGikoForm.BrowserBeforeNavigate2(Sender: TObject;
2275         const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
2276         Headers: OleVariant; var Cancel: WordBool);
2277 var
2278         sNo: string;
2279         p: TPoint;
2280 const
2281         kMenuName: string = 'menu:';
2282 begin
2283 {$IFDEF DEBUG}
2284         Writeln(URL);
2285 {$ENDIF}
2286         if Pos(kMenuName, URL) <> 0 then begin
2287                 sNo := Copy( URL, Pos( kMenuName, URL ) + Length( kMenuName ), Length( URL ) );
2288                 
2289                 if not GikoSys.IsNumeric(sNo) then Exit;
2290
2291                 Cancel := True;
2292                 GetCursorpos(p);
2293         KokoPopupMenu.PopupComponent := nil;
2294         if (Sender is TComponent) then
2295             KokoPopupMenu.PopupComponent := TComponent(Sender);
2296                 KokoPopupMenu.Tag := StrToInt(sNo);
2297                 KokoPopupMenu.Popup(p.x, p.y);
2298         end else if Pos('mailto', LowerCase(URL)) <> 0 then begin
2299                 Cancel := not GikoSys.Setting.OpenMailer;
2300         end;
2301
2302 end;
2303
2304 procedure TGikoForm.TreeViewCustomDraw(Sender: TCustomTreeView;
2305         const ARect: TRect; var DefaultDraw: Boolean);
2306 var
2307         NodeRect: TRect;
2308         i, j: Integer;
2309         IsBoardNode: Boolean;
2310         Cnt: Integer;
2311         CntText: string;
2312         TextWidth: Integer;
2313         TextRect: TRect;
2314         Board: TBoard;
2315         Category: TCategory;
2316         Bitmap: TBitmap;
2317         NodeWidth: Integer;
2318 begin
2319         DefaultDraw := True;
2320
2321         if FTreeType = gttHistory then Exit;
2322
2323         TreeView.Canvas.Font.Color := clBlue;
2324         IsBoardNode := False;
2325         for i := 0 to TreeView.Items.Count - 1 do begin
2326                 Cnt := 0;
2327                 if not TreeView.Items[i].IsVisible then
2328                         continue;
2329
2330                 if TObject(TreeView.Items[i].Data) is TCategory then begin
2331                         if TreeView.Items[i].Expanded then
2332                                 continue;
2333
2334                         IsBoardNode := False;
2335                         Category := TCategory(TreeView.Items[i].Data);
2336                         for j := 0 to Category.Count - 1 do begin
2337                                 Board := Category.Items[j];
2338                                 if Board <> nil then begin
2339                                         if Board.UnRead > 0 then begin
2340                                                 Cnt := 1;
2341                                                 Break;
2342                                         end;
2343                                 end;
2344                         end;
2345                         if Cnt <> 1 then
2346                                 continue;
2347                 end else if TObject(TreeView.Items[i].Data) is TBoard then begin
2348                         IsBoardNode := True;
2349                         Board := TBoard(TreeView.Items[i].Data);
2350
2351                         Cnt := Board.UnRead;
2352                         if Cnt <= 0 then
2353                                 continue;
2354                 end else
2355                         continue;
2356
2357                 Bitmap := TBitmap.Create;
2358                 try
2359                         Bitmap.Canvas.Font.Assign(TreeView.Canvas.Font);
2360                         Bitmap.Canvas.Font.Style := [fsBold];
2361                         NodeWidth := Bitmap.Canvas.TextWidth(TreeView.Items[i].Text);
2362                 finally
2363                         Bitmap.Free;
2364                 end;
2365
2366                 NodeRect := TreeView.Items[i].DisplayRect(True);
2367
2368                 if IsBoardNode then
2369                         CntText := '(' + IntToStr(Cnt) + ')'
2370                 else if Cnt = 1 then
2371                         CntText := '(+)';
2372
2373
2374                 TextWidth := TreeView.Canvas.TextWidth(CntText);
2375
2376                 TextRect := Rect(NodeRect.Left + NodeWidth + 8,
2377                                                                                  NodeRect.Top,
2378                                                                                  NodeRect.Left + NodeWidth + TextWidth + 8,
2379                                                                                  NodeRect.Bottom);
2380                 DrawText(TreeView.Canvas.Handle,
2381                                                  PChar(CntText),
2382                                                  -1,
2383                                                  TextRect,
2384                                                  DT_SINGLELINE or DT_VCENTER);
2385         end;
2386         TreeViewCustomDrawItem(nil, nil, [], DefaultDraw);
2387 end;
2388
2389 procedure TGikoForm.TreeViewCustomDrawItem(Sender: TCustomTreeView;
2390         Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
2391 var
2392         Board: TBoard;
2393         Category: TCategory;
2394         i: Integer;
2395 begin
2396         DefaultDraw := True;
2397
2398         if FTreeType = gttHistory then Exit;
2399
2400         TreeView.Canvas.Font.Style := [];
2401         if Node <> nil then begin
2402                 if TObject(Node.Data) is TCategory then begin
2403                         Category := TCategory(Node.Data);
2404                         for i := 0 to Category.Count - 1 do begin
2405                                 Board := Category.Items[i];
2406                                 if Board <> nil then begin
2407                                         if Board.UnRead > 0 then begin
2408                                                 TreeView.Canvas.Font.Style := [fsBold];
2409                                                 Break;
2410                                         end;
2411                                 end;
2412                         end;
2413                 end else if TObject(Node.Data) is TBoard then begin
2414                         Board := TBoard(Node.Data);
2415                         if Board.UnRead > 0 then
2416                                 TreeView.Canvas.Font.Style := [fsBold];
2417                 end;
2418         end;
2419 end;
2420
2421 procedure TGikoForm.TreeViewExpanded(Sender: TObject; Node: TTreeNode);
2422 begin
2423         TreeView.Invalidate;
2424
2425         if TObject(Node.Data) is TBBS then begin
2426                 TBBS(Node.Data).NodeExpand := True;
2427         end else if TObject(Node.Data) is TCategory then begin
2428                 TCategory(Node.Data).NodeExpand := True;
2429         end else if TObject(Node.Data) is TBoard then begin
2430                 TBoard(Node.Data).NodeExpand := True;
2431         end;
2432 end;
2433
2434 procedure TGikoForm.ListViewAllSelect;
2435 begin
2436         ListView.SetFocus;
2437         ListView.SelectAll;
2438 end;
2439 procedure TGikoForm.DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
2440 begin
2441     if csDestroying in Self.ComponentState then
2442         Exit;
2443         AddMessageList(Msg, nil, Icon);
2444 end;
2445 // *************************************************************************
2446 //! \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
2447 // *************************************************************************
2448 procedure TGikoForm.DownloadEnd(Sender: TObject; Item: TDownloadItem);
2449 var
2450         ATitle: string;
2451         s: string;
2452         boardPlugIn : TBoardPlugIn;
2453         i: Integer;
2454         Res : TResRec;
2455 begin
2456         try
2457         if csDestroying in Self.ComponentState then
2458                 Exit;
2459                 if Item.DownType = gdtBoard then
2460                         ATitle := Item.Board.Title
2461                 else
2462                         ATitle := Item.ThreadItem.Title;
2463                 if ATitle = '' then
2464                         ATitle := GikoSys.GetGikoMessage(gmUnKnown);
2465
2466                 if Item.State in [gdsComplete, gdsDiffComplete] then begin
2467                         //\90³\8fí\8fI\97¹
2468                         if Item.DownType = gdtBoard then begin
2469                                 //\94Â
2470                                 Item.SaveListFile;
2471                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureItiran), nil, gmiOK);
2472                                 if GetActiveList = Item.Board then begin
2473                                         FActiveList := nil;
2474                                         //\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é
2475                                         if (GikoSys.Setting.AutoSortThreadList) then begin
2476                                                 GikoSys.Setting.BoardSortIndex := 0;
2477                                                 GikoSys.Setting.BoardSortOrder := True;
2478                                         end;
2479                                         Sort.SetSortDate(Now());
2480                                         SetActiveList(Item.Board);
2481                                 end;
2482                                 Item.Board.Modified := True;
2483                                 Item.Board.IsThreadDatRead := True;
2484                                 PlaySound('New');
2485                                 ListView.Refresh;
2486                         end else if Item.DownType = gdtThread then begin
2487                                 //\83X\83\8c
2488                                 Item.SaveItemFile;
2489                                 Item.ThreadItem.NewArrival := True;
2490                                 //if (Item.ThreadItem.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
2491                                 if (Item.ThreadItem.ParentBoard.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
2492                                         //boardPlugIn           := Item.ThreadItem.BoardPlugIn;
2493                                         boardPlugIn             := Item.ThreadItem.ParentBoard.BoardPlugIn;
2494                                         THTMLCreate.DivideStrLine(boardPlugIn.GetDat( DWORD( Item.ThreadItem ), 1 ), @Res);
2495                                         Item.ThreadItem.Title := Res.FTitle;
2496                                         ATitle := Item.ThreadItem.Title;
2497                                 end else if ATitle = '\81i\96¼\8fÌ\95s\96¾\81j' then begin
2498                                         THTMLCreate.DivideStrLine(GikoSys.ReadThreadFile(Item.ThreadItem.GetThreadFileName, 1), @Res);
2499                                         ATitle := Res.FTitle;
2500                                 end;
2501                                 for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
2502                                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = Item.ThreadItem then begin
2503                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
2504                                                 break;
2505                                         end;
2506                                 end;
2507                                 if GikoSys.Setting.BrowserTabVisible then begin
2508                                         if GetActiveContent = Item.ThreadItem then
2509                                                 InsertBrowserTab(Item.ThreadItem)
2510                                         else if (ListView.Selected <> nil ) and ( TObject(ListView.Selected.Data) is TThreadItem ) and ( Item.ThreadItem = TThreadItem(ListView.Selected.Data)) then
2511                                                 InsertBrowserTab(Item.ThreadItem, True)
2512                                         else
2513                                                 InsertBrowserTab(Item.ThreadItem, False);
2514
2515                                 end else begin
2516                                         if (GetActiveContent = Item.ThreadItem) or (FActiveContent = nil) or(FActiveContent.Browser = BrowserNullTab.Browser) then
2517                                                                                                 InsertBrowserTab(Item.ThreadItem);
2518                                 end;
2519
2520                                                                 Application.ProcessMessages;
2521
2522                                 if Item.State = gdsComplete then begin
2523                                         PlaySound('New');
2524                                                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureSyutoku), nil, gmiOK);
2525                                                                                 //Add by Genyakun
2526                                                                                 DiffComp := True;
2527                                 end else begin
2528                                         PlaySound('NewDiff');
2529                                                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureDiff), nil, gmiOK);
2530                                                                                 //Add by Genyakun
2531                                                                                 DiffComp := True;
2532                                 end;
2533
2534                                 //\8f\84\89ñ\82 \82è\82Ì\8fê\8d\87\81\95\82P\82O\82O\82O\92´\82Í\8f\84\89ñ\8dí\8f\9c
2535                                 if (Item.ThreadItem.Round) and (Item.ThreadItem.Count > 1000) then begin
2536                     // 2ch\88È\8aO\82Í\81A1000\82ª\8dÅ\8d\82\82©\95s\96¾\82È\82Ì\82Å\81A2ch\8cÀ\92è\82É\82·\82é
2537                     if (Item.ThreadItem.ParentBoard.Is2ch) then begin
2538                                         Item.ThreadItem.Round := False;
2539                                         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);
2540                     end;
2541                                 end;
2542                                 TreeView.Refresh;
2543                                 //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
2544                                 if (ActiveList <> nil) and (ActiveList is TBoard) then begin
2545                                         TBoard(ActiveList).LogThreadCount := TBoard(ActiveList).GetLogThreadCount;
2546                                         TBoard(ActiveList).NewThreadCount := TBoard(ActiveList).GetNewThreadCount;
2547                                         TBoard(ActiveList).UserThreadCount:= TBoard(ActiveList).GetUserThreadCount;
2548                     //ListView\82Ì\83A\83C\83e\83\80\82Ì\8cÂ\90\94\82à\8dX\90V
2549                                         case GikoForm.ViewType of
2550                                                 gvtAll: ListView.Items.Count := TBoard(ActiveList).Count;
2551                                                 gvtLog: ListView.Items.Count := TBoard(ActiveList).LogThreadCount;
2552                                                 gvtNew: ListView.Items.Count := TBoard(ActiveList).NewThreadCount;
2553                                                 gvtArch: ListView.Items.Count := TBoard(ActiveList).ArchiveThreadCount;
2554                                                 gvtLive: ListView.Items.Count := TBoard(ActiveList).LiveThreadCount;
2555                                                 gvtUser: ListView.Items.Count := TBoard(ActiveList).UserThreadCount;
2556                                         end;
2557                                 end;
2558                                 RefreshListView(Item.ThreadItem);
2559                         end;
2560
2561                 end else if Item.State = gdsNotModify then begin
2562                         //\95Ï\8dX\83i\83V
2563 {                       if (Item.DownType = gdtThread) and (AddHistory(Item.ThreadItem)) then begin
2564                                 //SetContent(Item.ThreadItem);
2565                                 InsertBrowserTab(Item.ThreadItem);
2566                         end;}
2567                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmNotMod), nil, gmiSAD);
2568                         PlaySound('NoChange');
2569                         Screen.Cursor := crDefault;
2570                 end else if Item.State = gdsAbort then begin
2571                         //\92\86\92f
2572                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiOK);
2573                 end else if Item.State = gdsError then begin
2574                         //\83G\83\89\81[
2575                         s := Item.ErrText;
2576                         if s <> '' then
2577                                 s := ':' + s;
2578                         AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmError) + ' (' + IntToStr(Item.ResponseCode) + ')' + s, nil, gmiNG);
2579 //                      if Item.ResponseCode = 302 then
2580 //                              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);
2581                         PlaySound('Error');
2582                 end;
2583         finally
2584                 Item.Free;
2585                 Dec(FWorkCount);
2586                 if FWorkCount < 0 then FWorkCount := 0;
2587                 if FWorkCount = 0 then begin
2588                         try
2589                                 Animate.Active := False;
2590                         finally
2591                                 Screen.Cursor := crDefault;
2592                         end;
2593                 end;
2594
2595         end;
2596 end;
2597
2598 procedure TGikoForm.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
2599 begin
2600 //      SetProgressValue(Number, 0, AWorkCountMax);
2601 //      ProgressBar.Visible := True;
2602     if csDestroying in Self.ComponentState then
2603         Exit;
2604
2605         ProgressBar.Position := 0;
2606         ProgressBar.Max := AWorkCountMax;
2607         FDownloadTitle := AWorkTitle;
2608         StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82·';
2609         FDownloadMax := AWorkCountMax;
2610 end;
2611
2612 procedure TGikoForm.WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
2613 begin
2614     if csDestroying in Self.ComponentState then
2615         Exit;
2616         ProgressBar.Position := 0;
2617         if FDownloadMax <> 0 then
2618                 StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ª\8a®\97¹\82µ\82Ü\82µ\82½';
2619 end;
2620
2621 procedure TGikoForm.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
2622 begin
2623     if csDestroying in Self.ComponentState then
2624         Exit;
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
7846 end.