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