OSDN Git Service

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