OSDN Git Service

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