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