OSDN Git Service

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