OSDN Git Service

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