OSDN Git Service

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