OSDN Git Service

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