OSDN Git Service

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