OSDN Git Service

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