OSDN Git Service

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