OSDN Git Service

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