OSDN Git Service

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