OSDN Git Service

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