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