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