OSDN Git Service

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