OSDN Git Service

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