OSDN Git Service

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