OSDN Git Service

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