OSDN Git Service

Folder.idxファイル読み込み時にdatファイルをチェックしないオプションを追加
[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     if Thread.Thread.IsLogFile then  begin
2795         if not FileExists(Thread.Thread.GetThreadFileName) then begin
2796             Thread.Thread.DeleteLogFile;
2797         end;
2798     end;
2799
2800         ThreadIsLog := Thread.Thread.IsLogFile;
2801         ThreadItem := Thread.Thread;
2802         ThreadNewArraical :=  Thread.Thread.NewArrival;
2803         //ThreadUnRead := Thread.Thread.UnRead;
2804         BBSID := ThreadItem.ParentBoard.BBSID;
2805         FileName := ThreadItem.FileName;
2806
2807         if GetCapture = ListView.Handle then
2808                 ReleaseCapture;
2809
2810         Screen.Cursor := crHourGlass;
2811
2812
2813         try
2814                 if(FActiveContent <> nil) and (FActiveContent <> Thread) then begin
2815                         if (FActiveContent.Browser <> BrowserNullTab.Browser) then
2816                                 ShowWindow(FActiveContent.Browser.Handle, SW_HIDE);
2817                 end;
2818                 ShowWindow(Thread.Browser.Handle, SW_SHOW);
2819                 if (not Assigned(Thread.Browser.Document)) then begin
2820                         Thread.Browser.Navigate('about:blank');
2821                 end;
2822                 while (Thread.Browser.ReadyState <> READYSTATE_COMPLETE) and
2823                                 (Thread.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
2824                         Application.ProcessMessages;
2825                         if idx <> BrowserTab.TabIndex then begin
2826                                 Exit;
2827                         end;
2828                 end;
2829
2830                 if (Thread <> nil) and (ThreadItem <>nil) then begin
2831                         BrowserBoardNameLabel.Caption := ThreadPTitle;
2832                         ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
2833                         BrowserNameLabel.Caption := ThreadTitle;
2834                         ItemImage.Picture := nil;
2835                         if ThreadIsLog then
2836                                 if ThreadNewArraical then
2837                                         ItemImageList.GetBitmap(2, ItemImage.Picture.Bitmap)
2838                                 else
2839                                         ItemImageList.GetBitmap(0, ItemImage.Picture.Bitmap)
2840                         else
2841                                 ItemImageList.GetBitmap(1, ItemImage.Picture.Bitmap);
2842
2843                         ItemImage.Left := BrowserBoardNameLabel.Left + BrowserBoardNameLabel.Width + 8;
2844                         BrowserNameLabel.Left := ItemImage.Left + 20;
2845
2846                 end;
2847                 //ActiveContent\81@\82Ì\8dX\90V
2848                 FActiveContent := Thread;
2849
2850                 if not ThreadIsLog then begin
2851                         Self.Caption := GikoDataModule.CAPTION_NAME ;
2852                         //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\8fÁ\8b\8e
2853                         StatusBar.Panels[THREADSIZE_PANEL].Text := '';
2854                         try
2855                                 Thread.Browser.BringToFront;
2856                                 s := '<HTML><BODY><CENTER>\82±\82Ì\83X\83\8c\83b\83h\82Í\8eæ\93¾\82µ\82Ä\82¢\82Ü\82¹\82ñ</CENTER></BODY></HTML>';
2857                                 doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
2858                                 doc.open;
2859                                 doc.charset := 'Shift_JIS';
2860                                 doc.Write(s);
2861                                 doc.Close;
2862                         finally
2863                                 
2864                         end;
2865                 end else begin
2866                         Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + ThreadTitle + ']';
2867                         //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
2868                         StatusBar.Panels[THREADSIZE_PANEL].Text := Format('%6.2f kB', [ThreadItem.Size / 1024]);
2869                         StatusBar.Panels[THREADSIZE_PANEL].Width :=
2870                                 Max(StatusBar.Canvas.TextWidth(StatusBar.Panels[THREADSIZE_PANEL].Text), 70);
2871                         //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«
2872                         //\90V\8bK\82ÉThread\82ð\8aJ\82¢\82½\82Æ\82«\82É\90^\82É\82È\82Á\82Ä\82¢\82é\81B
2873                         if Thread.Repaint then begin
2874                                 Thread.Repaint := false;
2875
2876                                 Thread.Browser.OnStatusTextChange := nil;
2877                                 LockWindowUpdate(Thread.Browser.ParentWindow);
2878                                 HTMLCreater.CreateHTML2(Thread.Browser, ThreadItem, sTitle);
2879                                 Thread.Browser.OnStatusTextChange := BrowserStatusTextChange;
2880                                 PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( Thread.Browser ), 0 );
2881                         end;
2882                 end;
2883
2884                 RefreshListView(ThreadItem);
2885         finally
2886                 Screen.Cursor := crDefault;
2887         end;
2888 end;
2889
2890 function TGikoForm.GetActiveContent(popup :Boolean = false): TThreadItem;
2891 begin
2892         try
2893                 if FActiveContent <> nil then begin
2894                         Result := FActiveContent.Thread;
2895             if (popup) and
2896                 (FResPopupBrowser <> nil) and (FResPopupBrowser.CurrentBrowser.Visible = True) then
2897                 if (FResPopupBrowser.CurrentBrowser.Thread <> nil) then begin
2898                     Result := FResPopupBrowser.CurrentBrowser.Thread;
2899                 end;
2900                 end else
2901                         Result := nil;
2902         except
2903                 Result := nil;
2904         end;
2905
2906 end;
2907
2908 procedure TGikoForm.SetActiveList(Obj: TObject);
2909 var
2910         idx     : Integer;
2911 begin
2912 //      if FActiveList <> Obj then begin
2913                 FActiveList := Obj;
2914         try
2915                         if ListView.Selected <> nil then
2916                                 idx := ListView.Selected.Index
2917                         else
2918                                 idx := -1;
2919         except
2920                 idx := -1;
2921         end;
2922                 ListView.Items.Count := 0;
2923                 ListView.Items.Clear;
2924                 ListView.Selected := nil;
2925 //      ListView.Columns.Clear;
2926                 if (FActiveContent <> nil) and (FActiveContent.Thread <> nil)
2927                         and (FActiveContent.Thread.IsLogFile) then begin
2928                         try
2929                                 Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + FActiveContent.Thread.Title + ']'
2930                         except
2931                                 on E: Exception do begin
2932                                         //\83X\83\8c\88ê\97\97DL\8cã\82È\82Ç\82ÉFActiveContent\82Ì\8e\9d\82ÂThread\82ª
2933                                         //\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é
2934                                         ReleaseBrowser(FActiveContent);
2935                                         FActiveContent.Thread := nil;
2936                                         Self.Caption := GikoDataModule.CAPTION_NAME;
2937                                 end;
2938                         end;
2939                 end else
2940                         Self.Caption := GikoDataModule.CAPTION_NAME;
2941                 //Application.Title := CAPTION_NAME;
2942
2943 //              ActiveListColumnSave;
2944
2945                 Screen.Cursor := crHourGlass;
2946                 try
2947                         if Obj is TBBS then begin
2948                                 TListViewUtils.SetCategoryListItem(TBBS(obj), ListView, GikoDM.ListNumberVisibleAction.Checked);
2949                         end else if Obj is TCategory then begin
2950                                 TListViewUtils.SetBoardListItem(TCategory(Obj), ListView, GikoDM.ListNumberVisibleAction.Checked);
2951                         end else if Obj is TBoard then begin
2952                                 TListViewUtils.SetThreadListItem(TBoard(Obj), ListView,  GikoDM.ListNumberVisibleAction.Checked);
2953                         end;
2954                 finally
2955                         Screen.Cursor := crDefault;
2956                 end;
2957
2958                 if idx >= 0  then begin
2959                         if idx >= ListView.Items.Count then
2960                                 idx := ListView.Items.Count - 1;
2961                         ListView.ItemIndex := idx;
2962                         ListView.ItemFocused := ListView.Items.Item[ idx ];
2963                 end;
2964 //      end;
2965 end;
2966
2967
2968 //\81\9a\81\9a\83q\83\8d\83\86\83L\83\81\83\82
2969 //\82»\82Ì\82¤\82¿interface\82ð\8eg\82¤
2970 function TGikoForm.GetActiveList: TObject;
2971 begin
2972         Result := FActiveList;
2973 end;
2974
2975 procedure TGikoForm.SetListViewType(AViewType: TGikoViewType);
2976 begin
2977         SetListViewType(AViewType, '', False);
2978 end;
2979
2980 procedure TGikoForm.SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean);
2981 var
2982         Board: TBoard;
2983         i: Integer;
2984 begin
2985         for i := Length( BBSs ) - 1 downto 0 do begin
2986                 BBSs[i].SelectText := SelectText;
2987                 BBSs[i].KubetsuChk := KubetsuChk;
2988         end;
2989         ViewType := AViewType;
2990         if ActiveList is TBoard then begin
2991                 Board := TBoard(ActiveList);
2992                 case ViewType of
2993                         //gvtAll: ListView.Items.Count := Board.Count;
2994                         gvtLog: Board.LogThreadCount := Board.GetLogThreadCount;
2995                         gvtNew: Board.NewThreadCount := Board.GetNewThreadCount;
2996                         gvtArch: Board.ArchiveThreadCount := Board.GetArchiveThreadCount;
2997                         gvtLive: Board.LiveThreadCount := Board.GetLiveThreadCount;
2998                         gvtUser: Board.UserThreadCount:= Board.GetUserThreadCount;
2999
3000                 end;
3001
3002                 SetActiveList(Board);
3003         end;
3004 end;
3005
3006 procedure TGikoForm.ListViewCustomDraw(Sender: TCustomListView;
3007         const ARect: TRect; var DefaultDraw: Boolean);
3008 var
3009         s: string;
3010         p: TPoint;
3011 //      Board: TBoard;
3012 begin
3013         if ListView.Items.Count = 0 then begin
3014                 DefaultDraw := true;
3015                 ListView.Canvas.Brush.Color := ListView.Color;
3016                 ListView.Canvas.FillRect(ARect);
3017
3018                 case ViewType of
3019                         gvtAll: begin
3020                                 ListView.Canvas.Font.Color := clWindowText;
3021                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3022                         end;
3023                         gvtLog: begin
3024                                 ListView.Canvas.Font.Color := clBlue;
3025                                 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';
3026                         end;
3027                         gvtNew: begin
3028                                 ListView.Canvas.Font.Color := clGreen;
3029                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90V\92\85\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3030                         end;
3031                         gvtArch: begin
3032                                 ListView.Canvas.Font.Color := clFuchsia;
3033                                 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';
3034                         end;
3035                         gvtLive: begin
3036                                 ListView.Canvas.Font.Color := clMaroon;
3037                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90\91\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
3038                         end;
3039                         gvtUser: begin
3040                                 ListView.Canvas.Font.Color := clNavy;
3041                                 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';
3042                                 if GetActiveList is TBoard then
3043                                         s := Format(s, [TBoard(GetActiveList).ParentCategory.ParenTBBS.SelectText]);
3044 //                                      SelectText]);
3045                         end;
3046                         else begin
3047                                 s := '';
3048                         end;
3049                 end;
3050
3051                 p := Point((ListView.ClientWidth div 2) - (ListView.Canvas.TextWidth(s) div 2),
3052                                                          (ListView.ClientHeight div 2) - (ListView.Canvas.TextHeight(s) div 2));
3053                 ListView.Canvas.TextOut(p.X, p.Y, s);
3054         end else begin
3055                 DefaultDraw := True;
3056         end;
3057 end;
3058
3059 procedure TGikoForm.DownloadList(Board: TBoard; ForceDownload: Boolean = False);
3060 var
3061         Item: TDownloadItem;
3062 begin
3063         if not Board.IsThreadDatRead then
3064                 GikoSys.ReadSubjectFile(Board);
3065         Item := TDownloadItem.Create;
3066         try
3067                 Item.Board := Board;
3068                 Item.DownType := gdtBoard;
3069                 Item.ForceDownload := ForceDownload;
3070                 FControlThread.AddItem(Item);
3071                 if FWorkCount = 0 then begin
3072                         try
3073                                 Animate.Active := True;
3074                         except
3075                         end;
3076                         Screen.Cursor := crAppStart;
3077                 end;
3078                 Inc(FWorkCount);
3079         finally
3080                 //Item.Free;
3081         end;
3082 end;
3083
3084 procedure TGikoForm.DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
3085 var
3086         Item: TDownloadItem;
3087 begin
3088         Item := TDownloadItem.Create;
3089         try
3090                 Item.ThreadItem := ThreadItem;
3091                 Item.DownType := gdtThread;
3092                 Item.ForceDownload := ForceDownload;
3093                 FControlThread.AddItem(Item);
3094                 if FWorkCount = 0 then begin
3095                         try
3096                                 Animate.Active := True;
3097                         except
3098                         end;
3099                         Screen.Cursor := crAppStart;
3100                 end;
3101                 Inc(FWorkCount);
3102         finally
3103 //              Item.Free;
3104         end;
3105 end;
3106
3107 procedure TGikoForm.PlaySound(SoundEventName: string);
3108 var
3109         FileName: string;
3110 begin
3111         if not GikoSys.Setting.Mute then begin
3112                 FileName := GikoSys.Setting.FindSoundFileName(SoundEventName);
3113                 if FileExists(FileName) then begin
3114                         if not sndPlaySound(PChar(FileName), SND_ASYNC or SND_NOSTOP) then begin
3115                                 sndPlaySound(nil, SND_SYNC);
3116                                 Application.ProcessMessages;
3117                                 Sleep(10);
3118                                 sndPlaySound(PChar(FileName), SND_ASYNC);
3119                         end;
3120                 end;
3121         end;
3122 end;
3123
3124 //\97\9a\97ð\82©\82ç\8dí\8f\9c
3125 procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );
3126 begin
3127     FHistoryList.DeleteHistory( threadItem, TreeView, TreeType );
3128 end;
3129
3130 procedure TGikoForm.ShowBBSTreeOld(
3131         inBBS : TBBS
3132 );
3133 var
3134         i, b            : Integer;
3135         item            : TMenuItem;
3136 begin
3137         try
3138                 FavoriteTreeView.Visible := False;
3139                 FavoriteToolBar.Hide;
3140                 TreeView.Visible := True;
3141
3142                 b := CabinetSelectPopupMenu.Items.Count - 1;
3143                 for i := 0 to b do begin
3144                         item := CabinetSelectPopupMenu.Items[ i ];
3145                         if item is TBBSMenuItem then begin
3146                                 if TBBSMenuItem( item ).Data = inBBS then begin
3147                                         item.Checked := True;
3148                                         // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
3149                                         CabinetMenu.Items[ i ].Checked := True;
3150                                         GikoSys.Setting.CabinetIndex := i;
3151                                         Continue;
3152                                 end;
3153                         end;
3154                         item.Checked := False;
3155                         // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
3156                         CabinetMenu.Items[ i ].Checked := False;
3157                 end;
3158                 CabinetSelectToolButton.Caption := inBBS.Title;
3159
3160                 GikoDM.CabinetHistoryAction.Checked := False;
3161                 GikoDM.CabinetFavoriteAction.Checked := False;
3162
3163                 if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS) then begin
3164                         FTreeType := gtt2ch;
3165                         HistoryToolBar.Hide;
3166                         FActiveBBS := inBBS;
3167                         TListViewUtils.SetBoardTreeNode(inBBS, TreeView);
3168                         TreeView.Items.GetFirstNode.Expanded := True;                           //?c???[?g?b?v???????J??
3169                         //?c???[??g?b?v?????I????
3170                         if GetActiveList = nil then
3171                                 TreeView.Selected := TreeView.Items[0]
3172                         else begin
3173                                 for i := 0 to TreeView.Items.Count - 1 do begin
3174                                         if TreeView.Items[i].Data = GetActiveList then begin
3175                                                 TreeView.Selected := TreeView.Items[i];
3176                                                 Exit;
3177                                         end;
3178                                 end;
3179                                 TreeView.Selected := TreeView.Items[0]
3180                         end;
3181                 end;
3182         except
3183         end;
3184
3185 end;
3186
3187 procedure TGikoForm.ShowBBSTree(
3188         inBBS : TBBS
3189 );
3190 var
3191         i, b            : Integer;
3192         item            : TMenuItem;
3193 begin
3194
3195         try
3196                 FavoriteTreeView.Visible := False;
3197                 FavoriteToolBar.Hide;
3198                 TreeView.Visible := True;
3199
3200                 b := CabinetSelectPopupMenu.Items.Count - 1;
3201                 for i := 0 to b do begin
3202                         item := CabinetSelectPopupMenu.Items[ i ];
3203                         if item is TBBSMenuItem then begin
3204                                 if TBBSMenuItem( item ).Data = inBBS then begin
3205                                         item.Checked := True;
3206                                         // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3207                                         CabinetMenu.Items[ i ].Checked := True;
3208                                         GikoSys.Setting.CabinetIndex := i;
3209                                         Continue;
3210                                 end;
3211                         end;
3212                         item.Checked := False;
3213                         // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3214                         CabinetMenu.Items[ i ].Checked := False;
3215                 end;
3216                 CabinetSelectToolButton.Caption := inBBS.Title;
3217
3218                 GikoDM.CabinetHistoryAction.Checked := False;
3219                 GikoDM.CabinetFavoriteAction.Checked := False;
3220
3221                 if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS)
3222                         or (not (CabinetPanel.Visible)) then begin
3223                         FTreeType := gtt2ch;
3224                         HistoryToolBar.Hide;
3225                         FActiveBBS := inBBS;
3226                         TListViewUtils.SetBoardTreeNode(inBBS, TreeView);
3227                         TreeView.Items.GetFirstNode.Expanded := True;                           //\83c\83\8a\81[\83g\83b\83v\8d\80\96Ú\82¾\82¯\82ð\8aJ\82­
3228                         //\83c\83\8a\81[\82Ì\83g\83b\83v\8d\80\96Ú\82ð\91I\91ð\82·\82é
3229                         if GetActiveList = nil then begin
3230                                 try
3231                                         TreeClick( TreeView.Items[0] );
3232                                 except
3233                                 end;
3234                         end else begin
3235                                 for i := 0 to TreeView.Items.Count - 1 do begin
3236                                         if TreeView.Items[i].Data = GetActiveList then begin
3237                                                 TreeClick( TreeView.Items[i] );
3238                                                 Exit;
3239                                         end;
3240                                 end;
3241                                 TreeClick( TreeView.Items[0] );
3242                         end;
3243                 end;
3244         except
3245         end;
3246
3247 end;
3248
3249 procedure TGikoForm.ShowHistoryTree;
3250 var
3251         i, b : Integer;
3252         item : TMenuItem;
3253 begin
3254         if CabinetPanel.Visible then begin
3255                 if FTreeType = gttHistory then begin
3256                         CabinetVisible( False );
3257                         GikoDM.CabinetHistoryAction.Checked := False;
3258                 end else begin
3259                         GikoDM.CabinetHistoryAction.Checked := True;
3260                 end;
3261         end else begin
3262                 CabinetVisible( True );
3263                 GikoDM.CabinetHistoryAction.Checked := True;
3264         end;
3265
3266         // BBS...BBS, History, Favorite
3267         GikoSys.Setting.CabinetIndex := CabinetSelectPopupMenu.Items.Count - 2;
3268
3269         FavoriteTreeView.Visible := False;
3270         TreeView.Visible := True;
3271
3272         GikoDM.CabinetBBSAction.Checked := False;
3273         GikoDM.CabinetFavoriteAction.Checked := False;
3274
3275         if FTreeType <> gttHistory then begin
3276                 b := CabinetSelectPopupMenu.Items.Count - 1;
3277                 for i := 0 to b do begin
3278                         item := CabinetSelectPopupMenu.Items[ i ];
3279                         if item is TBBSMenuItem then begin
3280                                 item.Checked := False;
3281                                 // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3282                                 CabinetMenu.Items[ i ].Checked := False;
3283                         end;
3284                 end;
3285
3286                 FTreeType := gttHistory;
3287                 HistoryToolBar.Show;
3288                 FavoriteToolBar.Hide;
3289         FHistoryList.SetTreeNode( TreeView );
3290                 CabinetSelectToolButton.Caption := '\97\9a\97ð\83\8a\83X\83g';
3291         end;
3292 end;
3293
3294 procedure TGikoForm.SelectTreeNode(Item: TObject; CallEvent: Boolean);
3295 var
3296         ChangeEvent: TTVChangedEvent;
3297         ChangingEvent: TTVChangingEvent;
3298         i: Integer;
3299         bbs : TBBS;
3300 begin
3301         if Item is TCategory then
3302                 bbs := TCategory( Item ).ParenTBBS
3303         else if Item is TBoard then
3304                 bbs := TBoard( Item ).ParentCategory.ParenTBBS
3305         else
3306                 bbs := nil;
3307
3308         if (FTreeType = gtt2ch) and (FActiveBBS = bbs) then begin
3309                 if Item <> FActiveList then begin
3310                         ChangeEvent := nil;
3311                         ChangingEvent := nil;
3312
3313                         if not CallEvent then begin
3314                                 ChangeEvent := TreeView.OnChange;
3315                                 ChangingEvent := TreeView.OnChanging;
3316                         end;
3317                         try
3318                                 if not CallEvent then begin
3319                                         TreeView.OnChange := nil;
3320                                         TreeView.OnChanging := nil;
3321                                 end;
3322                                 //Application.ProcessMessages;
3323                                 for i := 0 to TreeView.Items.Count - 1 do begin
3324                                         if TreeView.Items[i].Data = Item then begin
3325                                                 TreeView.Items[i].Selected := True;
3326                                                 if CallEvent then
3327                                                         TreeClick(TreeView.Items[i]);
3328                                                 Break;
3329                                         end;
3330                                 end;
3331                                 //Application.ProcessMessages;
3332                         finally
3333                                 if not CallEvent then begin
3334                                         TreeView.OnChange := ChangeEvent;
3335                                         TreeView.OnChanging := ChangingEvent;
3336                                 end;
3337                         end;
3338                 end;
3339         end else begin
3340                 if Item <> FActiveList then begin
3341                         ActiveListColumnSave;
3342                         if (Item is TBBS) or (Item is TCategory) then begin
3343                                 ListView.Columns.Clear;
3344                                 SetActiveList( Item );
3345                         end else if Item is TBoard then begin
3346                                 if not TBoard( Item ).IsThreadDatRead then begin
3347                                         Screen.Cursor := crHourGlass;
3348                                         try
3349                                                 if not TBoard( Item ).IsThreadDatRead then
3350                                                         GikoSys.ReadSubjectFile(TBoard( Item ));
3351                                         finally
3352                                                 Screen.Cursor := crDefault;
3353                                         end;
3354                                 end;
3355                                 Sort.SetSortDate(Now());
3356                                 SetActiveList( Item );
3357                         end;
3358                 end;
3359         end;
3360
3361         if Item is TBoard then begin // not TCategory
3362                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3363                         if GikoSys.Setting.ListWidthState = glsMax then begin
3364                                 GikoDM.BrowserMinAction.Execute;
3365                                 if GikoForm.Visible then
3366                                         ListView.SetFocus;
3367                         end;
3368                 end else begin
3369                         if GikoSys.Setting.ListHeightState = glsMax then begin
3370                                 GikoDM.BrowserMinAction.Execute;
3371                                 if GikoForm.Visible then
3372                                         ListView.SetFocus;
3373                         end;
3374                 end;
3375         end;
3376 end;
3377
3378 procedure TGikoForm.ListViewMouseDown(Sender: TObject;
3379         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
3380 var
3381         listItem                : TListItem;
3382         threadItem      : TThreadItem;
3383         pos                                     : TPoint;
3384 //      t: Cardinal;
3385 begin
3386         case Button of
3387         mbMiddle:
3388                 begin
3389                         if not (GetActiveList is TBoard) then Exit;
3390                         listItem := ListView.GetItemAt( X, Y );
3391                         if listItem = nil then Exit;
3392                         if not (TObject(listItem.Data) is TThreadItem) then Exit;
3393
3394                         threadItem := TThreadItem(ListItem.Data);
3395                         InsertBrowserTab(threadItem, False);
3396                         if threadItem.IsLogFile then
3397                                 ListView.UpdateItems(listItem.Index, listItem.Index);
3398                 end;
3399         mbLeft:
3400                 begin
3401                         //\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Å
3402                         if (ssDouble in Shift) then
3403                                 ListDoubleClick(Shift)
3404                         else
3405                                 ListClick;
3406                 end;
3407         mbRight:
3408                 begin
3409                         pos.X := X;
3410                         pos.Y := Y;
3411                         Windows.ClientToScreen( ListView.Handle, pos );
3412                         ListPopupMenu.Popup( pos.X, pos.Y );
3413                 end;
3414         end;
3415
3416 end;
3417
3418 procedure TGikoForm.ListClick;
3419 var
3420         ListItem: TListItem;
3421         ThreadItem: TThreadItem;
3422 begin
3423         if ListView.SelCount <> 1 then Exit;
3424         ListItem := ListView.Selected;
3425         if ListItem = nil then Exit;
3426         if not (TObject(ListItem.Data) is TThreadItem) then Exit;
3427
3428         ThreadItem := TThreadItem(ListItem.Data);
3429         if ThreadItem.IsLogFile then begin
3430                 InsertBrowserTab(ThreadItem);
3431                 ListView.UpdateItems(ListItem.Index, ListItem.Index);
3432         end else begin
3433                 InsertBrowserTab(ThreadItem);
3434         end;
3435
3436         if GikoSys.Setting.BrowserAutoMaximize = gbmClick then begin
3437                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3438                         if GikoSys.Setting.ListWidthState = glsMin then begin
3439                                 GikoDM.BrowserMaxAndFocusAction.Execute;
3440                         end;
3441                 end else begin
3442                         if GikoSys.Setting.ListHeightState = glsMin then begin
3443                                 GikoDM.BrowserMaxAndFocusAction.Execute;
3444                         end;
3445                 end;
3446         end;
3447 end;
3448
3449 procedure TGikoForm.ListDoubleClick(Shift: TShiftState);
3450 var
3451         ThreadItem: TThreadItem;
3452         shiftDown: Boolean;
3453 begin
3454         shiftDown := (ssShift in Shift);
3455
3456         if ListView.Selected = nil then Exit;
3457
3458         if TObject(ListView.Selected.Data) is TCategory then begin
3459                 SelectTreeNode(ListView.Selected.Data, True);
3460         end else if TObject(ListView.Selected.Data) is TBoard then begin
3461                 SelectTreeNode(ListView.Selected.Data, True)
3462         end else if TObject(ListView.Selected.Data) is TThreadItem then begin
3463                 Application.ProcessMessages;
3464                 ThreadItem := TThreadItem(ListView.Selected.Data);
3465                 DownloadContent(ThreadItem, shiftDown);
3466
3467                 if GikoSys.Setting.BrowserAutoMaximize = gbmDoubleClick then begin
3468                         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3469                                 if GikoSys.Setting.ListWidthState = glsMin then begin
3470                                         GikoDM.BrowserMaxAction.Execute;
3471                                         GikoDM.SetFocusForBrowserAction.Execute;
3472                                 end;
3473                         end else begin
3474                                 if GikoSys.Setting.ListHeightState = glsMin then begin
3475                                         GikoDM.BrowserMaxAction.Execute;
3476                                         GikoDM.SetFocusForBrowserAction.Execute;
3477                                 end;
3478                         end;
3479                 end;
3480         end;
3481 end;
3482
3483 procedure TGikoForm.BrowserMovement(const AName: string);
3484 begin
3485         // Access Violation \82ª\8bN\82«\82é\8e\96\82ª\82 \82é\82Ì\82Å\8d¡\8cã\97v\83`\83F\83b\83N
3486         if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
3487                 and (FActiveContent <> nil) then begin
3488                 FActiveContent.Move(AName);
3489         end;
3490 end;
3491 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
3492 procedure TGikoForm.BrowserMovement(scroll: Integer);
3493 begin
3494         if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
3495                 and (FActiveContent <> nil) then begin
3496                 FActiveContent.Move(scroll);
3497         end;
3498 end;
3499 procedure TGikoForm.TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
3500 begin
3501         if TObject(Node.Data) is TBBS then begin
3502                 TBBS(Node.Data).NodeExpand := False;
3503         end else if TObject(Node.Data) is TCategory then begin
3504                 TCategory(Node.Data).NodeExpand := False;
3505         end else if TObject(Node.Data) is TBoard then begin
3506                 TBoard(Node.Data).NodeExpand := False;
3507         end;
3508         if (TreeView.Selected <> nil) and (TreeView.Selected = Node) then begin
3509         TreeClick(TreeView.Selected);
3510         end;
3511 end;
3512
3513 procedure TGikoForm.MessageListViewResize(Sender: TObject);
3514 begin
3515 //      MessageListView.Column[0].Width := MessageListView.ClientWidth - 16;
3516 end;
3517 procedure       TGikoForm.CabinetVisible( isVisible : Boolean );
3518 begin
3519         TreeSplitter.Visible := isVisible;
3520         CabinetPanel.Visible := isVisible;
3521         GikoDM.CabinetVisibleAction.Checked := isVisible;
3522 end;
3523
3524 procedure TGikoForm.SelectListItem(List: TList);
3525 var
3526         TmpListItem: TListItem;
3527 begin
3528         List.Clear;
3529         List.Capacity := 0;
3530         TmpListItem := ListView.Selected;
3531         while TmpListItem <> nil do begin
3532                 List.Add(TmpListItem.Data);
3533                 TmpListItem := ListView.GetNextItem(TmpListItem, sdAll, [isSelected]);
3534         end;
3535
3536 end;
3537
3538 procedure TGikoForm.FormResize(Sender: TObject);
3539 begin
3540
3541         MessageListView.Column[0].Width := MessageListView.ClientWidth - 32;
3542         MainCoolBar.Width := TopPanel.Width - TopRightPanel.Width;
3543
3544         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3545                 if GikoSys.Setting.ListWidthState = glsMin then begin
3546                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
3547                         ViewPanel.Width := ThreadMainPanel.Width - 80;
3548                 end;
3549         end else begin
3550                 if GikoSys.Setting.ListHeightState = glsMin then begin
3551                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
3552                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
3553                 end;
3554         end;
3555
3556         FIsIgnoreResize := rtResizing;
3557         PostMessage( Handle, USER_RESIZED, 0, 0 );
3558
3559
3560 end;
3561
3562 procedure TGikoForm.DeleteTab(BrowserRecord: TBrowserRecord);
3563 var
3564         i: Integer;
3565 begin
3566         FTabHintIndex := -1;
3567         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3568                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]) = BrowserRecord then begin
3569             DeleteTab(i, BrowserTab.TabIndex);
3570                         Break;
3571                 end;
3572         end;
3573 end;
3574 procedure TGikoForm.DeleteTab(ThreadItem: TThreadItem);
3575 var
3576         i: Integer;
3577 begin
3578         FTabHintIndex := -1;
3579         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3580                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
3581             DeleteTab(i, BrowserTab.TabIndex);
3582                         Break;
3583                 end;
3584         end;
3585 end;
3586 procedure TGikoForm.DeleteTab(index, selectIndex: Integer);
3587 var
3588     doc: Variant;
3589     j: Integer;
3590 begin
3591     try
3592         if TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser <> nil then begin
3593             doc := TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser.Document;
3594             TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.ScrollTop := doc.Body.ScrollTop;
3595         end;
3596     except
3597         TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.ScrollTop := 0;
3598     end;
3599     if(FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[index])) then
3600         FActiveContent := nil;
3601     if TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser <> nil then begin
3602         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser);
3603         if j <> -1 then
3604             FBrowsers.Move(j, BROWSER_COUNT - 1);
3605     end;
3606     BrowserTab.Tabs.BeginUpdate;
3607     try
3608         GikoSys.Setting.LastCloseTabURL :=
3609             TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.URL;
3610         TBrowserRecord(BrowserTab.Tabs.Objects[index]).Free;
3611         if ( BrowserTab.Tabs.Count - 1 = index ) and
3612             ( BrowserTab.TabRect(index).Left
3613                 <= BrowserTab.DisplayRect.Left ) then begin
3614             BrowserTab.ScrollTabs(-1);
3615         end;
3616         BrowserTab.Tabs.Delete(index);
3617         if selectIndex > index then begin
3618             BrowserTab.TabIndex := selectIndex - 1;
3619         end else begin
3620             if BrowserTab.Tabs.Count -1 >= selectIndex then
3621                 BrowserTab.TabIndex := selectIndex
3622             else
3623                 BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
3624         end;
3625     finally
3626         BrowserTab.Tabs.EndUpdate;
3627     end;
3628     if BrowserTab.Tabs.Count = 0 then begin
3629         BrowserNullTab.Thread := nil;
3630     end;
3631     if(BrowserTab.TabIndex <> -1) and
3632         ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
3633         // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
3634         ReleaseOldestBrowser;
3635
3636         TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
3637              :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3638         TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
3639         FBrowsers.Move(BROWSER_COUNT - 1, 0);
3640     end;
3641
3642     if( FActiveContent = nil) then
3643         BrowserTab.OnChange(nil);
3644 end;
3645 function TGikoForm.Hook(var Message: TMessage): Boolean;
3646 begin
3647         //\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Ì
3648         //\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ð
3649         Result := False;
3650         case Message.Msg of
3651         CM_APPKEYDOWN:
3652                 Result := True;         //\83V\83\87\81[\83g\83J\83b\83g\83L\81[\96³\8cø
3653         CM_APPSYSCOMMAND:
3654                 Result := True;  // \83A\83N\83Z\83\89\83\8c\81[\83^\82ð\96³\8cø\82É\82·\82é
3655         end;
3656 end;
3657
3658 procedure TGikoForm.ListPopupMenuPopup(Sender: TObject);
3659 var
3660     bBoard, bCategory : Boolean;
3661 begin
3662     bBoard := (GetActiveList is TBoard);
3663     bCategory := (GetActiveList is TCategory);
3664         ItemRoundPMenu.Visible := bBoard;
3665         ItemReservPMenu.Visible := bBoard;
3666         LPMSep01.Visible := bBoard;
3667         ListRoundPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
3668         ListReservPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
3669         LPMSep02.Visible := bCategory or bBoard;
3670         KidokuPMenu.Visible := bBoard;
3671         MidokuPMenu.Visible := bBoard;
3672         UrlCopyPMenu.Visible := bCategory or bBoard;
3673         NameUrlCopyPMenu.Visible := bCategory or bBoard;
3674         AllSelectPMenu.Visible := bCategory or bBoard;
3675         LPMSep05.Visible := bCategory or bBoard;
3676         DeletePMenu.Visible := bBoard;
3677         LPMSep06.Visible := bCategory or bBoard;
3678         BoardFavoriteAddMenu.Visible := bCategory;
3679         ThreadFavoriteAddMenu.Visible := bBoard;
3680     SaveThreadFile.Visible := bBoard;
3681         AddRoundNameMenu(ItemReservPMenu);
3682         AddRoundNameMenu(ListReservPMenu);
3683 end;
3684
3685 procedure TGikoForm.TreePopupMenuPopup(Sender: TObject);
3686 begin
3687         FClickNode := TreeView.Selected;
3688         if FClickNode = nil then begin
3689                 TreeSelectThreadPupupMenu.Visible := False;
3690                 TreeSelectBoardPupupMenu.Visible := False;
3691                 TPMSep01.Visible := False;
3692                 TreeSelectURLPupupMenu.Visible := False;
3693                 TreeSelectNamePupupMenu.Visible := False;
3694                 TreeSelectNameURLPupupMenu.Visible := False;
3695                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3696                 TreeSelectLogDeleteSeparator.Visible := False;
3697                 TreeSelectLogDeletePopupMenu.Visible := False;
3698         end else if TObject(FClickNode.Data) is TBoard then begin
3699                 TreeSelectThreadPupupMenu.Visible := False;
3700                 TreeSelectBoardPupupMenu.Visible := True;
3701                 TPMSep01.Visible := True;
3702                 TreeSelectURLPupupMenu.Visible := True;
3703                 TreeSelectNamePupupMenu.Visible := True;
3704                 TreeSelectNameURLPupupMenu.Visible := True;
3705                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3706                 TreeSelectLogDeleteSeparator.Visible := False;
3707                 TreeSelectLogDeletePopupMenu.Visible := False;
3708         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
3709                 TreeSelectThreadPupupMenu.Visible := False;
3710                 TreeSelectBoardPupupMenu.Visible := True;
3711                 TPMSep01.Visible := True;
3712                 TreeSelectURLPupupMenu.Visible := True;
3713                 TreeSelectNamePupupMenu.Visible := True;
3714                 TreeSelectNameURLPupupMenu.Visible := True;
3715                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3716                 TreeSelectLogDeleteSeparator.Visible := False;
3717                 TreeSelectLogDeletePopupMenu.Visible := False;
3718         end else if (TObject(FClickNode.Data) is TThreadItem) then begin
3719                 TreeSelectThreadPupupMenu.Visible := True;
3720                 TreeSelectBoardPupupMenu.Visible := False;
3721                 TPMSep01.Visible := True;
3722                 TreeSelectURLPupupMenu.Visible := True;
3723                 TreeSelectNamePupupMenu.Visible := True;
3724                 TreeSelectNameURLPupupMenu.Visible := True;
3725                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3726                 TreeSelectLogDeleteSeparator.Visible := True;
3727                 TreeSelectLogDeletePopupMenu.Visible := True;
3728         end else if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
3729                 TreeSelectThreadPupupMenu.Visible := True;
3730                 TreeSelectBoardPupupMenu.Visible := False;
3731                 TPMSep01.Visible := True;
3732                 TreeSelectURLPupupMenu.Visible := True;
3733                 TreeSelectNamePupupMenu.Visible := True;
3734                 TreeSelectNameURLPupupMenu.Visible := True;
3735                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3736                 TreeSelectLogDeleteSeparator.Visible := True;
3737                 TreeSelectLogDeletePopupMenu.Visible := True;
3738         end else if (TObject(FClickNode.Data) is TCategory) then begin
3739                 TreeSelectThreadPupupMenu.Visible := False;
3740                 TreeSelectBoardPupupMenu.Visible := False;
3741                 TPMSep01.Visible := False;
3742                 TreeSelectURLPupupMenu.Visible := False;
3743                 TreeSelectNamePupupMenu.Visible := True;
3744                 TreeSelectNameURLPupupMenu.Visible := False;
3745                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3746                 TreeSelectLogDeleteSeparator.Visible := False;
3747                 TreeSelectLogDeletePopupMenu.Visible := False;
3748         end else if FClickNode.IsFirstNode then begin
3749                 TreeSelectThreadPupupMenu.Visible := False;
3750                 TreeSelectBoardPupupMenu.Visible := False;
3751                 TPMSep01.Visible := False;
3752                 TreeSelectURLPupupMenu.Visible := False;
3753                 TreeSelectNamePupupMenu.Visible := True;
3754                 TreeSelectNameURLPupupMenu.Visible := False;
3755                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3756                 TreeSelectLogDeleteSeparator.Visible := False;
3757                 TreeSelectLogDeletePopupMenu.Visible := False;
3758         end else begin
3759                 TreeSelectThreadPupupMenu.Visible := False;
3760                 TreeSelectBoardPupupMenu.Visible := False;
3761                 TPMSep01.Visible := False;
3762                 TreeSelectURLPupupMenu.Visible := False;
3763                 TreeSelectNamePupupMenu.Visible := False;
3764                 TreeSelectNameURLPupupMenu.Visible := False;
3765                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3766                 TreeSelectLogDeleteSeparator.Visible := False;
3767                 TreeSelectLogDeletePopupMenu.Visible := False;
3768         end;
3769 end;
3770
3771 procedure TGikoForm.BrowserNewWindow2(Sender: TObject;
3772         var ppDisp: IDispatch; var Cancel: WordBool);
3773 var
3774         Text: string;
3775         Html: string;
3776         URL: string;
3777         idx: Integer;
3778         wkIntSt: Integer;
3779         wkIntTo: Integer;
3780     BNum, BRes: string;
3781     threadItem: TThreadItem;
3782     aElement : IHTMLElement;
3783 begin
3784 {$IFDEF DEBUG}
3785         Writeln(IntToStr(Integer(ppDisp)));
3786 {$ENDIF}
3787         Cancel := True;
3788     aElement := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement;
3789         if ( aElement <> nil) then begin
3790                 Text := aElement.Get_outerText;
3791                 Html := aElement.Get_outerHTML;
3792                 if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
3793                         or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
3794                         if GikoSys.Setting.ResAnchorJamp then begin
3795
3796                                 Text := ZenToHan(Trim(Text));
3797
3798                                 if(AnsiPos('>>', Text) = 1) then begin
3799                                         //Text := Copy(Text, 3, Length(Text) - 2);
3800                                         Delete(Text, 1, 2);
3801                                 end else begin
3802                                         //Text := Copy(Text, 2, Length(Text) - 1);
3803                                         Delete(Text, 1, 1);
3804                                 end;
3805
3806                                 if AnsiPos('-', Text) <> 0 then begin
3807                                         wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
3808                                         Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
3809                                         wkIntTo := StrToIntDef(Text, 0);
3810                                         if wkIntTo < wkIntSt then
3811                                                 wkIntSt := wkIntTo;
3812                                 end else begin
3813                                         wkIntSt := StrToIntDef(Text, 0);
3814                                 end;
3815
3816                                 if wkIntSt <> 0 then begin
3817                         FActiveContent.IDAnchorPopup('');
3818                     MoveHisotryManager.pushItem(FActiveContent);
3819                     if (Sender is TResPopupBrowser) then begin
3820                         TResPopupBrowser(Sender).ChildClear;
3821                         OpenThreadItem(
3822                             GetActiveContent(true),
3823                             GetActiveContent(true).URL + '&st=' +
3824                                  IntToStr(wkIntSt) + '&to=' + IntToStr(wkIntSt));
3825                     end else begin
3826                                         BrowserMovement(IntToStr(wkIntSt));
3827                     end;
3828                 end;
3829                         end;
3830                 end else begin
3831             ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
3832
3833                         URL := GikoSys.GetHRefText(Html);
3834                         URL := GikoSys.HTMLDecode(URL);
3835             if AnsiPos('BE:', URL) = 1 then begin
3836                                 BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
3837                                 BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
3838                 threadItem := FActiveContent.Thread;
3839                 if threadItem = nil then Exit;
3840                 URL := BE_PHP_URL + BNum + '&u=d'
3841                         + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
3842             end;
3843
3844                         if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
3845                                 ( AnsiPos('ftp://', URL) = 1) then begin
3846                                 //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
3847                                 if GikoSys.Setting.LinkAddAddressBar then begin
3848                                         idx := AddressComboBox.Items.IndexOf(URL);
3849                                         if idx = -1 then begin
3850                                                 AddressComboBox.Items.Insert(0, URL);
3851                                                 if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
3852                                                         AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
3853                                         end else begin
3854                                                 AddressComboBox.Items.Delete(idx);
3855                                                 AddressComboBox.Items.Insert(0, URL);
3856                                         end;
3857                                 end;
3858                 if (Sender is TResPopupBrowser) then begin
3859                     TResPopupBrowser(Sender).ChildClear
3860                 end;
3861
3862                 MoveHisotryManager.pushItem(FActiveContent);
3863                                 MoveToURL( URL );
3864                         end;
3865                 end;
3866     end;
3867
3868 end;
3869
3870 procedure TGikoForm.ListSplitterMoved(Sender: TObject);
3871 begin
3872         if Mouse.Capture <> 0 then
3873                 Exit;
3874         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3875                 if (ViewPanel.Width > 1) and (ViewPanel.Width <= (ThreadMainPanel.Width - 80)) then
3876                         FBrowserSizeWidth := ViewPanel.Width;
3877         end else begin
3878                 if (ViewPanel.Height > 1) and (ViewPanel.Height <= (ThreadMainPanel.Height - BrowserCoolBar.Height)) then
3879                         FBrowserSizeHeight := ViewPanel.Height;
3880         end;
3881         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3882                 if ViewPanel.Width < 2 then begin
3883                         ViewPanel.Width := 1;
3884                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3885                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3886                         GikoSys.Setting.ListWidthState := glsMax;
3887                 end else if ViewPanel.Width > (ThreadMainPanel.Width - 80) then begin
3888                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3889                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3890                         GikoSys.Setting.ListWidthState := glsMin;
3891                 end else begin
3892                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3893                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3894                         GikoSys.Setting.ListWidthState := glsNormal;
3895                 end;
3896         end else begin
3897                 if ViewPanel.Height < 2 then begin
3898                         ViewPanel.Height := 1;
3899                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3900                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3901                         GikoSys.Setting.ListHeightState := glsMax;
3902                 end else if ViewPanel.Height > (ThreadMainPanel.Height - BrowserCoolBar.Height - 7) then begin
3903                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3904                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3905                         GikoSys.Setting.ListHeightState := glsMin;
3906                 end else begin
3907                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3908                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3909                         GikoSys.Setting.ListHeightState := glsNormal;
3910                 end;
3911         end;
3912 {       if (Mouse.Capture = 0) and (ViewPanel.Height > 1) and (not ArrangeAction.Checked) then
3913                 FBrowserSizeHeight := ViewPanel.Height
3914         else if (Mouse.Capture = 0) and (ViewPanel.Width > 1) and (ArrangeAction.Checked) then
3915                 FBrowserSizeWidth := ViewPanel.Width;}
3916 end;
3917
3918 procedure TGikoForm.BrowserTabChange(Sender: TObject);
3919 var
3920         j: Integer;
3921         idx: Integer;
3922 begin
3923         BrowserTab.Tabs.BeginUpdate;
3924         try
3925                 if not BrowserTab.Dragging then begin
3926                         FTabHintIndex := -1;
3927                         BrowserTab.Hint := '';
3928                         idx := BrowserTab.TabIndex;
3929                         if idx = -1 then begin
3930                                 SetContent(BrowserNullTab);
3931
3932                         end else if(BrowserTab.Tabs.Objects[idx] <> nil) and (BrowserTab.Tabs.Objects[idx] is TBrowserRecord) then begin
3933                                 if TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser <> nil then begin
3934                                         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser);
3935                                         if j <> -1 then
3936                                                 FBrowsers.Move(j ,0);
3937                                 end else begin
3938                                         if( FActiveContent <> nil ) and (FActiveContent.Browser <> nil) and
3939                                                 (FActiveContent.Browser <> BrowserNullTab.Browser) and
3940                                                 (FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
3941                                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
3942
3943                     // \88ê\94Ô\8cÃ\82¢\83u\83\89\83E\83U\82ð\8aJ\95ú\82·\82é
3944                     ReleaseOldestBrowser;
3945
3946                                         TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3947                                         TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Repaint := true;
3948                                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
3949                                 end;
3950                                 MoveWindow(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser.Handle, 0, 0, BrowserPanel.Width, BrowserPanel.Height, false);
3951                                 TOleControl(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser).BringToFront;
3952                                 SetContent(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
3953
3954                                 if (GikoSys.Setting.URLDisplay) and (GetActiveContent <> nil) then
3955                                         AddressComboBox.Text := GetActiveContent.URL;
3956
3957                                 if ((TreeView.Visible) and (TreeView.Focused)) or ((FavoriteTreeView.Visible) and (FavoriteTreeView.Focused)) or
3958                                         (ListView.Focused) or (SelectComboBox.Focused) or (AddressComboBox.Focused)
3959                                 then
3960                                 else
3961                                         GikoDM.SetFocusForBrowserAction.Execute;
3962                         end;
3963                 end;
3964         finally
3965                 BrowserTab.Tabs.EndUpdate;
3966         end;
3967 end;
3968
3969
3970 procedure TGikoForm.BrowserTabMouseDown(Sender: TObject;
3971         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
3972 var
3973         p: TPoint;
3974         p2: TPoint;
3975         idx: Integer;
3976 begin
3977         if Button = mbMiddle then begin
3978                 // \83}\83E\83X\92\86\83{\83^\83\93
3979                 GetCursorPos(p);
3980                 p2 := p;
3981                 p := BrowserTab.ScreenToClient(p);
3982                 idx := BrowserTab.IndexOfTabAt(p.X, p.Y);
3983                 if idx <> -1 then
3984                         DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
3985         end else if Button = mbLeft then begin
3986                 FDragWFirst := true;
3987                 FMouseDownPos.X := X;
3988                 FMouseDownPos.Y := Y;
3989         end;
3990
3991 end;
3992
3993 procedure TGikoForm.SetBrowserTabState;
3994 var
3995         CoolBand: TCoolBand;
3996 begin
3997         BrowserBottomPanel.AutoSize := False;
3998         if GikoSys.Setting.BrowserTabVisible then begin
3999                 BrowserTab.Hide;
4000                 BrowserTab.Tabs.BeginUpdate;
4001                 try
4002                         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
4003                                 BrowserTab.Style := tsTabs;
4004                                 if GikoSys.Setting.BrowserTabPosition = gtpTop then
4005                                         BrowserTab.TabPosition := tpTop
4006                                 else
4007                                         BrowserTab.TabPosition := tpBottom;
4008                         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
4009                                 BrowserTab.TabPosition := tpTop;
4010                                 BrowserTab.Style := tsButtons;
4011                         end else begin
4012                                 BrowserTab.TabPosition := tpTop;
4013                                 BrowserTab.Style := tsFlatButtons
4014                         end;
4015
4016                         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
4017                                 BrowserTab.Parent := BrowserTabToolBar;
4018                                 BrowserBottomPanel.Hide;
4019                                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4020                                 if CoolBand <> nil then
4021                                         CoolBand.Visible := True;
4022                         end else begin
4023                                 BrowserTab.Parent := BrowserBottomPanel;
4024                                 BrowserTab.Top := 0;
4025                                 BrowserTab.Left := 0;
4026                                 BrowserBottomPanel.Show;
4027                                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4028                                 if CoolBand <> nil then
4029                                         CoolBand.Visible := False;
4030                         end;
4031                 finally
4032                         BrowserTab.Tabs.EndUpdate;
4033                         BrowserTab.Show;
4034                 end;
4035         end else begin
4036                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4037                 if CoolBand <> nil then
4038                         CoolBand.Visible := False;
4039                 BrowserBottomPanel.Visible := False;
4040                 GikoDM.AllTabCloseAction.Execute;
4041         end;
4042 end;
4043
4044 procedure TGikoForm.BrowserTabDragOver(Sender, Source: TObject; X,
4045         Y: Integer; State: TDragState; var Accept: Boolean);
4046 var
4047         idx: Integer;
4048 begin
4049         idx := BrowserTab.IndexOfTabAt(X, Y);
4050         Accept := (Source = BrowserTab) and (BrowserTab.TabIndex <> idx);
4051 end;
4052
4053 procedure TGikoForm.BrowserTabDragDrop(Sender, Source: TObject; X,
4054         Y: Integer);
4055 var
4056         idx: Integer;
4057 begin
4058     FDragWFirst := False;
4059         idx := BrowserTab.IndexOfTabAt(X, Y);
4060         if idx <> -1 then
4061                 BrowserTab.Tabs.Move(BrowserTab.TabIndex, idx);
4062 end;
4063
4064 procedure TGikoForm.BrowserTabMouseMove(Sender: TObject;
4065         Shift: TShiftState; X, Y: Integer);
4066 var
4067         TabIdx: Integer;
4068         ThreadItem: TThreadItem;
4069 begin
4070
4071         TabIdx := BrowserTab.IndexOfTabAt(x, y);
4072
4073         if ( ssLeft in Shift ) then begin
4074         if (FDragWFirst) then begin
4075                         BrowserTab.EndDrag(false);
4076                         BrowserTab.BeginDrag(false, DandD_THRESHOLD);
4077         end;
4078         end else begin
4079                 BrowserTab.EndDrag(false);
4080                 FDragWFirst := false;
4081         end;
4082         
4083         if (FTabHintIndex <> TabIdx) and (TabIdx <> -1) then begin
4084                 Application.CancelHint;
4085                 ThreadItem := TBrowserRecord(BrowserTab.Tabs.Objects[TabIdx]).Thread;
4086                 if ThreadItem.Title <> BrowserTab.Tabs[TabIdx] then begin
4087                         BrowserTab.Hint := ThreadItem.Title;
4088                         Application.ShowHint := True;
4089                 end else begin
4090                         BrowserTab.Hint := '';
4091                         Application.ShowHint := True;
4092                 end;
4093                 FTabHintIndex := TabIdx;
4094         end;
4095
4096 end;
4097
4098 procedure TGikoForm.BrowserDocumentComplete(Sender: TObject;
4099         const pDisp: IDispatch; var URL: OleVariant);
4100 var
4101         FDispHtmlDocument: DispHTMLDocument;
4102         BrowserRecord :TBrowserRecord;
4103         i :Integer;
4104         doc                                     : Variant;
4105         threadItem      : TThreadItem;
4106 begin
4107         if TObject(Sender) is TWebBrowser then begin
4108                 BrowserRecord := nil;
4109                 if TWebBrowser(Sender) <> Browser then begin
4110                         for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
4111                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(Sender) then begin
4112                                                 BrowserRecord := TBrowserRecord(BrowserTab.Tabs.Objects[i]);
4113                                                 break;
4114                                 end;
4115                         end;
4116                         if BrowserRecord <> nil then begin
4117                                 if BrowserRecord.Event <> nil then
4118                                         BrowserRecord.Event.Free;
4119                                 FDispHtmlDocument := Idispatch(OleVariant(BrowserRecord.Browser.ControlInterface).Document) as DispHTMLDocument;
4120                                 BrowserRecord.Event := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4121                                 BrowserRecord.Event.OnContextMenu := OnDocumentContextMenu;
4122                                 BrowserRecord.Event.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4123                         end;
4124                 end else begin
4125                         if GetActiveContent <> nil then begin
4126                                 FDispHtmlDocument := Idispatch(OleVariant(Browser.ControlInterface).Document) as DispHTMLDocument;
4127                                 if FEvent <> nil then
4128                                         FEvent.Free;
4129                                 FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4130                                 FEvent.OnContextMenu := OnDocumentContextMenu;
4131                                 FEvent.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4132                         end else begin
4133                                 if FEvent <> nil then begin
4134                                         FEvent.Free;
4135                                         FEvent := nil;
4136                                 end;
4137                         end;
4138
4139                 end;
4140
4141                 if (BrowserRecord <> nil) and
4142                          Assigned( BrowserRecord.Thread ) then begin
4143                         threadItem := BrowserRecord.Thread;
4144
4145                         if (threadItem.JumpAddress > 0) then begin
4146                                 if threadItem.UnRead then begin
4147                                         threadItem.UnRead := False;
4148                                         TreeView.Refresh;
4149                                         RefreshListView(threadItem);
4150                                 end;
4151                                 // \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®
4152                                 //if (StrToIntDef(BrowserRecord.Movement, 0) <= BrowserRecord.Thread.Count) then begin
4153                                 if (threadItem.JumpAddress <= BrowserRecord.Thread.Count) then begin
4154                                         BrowserRecord.Move(IntToStr(threadItem.JumpAddress));
4155                                         threadItem.JumpAddress := 0;
4156                                 end else begin
4157                                         BrowserRecord.Move(IntToStr(BrowserRecord.Thread.Count));
4158                                 end;
4159
4160                         end else if threadItem.UnRead then begin
4161                                 threadItem.UnRead := False;
4162                                 TreeView.Refresh;
4163                                 BrowserRecord.Move('new');
4164                                 RefreshListView(threadItem);
4165                         end else if threadItem.ScrollTop <> 0 then begin
4166                                 try
4167                                         doc := Idispatch( OleVariant( BrowserRecord.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4168                                         doc.Body.ScrollTop := threadItem.ScrollTop;
4169                                 except
4170                                         on E: Exception do
4171                                                 MsgBox(Handle, E.Message, 'SetContent[ScrollTop<-]', 0);
4172                                 end;
4173                         end;
4174                 end;
4175         end;
4176         LockWindowUpdate(0);
4177 end;
4178
4179 procedure TGikoForm.RoundNamePopupMenuPopup(Sender: TObject);
4180 begin
4181         AddRoundNameMenu(RoundNamePopupMenu.Items);
4182 end;
4183
4184 procedure TGikoForm.AddRoundNameMenu(MenuItem: TMenuItem);
4185 var
4186         i: Integer;
4187         Item: TMenuItem;
4188 begin
4189         MenuItem.Clear;
4190         Item := TMenuItem.Create(Self);
4191         Item.Caption := '\90V\82µ\82¢\96¼\91O\82Å\8f\84\89ñ\97\\96ñ(&N)...';
4192         Item.OnClick := GikoDM.SelectNewRoundNameExecute;
4193         MenuItem.Add(Item);
4194         Item := TMenuItem.Create(Self);
4195         Item.Caption := '\8f\84\89ñ\83\8a\83X\83g\82©\82ç\8dí\8f\9c(&D)';
4196         Item.OnClick := GikoDM.SelectDeleteRoundExecute;
4197         MenuItem.Add(Item);
4198         Item := TMenuItem.Create(Self);
4199         Item.Caption := '-';
4200         MenuItem.Add(Item);
4201         for i := 0 to RoundList.RoundNameList.Count - 1 do begin
4202                 Item := TMenuItem.Create(Self);
4203                 Item.Caption := RoundList.RoundNameList[i];
4204                 Item.OnClick := SetSelectRoundName;
4205                 MenuItem.Add(Item);
4206         end;
4207 end;
4208
4209 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string);
4210 var
4211         threadItem : TThreadItem;
4212 begin
4213         if ParentName <> 'dummy1' then begin
4214                 SetSelectItemRound(RoundFlag, RoundName);
4215         end else begin
4216                 threadItem := GetActiveContent;
4217                 if threadItem <> nil then begin
4218                         threadItem.RoundName := RoundName;
4219                         if RoundFlag then
4220                                 RoundList.RoundNameList.Add(RoundName);
4221                         threadItem.Round := RoundFlag;
4222                 end;
4223         end;
4224 end;
4225
4226 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string);
4227 var
4228         i{, idx}: Integer;
4229         List: TList;
4230 begin
4231         List := TList.Create;
4232         try
4233                 SelectListItem(List);
4234                 for i := 0 to List.Count - 1 do begin
4235                         if TObject(List[i]) is TBoard then begin
4236                                 TBoard(List[i]).RoundName := RoundName;
4237                                 if RoundFlag then
4238                                         RoundList.RoundNameList.Add(RoundName);
4239                                 TBoard(List[i]).Round := RoundFlag;
4240                         end else if TObject(List[i]) is TThreadItem then begin
4241                                 if TThreadItem(List[i]).IsLogFile then begin
4242                                         TThreadItem(List[i]).RoundName := RoundName;
4243                                         if RoundFlag then
4244                                                 RoundList.RoundNameList.Add(RoundName);
4245                                         TThreadItem(List[i]).Round := RoundFlag;
4246                                 end;
4247                         end;
4248                 end;
4249         finally
4250                 List.Free;
4251         end;
4252 end;
4253
4254 procedure TGikoForm.SetSelectRoundName(Sender: TObject);
4255 var
4256         MenuItem: TMenuItem;
4257 begin
4258         if Sender is TMenuItem then begin
4259                 MenuItem := TMenuItem(Sender);
4260                 SetSelectItemRound(True, StripHotKey(MenuItem.Caption), TMenuItem(Sender).Parent.Name);
4261                 ListView.Refresh;
4262         end;
4263 end;
4264
4265 function TGikoForm.GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
4266 var
4267         i: Integer;
4268 begin
4269         Result := nil;
4270         if CoolBar = nil then
4271                 Exit;
4272         for i := 0 to CoolBar.Bands.Count - 1 do begin
4273                 if CoolBar.Bands[i].Control = Control then begin
4274                         Result := CoolBar.Bands[i];
4275                         Exit;
4276                 end;
4277         end;
4278 end;
4279
4280 procedure TGikoForm.BrowserTabToolBarResize(Sender: TObject);
4281 begin
4282         if BrowserTab.Parent = BrowserTabToolBar then
4283                 BrowserTab.Width := BrowserTabToolBar.Width;
4284 end;
4285
4286 procedure TGikoForm.WMSettingChange(var Message: TWMWinIniChange);
4287 begin
4288         SetMenuFont;
4289 end;
4290
4291 procedure TGikoForm.SetMenuFont;
4292 begin
4293 //      GikoSys.MenuFont(MenuToolBar.Font);
4294 //      MenuToolBar.Buttons[0].AutoSize := False;
4295 //      MenuToolBar.Buttons[0].AutoSize := True;
4296 //      MenuToolBar.Font.Color := clMenuText;
4297         GikoSys.MenuFont(MainCoolBar.Font);
4298         MenuToolBar.Buttons[0].AutoSize := False;
4299         MenuToolBar.Buttons[0].AutoSize := True;
4300         MainCoolBar.AutoSize := False;
4301         MainCoolBar.AutoSize := True;
4302
4303         GikoSys.MenuFont(ListCoolBar.Font);
4304         GikoSys.MenuFont(BrowserCoolBar.Font);
4305 //      MenuToolBar.Font.Color := clMenuText;
4306 end;
4307
4308 procedure TGikoForm.FavoriteMenuClick(Sender: TObject);
4309 var
4310         NewMenu: TMenuItem;
4311 begin
4312         if FavoriteDM.Modified then begin
4313                 FavoriteMenu.Clear;
4314
4315                 //\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á
4316                 NewMenu := TMenuItem.Create(MainMenu);
4317                 NewMenu.Action := GikoDM.FavoriteAddAction;
4318                 FavoriteMenu.Add(NewMenu);
4319                 //\82¨\8bC\82É\93ü\82è\82Ì\90®\97\9d
4320                 NewMenu := TMenuItem.Create(FavoriteMenu);
4321                 NewMenu.Action := GikoDM.FavoriteArrangeAction;
4322                 FavoriteMenu.Add(NewMenu);
4323                 //\83Z\83p\83\8c\81[\83^
4324                 FavoriteMenu.InsertNewLineAfter(NewMenu);
4325                 CreateFavMenu(FavoriteDM.TreeView.Items.GetFirstNode, FavoriteMenu);
4326                 FavoriteDM.Modified := false;
4327         end;
4328 end;
4329
4330 procedure TGikoForm.CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
4331 var
4332         i: Integer;
4333         NewMenu: array of TMenuItem;
4334 begin
4335         SetLength(NewMenu, Node.Count);
4336         Node := Node.getFirstChild;
4337         i := 0;
4338         while ( Node <> nil ) do begin
4339                 NewMenu[i] := TFavoriteMenuItem.Create(nil);
4340                 NewMenu[i].AutoHotkeys := maAutomatic;
4341                 NewMenu[i].Caption := CustomStringReplace(Node.Text, '&', '&&');
4342                 TFavoriteMenuItem(NewMenu[i]).Data := Node.Data;
4343
4344                 if TObject(Node.Data) is TFavoriteFolder then begin
4345                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
4346                         CreateFavMenu(Node, NewMenu[i]);
4347                 end else if TObject(Node.Data) is TFavoriteBoardItem then begin
4348                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
4349                         NewMenu[i].OnClick := FavoriteClick;
4350                 end else if TObject(Node.Data) is TFavoriteThreadItem then begin
4351                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
4352                         NewMenu[i].OnClick := FavoriteClick;
4353                 end;
4354         Inc(i);
4355                 Node := Node.getNextSibling;
4356         end;
4357         MenuItem.Add(NewMenu);
4358 end;
4359
4360 procedure TGikoForm.ShowFavoriteAddDialog( Item : TObject );
4361 const
4362         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';
4363         TitleAdd: String =  '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á';
4364 var
4365         Dlg                     : TFavoriteAddDialog;
4366         ItemURL : string;
4367         Data            : Pointer;
4368         Node            : TTreeNode;
4369 begin
4370
4371         if Item is TFavoriteBoardItem then
4372                 Item := TFavoriteBoardItem( Item ).Item
4373         else if Item is TFavoriteThreadItem then
4374                 Item := TFavoriteThreadItem( Item ).Item;
4375
4376         Node := FavoriteTreeView.Items.GetFirstNode;
4377         if Item is TBoard then begin
4378                 ItemURL := TBoard( Item ).URL;
4379                 while Node <> nil do begin
4380                         Data := Node.Data;
4381                         if TObject( Data ) is TFavoriteBoardItem then begin
4382                                 if ItemURL = TFavoriteBoardItem( Data ).URL then begin
4383                                         if Application.MessageBox(PChar(MsgAdd) , PChar(TitleAdd), MB_YESNO ) = IDNO then
4384                                                 Exit;
4385                                         Break;
4386                                 end;
4387                         end;
4388                         Node := Node.GetNext;
4389                 end;
4390                 Dlg := TFavoriteAddDialog.Create(Self);
4391                 try
4392                         Dlg.SetBoard( TBoard( Item ) );
4393                         Dlg.ShowModal;
4394                 finally
4395                         Dlg.Release;
4396                 end;
4397         end else if Item is TThreadItem then begin
4398                 ItemURL := TThreadItem( Item ).URL;
4399                 while Node <> nil do begin
4400                         Data := Node.Data;
4401                         if TObject( Data ) is TFavoriteThreadItem then begin
4402                                 if ItemURL = TFavoriteThreadItem( Data ).URL then begin
4403                                         if Application.MessageBox( PChar(MsgAdd), PChar(TitleAdd), MB_YESNO ) = IDNO then
4404                                                 Exit;
4405                                         Break;
4406                                 end;
4407                         end;
4408                         Node := Node.GetNext;
4409                 end;
4410                 Dlg := TFavoriteAddDialog.Create(Self);
4411                 try
4412                         Dlg.SetThreadItem( TThreadItem( Item ) );
4413                         Dlg.ShowModal;
4414                 finally
4415                         Dlg.Release;
4416                 end;
4417         end;
4418
4419         SetLinkBar;
4420 end;
4421
4422 procedure TGikoForm.FavoriteClick(Sender: TObject);
4423 begin
4424         FavoriteClick( Sender, True );
4425 end;
4426
4427 procedure TGikoForm.FavoriteClick(Sender: TObject; ActiveTab: Boolean);
4428 var
4429         Board: TBoard;
4430         ThreadItem: TThreadItem;
4431         FavBoard: TFavoriteBoardItem;
4432         FavThread: TFavoriteThreadItem;
4433         Item: TObject;
4434 begin
4435 //      Item := nil;
4436         if Sender is TFavoriteMenuItem then
4437                 Item := TFavoriteMenuItem(Sender).Data
4438         else if Sender is TLinkToolButton then
4439                 Item := TLinkToolButton(Sender).Data
4440         else if Sender is TTreeNode then
4441                 Item := TTreeNode( Sender ).Data
4442         else
4443                 Exit;
4444
4445         if TObject(Item) is TFavoriteBoardItem then begin
4446                 FavBoard := TFavoriteBoardItem(Item);
4447                 Board := FavBoard.Item;
4448                 if Board <> nil then begin
4449                         if (FTreeType = gtt2ch) and (FActiveBBS <> Board.ParentCategory.ParenTBBS) then
4450                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4451                         SelectTreeNode(Board, True);
4452                 end;
4453         end else if TObject(Item) is TFavoriteThreadItem then begin
4454                 FavThread := TFavoriteThreadItem(Item);
4455                 ThreadItem := FavThread.Item;
4456                 if ThreadItem = nil then
4457                         Exit;
4458
4459                 InsertBrowserTab(ThreadItem, ActiveTab);
4460
4461                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
4462                         if GikoSys.Setting.ListWidthState = glsMin then begin
4463                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4464                         end;
4465                 end else begin
4466                         if GikoSys.Setting.ListHeightState = glsMin then begin
4467                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4468                         end;
4469                 end;
4470         end;
4471 end;
4472
4473 procedure TGikoForm.BBSMenuItemOnClick(
4474         Sender  : TObject
4475 );
4476 begin
4477
4478         if Sender is TBBSMenuItem then
4479                 ShowBBSTree( TBBSMenuItem( Sender ).Data );
4480
4481 end;
4482
4483 procedure TGikoForm.MainCoolBarResize(Sender: TObject);
4484 begin
4485         TopPanel.Height := Max(MainCoolBar.Height, AnimePanel.Height);
4486
4487 end;
4488 //! \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é)
4489 procedure TGikoForm.OpenThreadItem(Thread: TThreadItem; URL: String);
4490 var
4491         stRes, edRes : Int64;
4492         browserRec : TBrowserRecord;
4493         threadNumber : String;
4494         doc : Variant;
4495 begin
4496         stRes := 0;
4497         edRes := 0;
4498         Thread.JumpAddress := 0;
4499         // \83^\83u\82ð\90\90¬
4500         browserRec := InsertBrowserTab(Thread);
4501         if (browserRec <> nil) then begin
4502                 // JUMP\82·\82×\82«\83\8c\83X\94Ô\8d\86\82ª\82 \82é\82©\83`\83F\83b\83N\82·\82é
4503                 threadNumber := ChangeFileExt(Thread.FileName, '');
4504                 GikoSys.GetPopupResNumber( URL, stRes, edRes );
4505                 // \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
4506                 if (StrToInt64(threadNumber) = stRes) then begin
4507                         if not (AnsiEndsText(threadNumber + '/' + threadNumber, URL))
4508                                 and (Pos('&st=' + threadNumber , URL) = 0) then begin
4509                                 stRes := 0;
4510                         end;
4511                 end;
4512                 if ( stRes > 0 ) then begin
4513                         Thread.JumpAddress := stRes;
4514                 end;
4515                 // \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é
4516                 if (not Thread.IsLogFile) or (stRes > Thread.Count) then begin
4517                         DownloadContent(Thread);
4518                 end else if (not browserRec.Repaint) and (stRes > 0) then begin
4519                         browserRec.Move(IntToStr(stRes));
4520                         Thread.JumpAddress := 0;
4521                         try
4522                                 doc := Idispatch( OleVariant( browserRec.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4523                                 Thread.ScrollTop := doc.Body.ScrollTop;
4524                         except
4525                         end;
4526                 end;
4527         end;
4528 end;
4529
4530 procedure TGikoForm.MoveToURL(const inURL: string);
4531 var
4532         protocol, host, path, document, port, bookmark : string;
4533         URL, protocol2, host2, path2, document2, port2, bookmark2 : string;
4534         tmp1, tmp2: string;
4535         BBSID, BBSKey: string;
4536         {tmpBoard,} Board: TBoard;
4537         ThreadItem: TThreadItem;
4538         i, bi                                   : Integer;
4539         boardURL                        : string;
4540         tmpThread                       : TThreadItem;
4541         shiftDown                       : Boolean;
4542         ctrlDown                        : Boolean;
4543 begin
4544
4545         GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
4546         GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey );
4547
4548
4549         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
4550         ctrlDown        := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
4551         if shiftDown then begin
4552                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4553                 Exit;
4554         end else if ctrlDown then begin
4555                 GikoSys.OpenBrowser(inURL, gbtIE);
4556                 Exit;
4557         end;
4558
4559         //===== \83v\83\89\83O\83C\83\93
4560         try
4561                 //\8dì\8bÆ\92\86//
4562                 bi := Length(BoardGroups) - 1;
4563                 for i := 1 to bi do begin
4564                         if (BoardGroups[i].BoardPlugIn <> nil) and (Assigned(Pointer(BoardGroups[i].BoardPlugIn.Module))) then begin
4565                                 case BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) of
4566                                 atThread:
4567                                         begin
4568                                                 boardURL        := BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL );
4569                                                 Board           := BBSsFindBoardFromURL( boardURL );
4570
4571
4572                                                 if Board = nil then begin
4573                                                         //break;
4574                                                         // \81¦\8dì\82Á\82Ä\82à\92Ç\89Á\82·\82é\82Æ\82±\82ë\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82­\95Û\97¯
4575                                                         //GikoSys.OpenBrowser(inURL, gbtUserApp);
4576                                                         //Exit;
4577                                                         {
4578                                                         Board := GikoSys.GetUnknownBoard( tmpThread.BoardPlugIn, boardURL );
4579                                                         if (FTreeType = gtt2ch) and (FActiveBBS = BBSs[ 1 ]) then
4580                                                                 ShowBBSTree( BBSs[ 1 ] );
4581                                                         }
4582                                                 end else begin
4583                                                         tmpThread               := TThreadItem.Create( BoardGroups[i].BoardPlugIn, Board, inURL );
4584                                                         if not Board.IsThreadDatRead then begin
4585                                                                 GikoSys.ReadSubjectFile( Board );
4586                                                                 tmpThread.Free;
4587                                                                 Exit;
4588                                                         end;
4589                                                         ThreadItem := Board.FindThreadFromFileName( tmpThread.FileName );
4590                                                         if ThreadItem = nil then begin
4591                                                                 //tmpThread\82ð\82±\82Á\82¿\82Í\8aJ\95ú\82µ\82Ä\82Í\82¢\82¯\82È\82¢
4592                                                                 ThreadItem := tmpThread;
4593                                                                 Board.Insert( 0, ThreadItem );
4594                                                                 if ActiveList is TBoard then begin
4595                                                                         if TBoard(ActiveList) = Board then
4596                                                                                 ListView.Items.Count := ListView.Items.Count + 1;
4597                                                                 end;
4598                                                         end else begin
4599                                                                 tmpThread.Free;
4600                                                         end;
4601                                                         OpenThreadItem(ThreadItem, inURL);
4602                                                         Exit;
4603                                                 end;
4604                                         end;
4605
4606                                 atBoard:
4607                                         begin
4608                                                 Board := BBSsFindBoardFromURL(
4609                                                                         BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL )
4610                                                                         );
4611                                                 if Board <> nil then begin
4612                                                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4613                                                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4614                                                         SelectTreeNode( Board, True );
4615                                                         Exit;
4616                                                 end;
4617                                         end;
4618                                 end;
4619                         end;
4620                 end;
4621         except
4622                 // 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¢
4623         end;
4624
4625
4626         if (Length( Trim(BBSKey) ) > 0) and (Length( Trim(BBSID) ) > 0) then begin
4627                 boardURL := GikoSys.Get2chThreadURL2BoardURL( inURL );
4628                 Board := BBSsFindBoardFromURL( boardURL );
4629                 if Board = nil then begin
4630                          // \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­
4631                          GikoSys.OpenBrowser(inURL, gbtUserApp);
4632                          Exit;
4633                 end else begin
4634                         // \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é
4635                         URL :=  Board.URL;
4636                         GikoSys.ParseURI(URL , protocol2, host2, path2, document2, port2, bookmark2 );
4637                         tmp1 := Copy(host, AnsiPos('.', host) + 1, Length(host));
4638                         tmp2 := Copy(host2, AnsiPos('.', host2) + 1, Length(host2));
4639                         if ( not GikoSys.Is2chHost(tmp1)) and (tmp1 <> tmp2) then begin
4640                                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4641                                 Exit;
4642                         end;
4643                 end;
4644
4645                 if not Board.IsThreadDatRead then
4646                         GikoSys.ReadSubjectFile(Board);
4647                 URL := GikoSys.Get2chBrowsableThreadURL( inURL );
4648                 ThreadItem := Board.FindThreadFromURL( URL );
4649                 //\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)
4650                 if ThreadItem = nil then begin
4651                         ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
4652                 end;
4653                 try
4654                         // \83X\83\8c\83b\83h\83A\83C\83e\83\80\82ª\82È\82¢\82È\82ç\90\90¬\82·\82é\81B
4655                         if ThreadItem = nil then begin
4656                                 ThreadItem := TThreadItem.Create( nil, Board, URL );
4657                                 ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
4658                                 Board.Insert(0, ThreadItem);
4659                                 if ActiveList is TBoard then begin
4660                                         if TBoard(ActiveList) = Board then
4661                                                 ListView.Items.Count := ListView.Items.Count + 1;
4662                                 end;
4663                         end;
4664                         // \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é
4665                         if (not ThreadItem.IsLogFile) then begin
4666                                 if AnsiPos(Host, Board.URL) = 0 then
4667                                         ThreadItem.DownloadHost := Host
4668                                 else
4669                                         ThreadItem.DownloadHost := '';
4670                         end;
4671                         OpenThreadItem(ThreadItem, inURL);
4672                 except
4673                 end;
4674         end else begin
4675                 Board := BBSsFindBoardFromURL( inURL );
4676                 if Board = nil then begin
4677                         GikoSys.OpenBrowser(inURL, gbtAuto);
4678                 end else begin
4679                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4680                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4681                         SelectTreeNode( Board, True );
4682                 end;
4683         end;
4684 end;
4685
4686 procedure TGikoForm.AddressToolBarResize(Sender: TObject);
4687 begin
4688         AddressComboBox.Width := AddressToolBar.Width - MoveToToolButton.Width - 10;
4689         CoolBarResized( Sender, MainCoolBar );
4690 end;
4691
4692 procedure TGikoForm.AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
4693         Shift: TShiftState);
4694 begin
4695         if Key = VK_RETURN then
4696                 GikoDM.MoveToAction.Execute;
4697 end;
4698
4699 procedure TGikoForm.BrowserEnter(Sender: TObject);
4700 begin
4701     Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
4702 end;
4703
4704 procedure TGikoForm.WMCopyData(var Message: TWMCopyData);
4705 var
4706         CDS:PCopyDataStruct;
4707         PC:PChar;
4708         sURL: string;
4709 begin
4710         CDS := Message.CopyDataStruct;
4711         GetMem(PC, CDS^.cbData);
4712         try
4713                 lstrcpy(PC,CDS^.lpData);
4714                 SetString(sURL, PC,lstrlen(PC));
4715                 MoveToURL(sURL);
4716         finally
4717                 FreeMem(PC);
4718         end;
4719         Message.Result := 1;
4720 end;
4721
4722 procedure TGikoForm.WndProc(var Message: TMessage);
4723 var
4724         senderBrowser   : TWebBrowser;
4725         url                                             : OleVariant;
4726 begin
4727         try
4728                 case Message.Msg of
4729                 CM_DIALOGCHAR:
4730                         if not (ssAlt in KeyDataToShiftState(TWMChar(Message).KeyData)) then
4731                                 Exit;
4732                 WM_SYSCOMMAND:
4733                         if Message.WParam = SC_MINIMIZE then begin
4734                                 OnMinimize;
4735                 PostMessage(Handle, USER_MINIMIZED, 0, 0);
4736             end;
4737                 USER_TREECLICK:
4738                         TreeClick( TreeView.Selected );
4739                 USER_RESIZED:
4740                         OnResized;
4741                 USER_MINIMIZED:
4742             begin
4743                 if (GikoSys.Setting.StoredTaskTray) then begin
4744                     StoredTaskTray;
4745                 end;
4746                 OnMinimized;
4747             end;
4748                 USER_SETLINKBAR:
4749                         SetLinkBar;
4750                 USER_DOCUMENTCOMPLETE:
4751                         if (Message.WParam <> 0) and
4752                                  (TObject(Message.WParam) is TWebBrowser) then begin
4753                                 senderBrowser := TWebBrowser( Message.WParam );
4754                                 BrowserDocumentComplete( senderBrowser, senderBrowser.Parent, url );
4755                         end;
4756                 end;
4757
4758                 inherited;
4759         except
4760         end;
4761 end;
4762
4763 procedure TGikoForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
4764 var
4765         handle: THandle;
4766 begin
4767         Handled := False;
4768         //\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Í
4769         //\83V\83\87\81[\83g\83J\83b\83g\82È\82Ç\82ð\96³\8cø\82É\82·\82é
4770         if ((FavoriteTreeView.Visible) and (FavoriteTreeView.IsEditing)) then begin
4771                 if Msg.CharCode in [VK_BACK] then begin
4772                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4773                         if Msg.KeyData > 0 then begin
4774                                 handle := GetFocus;
4775                                 if handle <> 0 then
4776                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4777                                 Handled := True;
4778                         end;
4779                 end else
4780                 //\82¨\8bC\82É\93ü\82è\82ÍESC\82Å\92E\8fo\82µ\82½\82¢\82Ì\82Å\81A\82»\82ê\82à\91\97\82é
4781                 if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_ESCAPE] then begin
4782                         handle := GetFocus;
4783                         if handle <> 0 then
4784                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4785                         Handled := True;
4786                 end;
4787         end     else if (AddressComboBox.Focused) or (SelectComboBox.Focused) then begin
4788                 if Msg.CharCode in [VK_BACK] then begin
4789                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4790                         if Msg.KeyData > 0 then begin
4791                                 handle := GetFocus;
4792                                 if handle <> 0 then
4793                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4794                                 Handled := True;
4795                         end;
4796                 end else if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT] then begin
4797                         handle := GetFocus;
4798                         if handle <> 0 then
4799                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4800                         Handled := True;
4801                 end;
4802         end else begin
4803                 Handled := GikoDM.GikoFormActionList.IsShortCut(Msg);
4804         end;
4805 end;
4806
4807 procedure TGikoForm.PreviewTimerTimer(Sender: TObject);
4808 var
4809         p: TPoint;
4810         ARect: TRect;
4811 begin
4812         PreviewTimer.Enabled := False;
4813
4814         GetCursorpos(p);
4815
4816     ARect := FPreviewBrowser.GetWindowRect(p);
4817
4818     FPreviewBrowser.PreviewImage(FPreviewURL);
4819
4820         if ARect.Bottom > Screen.DesktopHeight then begin
4821         OffsetRect(ARect, 0, -(ARect.Bottom - Screen.DesktopHeight));
4822     end;
4823         if (ARect.Right > Screen.DesktopWidth) then begin
4824         OffsetRect(ARect, -(ARect.Right - Screen.DesktopWidth), 0);
4825     end;
4826         if (ARect.Left < Screen.DesktopLeft) then begin
4827         OffsetRect(ARect, +(Screen.DesktopLeft - ARect.Left), 0);
4828     end;
4829         if (ARect.Top < Screen.DesktopTop) then begin
4830         OffsetRect(ARect, 0, (Screen.DesktopTop - ARect.Top));
4831     end;
4832
4833         SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST,
4834         ARect.Left, ARect.Top,
4835         (ARect.Right - ARect.Left), (ARect.Bottom - ARect.Top),
4836         SWP_NOACTIVATE or SWP_HIDEWINDOW);
4837
4838         ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);
4839         FPreviewBrowserRect := ARect;
4840 end;
4841
4842 procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
4843 var
4844         Pos : TPoint;
4845 begin
4846         if PreviewTimer.Enabled then
4847                 PreviewTimer.Enabled := False;
4848
4849         if (FResPopupBrowser <> nil) and (IsWindowVisible(FResPopupBrowser.Handle)) then begin
4850         FResPopupBrowser.Clear;
4851         end;
4852
4853         if (FPreviewBrowser <> nil)
4854                 and (IsWindowVisible(FPreviewBrowser.Handle)) then begin
4855         //\82±\82±\82Å\8fÁ\82³\82ê\82é\82Ì\82ª\96â\91è
4856         //\82½\82Ô\82ñ\82±\82ê\82Å\95\\8e¦\94Í\88Í\94»\92è\82Å\82«\82Ä\82¢\82é\82Í\82¸
4857                 Pos := Mouse.CursorPos;
4858                 Pos.X := Pos.X + Left;
4859                 Pos.Y := Pos.Y + Top;
4860                 if (FPreviewBrowserRect.Left > Pos.X) or
4861                         (FPreviewBrowserRect.Right < Pos.X) or
4862                         (FPreviewBrowserRect.Top > Pos.Y) or
4863                         (FPreviewBrowserRect.Bottom < Pos.Y) then begin
4864                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
4865                 end;
4866         end;
4867
4868         Message.Result := 1;
4869         inherited;
4870 end;
4871 procedure TGikoForm.MessageHideButtonClick(Sender: TObject);
4872 begin
4873         GikoDM.MsgBarCloseAction.Execute;
4874 end;
4875
4876 function TGikoForm.OnDocumentContextMenu(Sender: TObject): WordBool;
4877 var
4878         Doc: IHtmlDocument2;
4879         Range: IHTMLTxtRange;
4880         s: string;
4881         Num: Integer;
4882         ThreadItem: TThreadItem;
4883 begin
4884         Result := False;
4885         FactiveContent.IDAnchorPopup('');
4886         Doc := FactiveContent.Browser.Document as IHtmlDocument2;
4887         if Assigned(Doc) then begin
4888                 Range := Doc.selection.createRange as IHTMLTxtRange;
4889                 s := CustomStringReplace(Range.text, '\81@', ' ');//\91S\8ap\8bó\94\92\82ð\94¼\8ap\8bó\94\92\82É
4890                 s := ZenToHan(Trim(s));
4891                 if GikoSys.IsNumeric(s) then begin
4892                         Num := StrToInt64(s);
4893                         ThreadItem := GetActiveContent(true);
4894                         if (ThreadItem <> nil) and (Num <= ThreadItem.Count)
4895                 and (Num > 0)then begin
4896                 CreateResPopupBrowser;
4897                 FResPopupBrowser.CreateNewBrowser.PopupType := gptThread;
4898                                 HTMLCreater.SetResPopupText(FResPopupBrowser.CreateNewBrowser, ThreadItem, Num, Num, False, False);
4899                 FResPopupBrowser.Popup;
4900                                 Result := False;
4901                         end else
4902                                 Result := True;
4903                 end else begin
4904                         Result := True;
4905                 end;
4906         end;
4907 end;
4908
4909 procedure TGikoForm.HistoryAllClearToolButtonClick(Sender: TObject);
4910 const
4911         DEL_MSG = '\91S\97\9a\97ð\82ð\8dí\8f\9c\82µ\82Ü\82·\81B\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
4912         DEL_TITLE = '\8dí\8f\9c\8am\94F';
4913 begin
4914         if FTreeType = gttHistory then begin
4915                 if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then
4916                         if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then
4917                                 Exit;
4918                 FHistoryList.Clear;
4919                 TreeView.Items.Clear;
4920         end;
4921 end;
4922
4923 procedure TGikoForm.SetLinkBar;
4924 var
4925         i: Integer;
4926         j: Integer;
4927         ToolButton: TLinkToolButton;
4928         MenuItem: TMenuItem;
4929         oldIgnoreResize : TResizeType;
4930 begin
4931         oldIgnoreResize := FIsIgnoreResize;
4932         FIsIgnoreResize := rtResizing;
4933         MainCoolBar.Bands.BeginUpdate;
4934         try
4935                 LinkBarPopupMenu.Items.Clear;
4936                 for i := LinkToolBar.ButtonCount - 1 downto 0 do
4937                         //LinkToolBar.RemoveControl(LinkToolBar.Buttons[i]);
4938                         LinkToolBar.Buttons[i].Free;
4939                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
4940                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
4941                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
4942                                         ToolButton := TLinkToolButton.Create(LinkToolBar);
4943 //                    ToolButton.Parent := LinkToolBar;
4944                                         if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteFolder then begin
4945                                                 MenuItem := TMenuItem.Create(Self);
4946                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], MenuItem);
4947                                                 LinkBarPopupMenu.Items.Add(MenuItem);
4948                                                 ToolButton.MenuItem := MenuItem;
4949                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
4950                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteBoardItem then begin
4951                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
4952                                                 ToolButton.OnClick := FavoriteClick;
4953                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteThreadItem then begin
4954                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
4955                                                 ToolButton.OnClick := FavoriteClick;
4956                                         end;
4957                                         ToolButton.Caption := FavoriteTreeView.Items[i].Item[j].Text;
4958                                         ToolButton.Left := 10000;
4959                                         ToolButton.Data := FavoriteTreeView.Items[i].Item[j].Data;
4960                                         ToolButton.AutoSize := True;
4961                                         ToolButton.OnDragDrop := LinkToolButtonDragDrop;
4962                                         ToolButton.OnDragOver := FavoriteDragOver;
4963                                         ToolButton.OnMouseDown := LinkToolButtonOnMouseDown;
4964                                         ToolButton.OnMouseMove := LinkToolButtonOnMouseMove;
4965                                         ToolButton.OnMouseUp := LinkToolButtonOnMouseUp;
4966                                         ToolButton.OnStartDrag := LinkToolButtonStartDrag;
4967                                         //ToolButton.DragMode := dmAutomatic;
4968                                         ToolButton.DragMode := dmManual;
4969                                         ToolButton.PopupMenu := FavoriteTreePopupMenu;
4970
4971                                         LinkToolBar.InsertControl(ToolButton);
4972                                 end;
4973                                 break;
4974                         end;
4975                 end;
4976 {               if LinkToolBar.ButtonCount = 0 then begin
4977                         ToolButton := TLinkToolButton.Create(LinkToolBar);
4978                         ToolButton.Style := tbsButton;
4979                         ToolButton.ImageIndex := -1;
4980                         ToolButton.Caption := '';
4981                         LinkToolBar.InsertControl(ToolButton);
4982                 end;}
4983         finally
4984                 MainCoolBar.Bands.EndUpdate;
4985                 LoadCoolBarSettings;
4986                 FIsIgnoreResize := oldIgnoreResize;
4987         end;
4988 end;
4989
4990 procedure TGikoForm.FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
4991 var
4992         Node: TTreeNode;
4993         bound: TRect;
4994         height: Integer;
4995         Change: Boolean;
4996 begin
4997
4998         if Sender = FavoriteTreeView then begin
4999                 Node := FavoriteTreeView.GetNodeAt(X, Y);
5000
5001                 if Node = nil then
5002                         Exit;
5003
5004                 bound := Node.DisplayRect( False );
5005                 height := bound.Bottom - bound.Top;
5006                 if (bound.Top + height / 2) <= Y then
5007                         Node := FavoriteTreeView.GetNodeAt(X, Y + height);
5008
5009                 if Node = nil then
5010                         Exit;
5011
5012                 if Node.IsFirstNode then
5013                         Exit;
5014
5015                 Change := True;
5016
5017                 if FDropSpaceNode <> nil then
5018                         if FDropSpaceNode.AbsoluteIndex = Node.AbsoluteIndex then
5019                                 Change := False;
5020
5021                 if Change then begin
5022                         if FDropSpaceNode <> nil then
5023                                 FDropSpaceNode.Free;
5024
5025                         FDropSpaceNode := FavoriteDM.TreeView.Items.AddChildObjectFirst(Node.Parent, '', nil );
5026                         FDropSpaceNode.MoveTo( Node, naInsert );
5027                         FDropSpaceNode.ImageIndex := -1;
5028                         FDropSpaceNode.SelectedIndex := -1;
5029                 end;
5030         end;
5031
5032         if Source = FavoriteTreeView then begin
5033                 if FavoriteTreeView.Selected = FavoriteTreeView.Items.GetFirstNode then begin
5034                         Accept := False;
5035                         Exit;
5036                 end;
5037                 Accept := True;
5038         end else if Source = BrowserTab then
5039                 Accept := True
5040         else if Source = ListView then
5041                 Accept := True
5042         else if Source is TLinkToolButton then
5043                 Accept := True
5044         else if Source = TreeView then
5045                 Accept := True
5046         else
5047                 Accept := False;
5048 end;
5049
5050 procedure TGikoForm.FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5051 begin
5052
5053         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
5054
5055 end;
5056 procedure TGikoForm.LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
5057 begin
5058          //     FDragging := true;
5059 end;
5060
5061 procedure TGikoForm.LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
5062 var
5063         SenderNode: TTreeNode;
5064         LinkToolButton: TLinkToolButton;
5065 begin
5066
5067         LinkToolButton := TLinkToolButton( Sender );
5068         SenderNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
5069         SenderNode.Selected := False;
5070         FavoriteDragDrop( SenderNode, Source );
5071
5072         SetLinkBar;
5073
5074 end;
5075
5076 procedure TGikoForm.LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5077 var
5078         favButton                       : TLinkToolButton;
5079         favThreadItem   : TFavoriteThreadItem;
5080 begin
5081
5082         case Button of
5083         mbMiddle:
5084                 begin
5085                         if Sender is TLinkToolButton then begin
5086                                 favButton := TLinkToolButton( Sender );
5087                                 if TObject( favButton.Data ) is TFavoriteThreadItem then begin
5088                                         favThreadItem := TFavoriteThreadItem( favButton.Data );
5089                                         if favThreadItem.Item <> nil then
5090                                                 InsertBrowserTab( favThreadItem.Item, False );
5091                                 end;
5092                         end;
5093                 end;
5094         end;
5095
5096 end;
5097
5098 procedure TGikoForm.LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
5099 var
5100         Now : Cardinal;
5101 begin
5102         TToolButton( Sender ).DragMode := dmManual;
5103         if ssLeft in Shift then begin
5104 //              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)
5105                 if FDragTime = 0 then begin
5106                         FDragTime := GetTickCount();
5107                 end else begin
5108                         Now := GetTickCount();
5109                         if (Now - FDragTime) > 500 then begin
5110                                 if FDragButton <> TToolButton( Sender ) then begin
5111                                         try
5112                                                 FDragButton := TToolButton( Sender );
5113                                                 TToolButton(Sender).BeginDrag(false ,5);
5114                                                 FDragTime := 0;
5115                                         except
5116                                                 {$IF Defined(debug)}
5117                                                 ShowMessage('Error');
5118                                                 {$IFEND}
5119                                         end;
5120                                 end;
5121                         end;
5122                 end;
5123         end else begin
5124                 FDragTime := 0;
5125         end;
5126 end;
5127
5128 procedure TGikoForm.LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5129 begin
5130         FDragTime := 0;
5131 end;
5132
5133 function TGikoForm.GetWidthAllToolButton(ToolBar: TToolBar): Integer;
5134 var
5135         i: Integer;
5136 begin
5137         Result := 0;
5138         for i := 0 to ToolBar.ButtonCount - 1 do
5139                 if ToolBar.Buttons[i].Visible then
5140                         Result := Result + ToolBar.Buttons[i].Width;
5141 end;
5142
5143 procedure TGikoForm.MainCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5144 var
5145         Control : TWinControl;
5146         i, idx  : Integer;
5147 begin
5148         Control := FindControl(BandInfo^.hwndChild);
5149         if Control = nil then
5150                 Exit;
5151         idx := 0;
5152         for i := MainCoolBar.Bands.Count - 1 downto 0 do begin
5153                 if MainCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5154                         idx := MainCoolBar.Bands[ i ].ID;
5155                         Break;
5156                 end;
5157         end;
5158         Canvas.Font.Handle := GetStockObject( DEFAULT_GUI_FONT );
5159         if (Control = MenuToolBar) or (Control = StdToolBar) 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;
5164                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5165         end else if Control = LinkToolBar then begin
5166                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5167                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5168                 BandInfo^.cxMinChild    := 0;
5169                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83\8a\83\93\83N' );
5170                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5171         end else begin // AddressToolBar
5172                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5173                 BandInfo^.cxMinChild    := 0;
5174                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83A\83h\83\8c\83X' );
5175         end;
5176 end;
5177
5178 procedure TGikoForm.MainCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5179 var
5180         i : Integer;
5181         Idx: Integer;
5182         p: TPoint;
5183 begin
5184         ChevronPopupMenu.Items.Clear;
5185         Idx := 0;
5186         for i := 0 to MainCoolBar.Bands.Count - 1 do begin
5187                 if MainCoolBar.Bands[ i ].Visible then begin
5188                         if Idx = Int64(RebarChevron^.uBand) then begin
5189                                 Idx := i;
5190                                 break;
5191                         end;
5192                         Inc( Idx );
5193                 end;
5194         end;
5195         if (Idx >= 0) and (MainCoolBar.Bands.Count > Idx) then begin
5196                 if MainCoolBar.Bands[Idx].Control = MenuToolbar then begin
5197                         MenuBarChevronMenu;
5198                 end else if MainCoolBar.Bands[Idx].Control = StdToolbar then begin
5199                         ToolBarChevronMenu(StdToolBar);
5200                 end else if MainCoolBar.Bands[Idx].Control = LinkToolbar then begin
5201                         LinkBarChevronMenu;
5202                 end else
5203                         Exit;
5204                 p := MainCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5205                 ChevronPopupMenu.Popup(p.x, p.y);
5206         end;
5207 end;
5208
5209 procedure TGikoForm.MenuBarChevronMenu;
5210         procedure SetSubMenu(MenuItem: TMenuItem; PopupItem: TMenuItem);
5211         var
5212                 i: Integer;
5213                 Item: TMenuItem;
5214         begin
5215                 MenuItem.Click;
5216                 for i := 0 to MenuItem.Count - 1 do begin
5217 //                      Item := nil;
5218                         if MenuItem[i] is TFavoriteMenuItem then begin
5219                                 Item := TFavoriteMenuItem.Create(Self);
5220                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(MenuItem[i]).Data;
5221                         end else
5222                                 Item := TMenuItem.Create(Self);
5223                         Item.Caption := MenuItem[i].Caption;
5224                         Item.Action := MenuItem[i].Action;
5225                         Item.ImageIndex := MenuItem[i].ImageIndex;
5226                         Item.OnClick := MenuItem[i].OnClick;
5227                         PopupItem.Add(Item);
5228                         if MenuItem[i].Count > 0 then
5229                                 SetSubMenu(MenuItem[i], Item);
5230                 end;
5231         end;
5232 var
5233         i: Integer;
5234         w: Integer;
5235         bw: Integer;
5236         Item: TMenuItem;
5237 begin
5238         ChevronPopupMenu.Items.Clear;
5239         ChevronPopupMenu.Images := MainMenu.Images;
5240         bw := GetWidthAllToolButton(MenuToolBar);
5241         if MenuToolBar.Width < bw then begin
5242                 w := 0;
5243                 for i := 0 to MenuToolBar.ButtonCount - 1 do begin
5244                         w := w + MenuToolBar.Buttons[i].Width;
5245                         if MenuToolBar.Width <= w then begin
5246                                 Item := TMenuItem.Create(Self);
5247                                 Item.Caption := MenuToolBar.Buttons[i].MenuItem.Caption;
5248                                 //Item.Action := MenuToolBar.Buttons[i].MenuItem.Action;
5249                                 ChevronPopupMenu.Items.Add(Item);
5250                                 SetSubMenu(MenuToolbar.Buttons[i].MenuItem, Item);
5251                         end;
5252                 end;
5253         end;
5254 end;
5255
5256 procedure TGikoForm.ToolBarChevronMenu(ToolBar: TToolBar);
5257         procedure SetSubMenu(PopupMenu: TPopupMenu; PopupItem: TMenuItem);
5258         var
5259                 i: Integer;
5260                 Item: TMenuItem;
5261         begin
5262                 if Assigned(PopupMenu.OnPopup) then
5263                         PopupMenu.OnPopup(nil);
5264                 for i := 0 to PopupMenu.Items.Count - 1 do begin
5265 //                      Item := nil;
5266                         if PopupMenu.Items[i] is TFavoriteMenuItem then begin
5267                                 Item := TFavoriteMenuItem.Create(Self);
5268                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(PopupMenu.Items[i]).Data;
5269                         end else
5270                         Item := TMenuItem.Create(Self);
5271                         Item.Caption := PopupMenu.Items[i].Caption;
5272                         Item.Action := PopupMenu.Items[i].Action;
5273                         Item.ImageIndex := PopupMenu.Items[i].ImageIndex;
5274                         Item.OnClick := PopupMenu.Items[i].OnClick;
5275                         PopupItem.Add(Item);
5276                 end;
5277         end;
5278 var
5279         i: Integer;
5280         w: Integer;
5281         bw: Integer;
5282         Item: TMenuItem;
5283 begin
5284         ChevronPopupMenu.Items.Clear;
5285         ChevronPopupMenu.Images := ToolBar.HotImages;
5286         bw := GetWidthAllToolButton(ToolBar);
5287         if ToolBar.Width < bw then begin
5288                 w := 0;
5289                 for i := 0 to ToolBar.ButtonCount - 1 do begin
5290                         if ToolBar.Buttons[i].Visible then
5291                                 w := w + ToolBar.Buttons[i].Width;
5292                         if ToolBar.Width <= w then begin
5293                                 if ToolBar.Buttons[i].Tag = 0 then begin
5294                                         Item := TMenuItem.Create(Self);
5295                                         if ToolBar.Buttons[i].Style = tbsSeparator then
5296                                                 Item.Caption := '-'
5297                                         else begin
5298                                                 //\83X\83\8c\8di\8d\9e\82ÝComBox\82ÌTPanel\82ð\94r\8f\9c\82·\82é
5299                                                 if TObject(ToolBar.Buttons[i]) is TPanel then begin
5300                                                         Continue;
5301                                                 end else begin
5302                                                         Item.Caption := ToolBar.Buttons[i].Caption;
5303                                                         Item.Action := ToolBar.Buttons[i].Action;
5304                                                 end;
5305                                                 //Item.Visible := True;
5306                                         end;
5307                                         ChevronPopupMenu.Items.Add(Item);
5308                                         if ToolBar.Buttons[i].DropdownMenu <> nil then begin
5309                                                 Item.Action := nil;
5310                                                 Item.OnClick := nil;
5311                                                 SetSubMenu(ToolBar.Buttons[i].DropdownMenu, Item);
5312                                         end;
5313                                 end;
5314                         end;
5315                 end;
5316         end;
5317 end;
5318
5319 procedure TGikoForm.LinkBarChevronMenu;
5320 var
5321         i: Integer;
5322         j: Integer;
5323         w: Integer;
5324         Item: TFavoriteMenuItem;
5325         bw: Integer;
5326         Button: TLinkToolButton;
5327 begin
5328         ChevronPopupMenu.Items.Clear;
5329         ChevronPopupMenu.Images := LinkToolBar.Images;
5330         bw := GetWidthAllToolButton(LinkToolBar);
5331         if LinkToolBar.Width < bw then begin
5332                 w := 0;
5333                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5334                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5335                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5336                                         w := w + LinkToolBar.Buttons[j].Width;
5337                                         if LinkToolBar.Width <= w then begin
5338                                                 if LinkToolBar.Buttons[j] is TLinkToolButton then begin
5339                                                         Button := TLinkToolButton(LinkToolBar.Buttons[j]);
5340                                                         Item := TFavoriteMenuItem.Create(Self);
5341                                                         if TObject(Button.Data) is TFavoriteFolder then begin
5342                                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], Item);
5343                                                         end else if TObject(Button.Data) is TFavoriteBoardItem then begin
5344                                                                 Item.OnClick := FavoriteClick;
5345                                                         end else if TObject(Button.Data) is TFavoriteThreadItem then begin
5346                                                                 Item.OnClick := FavoriteClick;
5347                                                         end;
5348                                                         Item.Data := Button.Data;
5349                                                         Item.Caption := LinkToolBar.Buttons[j].Caption;
5350                                                         Item.ImageIndex := LinkToolBar.Buttons[j].ImageIndex;
5351                                                         ChevronPopupMenu.Items.Add(Item);
5352                                                 end;
5353                                         end;
5354                                 end;
5355                                 break;
5356                         end;
5357                 end;
5358         end;
5359 end;
5360
5361 {!
5362 \brief  \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
5363 \param  bar             \83o\83\93\83h\82ª\8f\8a\91®\82·\82é CoolBar
5364 \param  band    \8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é\83o\83\93\83h
5365
5366 \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É
5367 \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
5368 }
5369 procedure TGikoForm.ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
5370 var
5371         bandInfo        : tagREBARBANDINFOA;
5372         pBandInfo       : PReBarBandInfoA;
5373         lResult         : Integer;
5374         h                                       : HWND;
5375         i, idx          : Integer;
5376 begin
5377
5378         h                                                                               := band.Handle;
5379         pBandInfo := @bandInfo;
5380         ZeroMemory( pBandInfo, sizeof( bandInfo ) );
5381         bandInfo.cbSize                 := sizeof( bandInfo );
5382         bandInfo.hwndChild      := h;
5383         bandInfo.cyMinChild     := bar.Height;
5384         bar.OnBandInfo( nil, pBandInfo );
5385         // band \82Ì\83C\83\93\83f\83b\83N\83X\82ð\92T\82·
5386         idx := 0;
5387         for i := bar.Bands.Count - 1 downto 0 do begin
5388                 if bar.Bands[ i ].Control.Handle = h then begin
5389                         idx := i;
5390                         Break;
5391                 end;
5392         end;
5393         // \90Ý\92è
5394         lResult := SendMessage( bar.Handle, RB_SETBANDINFO, idx, Integer( pBandInfo ) );
5395
5396 end;
5397
5398 procedure TGikoForm.ListCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5399 var
5400         Control: TWinControl;
5401         i, idx  : Integer;
5402 begin
5403         Control := FindControl(BandInfo^.hwndChild);
5404         if Control = nil then
5405                 Exit;
5406         idx := 0;
5407         for i := ListCoolBar.Bands.Count - 1 downto 0 do begin
5408                 if ListCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5409                         idx := ListCoolBar.Bands[ i ].ID;
5410                         Break;
5411                 end;
5412         end;
5413         if Control = ListToolBar then begin
5414                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5415                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5416                 BandInfo^.cxMinChild    := 0;
5417                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5418                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5419         end else begin
5420                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5421                 BandInfo^.cxMinChild    := 0;
5422                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5423         end;
5424 end;
5425
5426 procedure TGikoForm.ListCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5427 var
5428         Idx: Integer;
5429         p: TPoint;
5430 begin
5431         ChevronPopupMenu.Items.Clear;
5432         Idx := RebarChevron^.uBand;
5433         if (Idx >= 0) and (ListCoolBar.Bands.Count > Idx) then begin
5434                 if ListCoolBar.Bands[Idx].Control = ListToolBar then begin
5435                         ToolBarChevronMenu(ListToolBar);
5436                 end else
5437                         Exit;
5438                 p := ListCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5439                 ChevronPopupMenu.Popup(p.x, p.y);
5440         end;
5441 end;
5442
5443 procedure TGikoForm.BrowserCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5444 var
5445         Control: TWinControl;
5446         i, idx  : Integer;
5447 begin
5448         Control := FindControl(BandInfo^.hwndChild);
5449         if Control = nil then
5450                 Exit;
5451         idx := 0;
5452         for i := BrowserCoolBar.Bands.Count - 1 downto 0 do begin
5453                 if BrowserCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5454                         idx := BrowserCoolBar.Bands[ i ].ID;
5455                         Break;
5456                 end;
5457         end;
5458         if Control = BrowserToolBar then begin
5459                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5460                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5461                 BandInfo^.cxMinChild    := 0;
5462                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5463                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5464         end else begin
5465                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5466                 BandInfo^.cxMinChild    := 0;
5467                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5468         end;
5469 end;
5470
5471 procedure TGikoForm.BrowserCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5472 var
5473         Idx: Integer;
5474         p: TPoint;
5475 begin
5476         ChevronPopupMenu.Items.Clear;
5477         Idx := RebarChevron^.uBand;
5478         if (Idx >= 0) and (BrowserCoolBar.Bands.Count > Idx) then begin
5479                 if BrowserCoolBar.Bands[Idx].Control = BrowserToolBar then
5480                         ToolBarChevronMenu(BrowserToolBar)
5481                 else
5482                         Exit;
5483                 p := BrowserCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5484                 ChevronPopupMenu.Popup(p.x, p.y);
5485         end;
5486 end;
5487
5488 procedure TGikoForm.ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
5489 begin
5490         if Column^.iImage = -1 then begin
5491                 Column^.mask := Column^.mask or LVCF_FMT;
5492         end else begin
5493                 Column^.mask := Column^.mask or LVCF_FMT or LVCF_IMAGE;
5494                 Column^.fmt := Column^.fmt or LVCFMT_IMAGE or LVCFMT_BITMAP_ON_RIGHT;
5495         end;
5496 end;
5497
5498 function TGikoForm.FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
5499 var
5500         i : Integer;
5501 begin
5502         Result := nil;
5503         for i := bar.ButtonCount - 1 downto 0 do begin
5504                 if bar.Buttons[ i ].Action = action then begin
5505                         Result := bar.Buttons[ i ];
5506                         Break;
5507                 end;
5508         end;
5509 end;
5510
5511 procedure TGikoForm.SetToolBarPopup;
5512 var
5513         i                                                                       : Integer;
5514         aIEButton                                       : TToolButton;
5515         aCabinetBBSButton       : TToolButton;
5516         aResRangeButton         : TToolButton;
5517         aThreadRangeButton:     TToolButton;
5518 begin
5519         for i := 0 to StdToolBar.ButtonCount - 1 do begin
5520         end;
5521         for i := 0 to ListToolBar.ButtonCount - 1 do begin
5522                 if ListToolBar.Buttons[i].Action = GikoDM.IconStyle then
5523                         ListToolBar.Buttons[i].DropdownMenu := ListIconPopupMenu;
5524                 if ListToolBar.Buttons[i].Action = GikoDM.SelectReservAction then
5525                         ListToolBar.Buttons[i].DropdownMenu := RoundNamePopupMenu;
5526         end;
5527         aIEButton                                       := FindToolBarButton( BrowserToolBar, GikoDM.IEAction );
5528         if aIEButton <> nil then
5529                 aIEButton.DropdownMenu                                  := BrowserPopupMenu;
5530         aCabinetBBSButton       := FindToolBarButton( StdToolBar, GikoDM.CabinetBBSAction );
5531         if aCabinetBBSButton <> nil then
5532                 aCabinetBBSButton.DropdownMenu  := BBSSelectPopupMenu;
5533         aResRangeButton         := FindToolBarButton( BrowserToolBar, GikoDM.ResRangeAction );
5534         if aResRangeButton <> nil then
5535                 aResRangeButton.DropdownMenu            := ResRangePopupMenu;
5536         aThreadRangeButton:= FindToolBarButton( ListToolBar, GikoDM.ThreadRangeAction );
5537         if aThreadRangeButton <> nil then
5538                 aThreadRangeButton.DropdownMenu := ThreadRangePopupMenu;
5539 end;
5540
5541 procedure TGikoForm.FormMouseWheel(Sender: TObject; Shift: TShiftState;
5542         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
5543 var
5544         Wnd: THandle;
5545         delta: Integer;
5546 //      browserPos : TPoint;
5547 const
5548         ICON_SIZE = 16;
5549 begin
5550         Wnd := WindowFromPoint(Mouse.CursorPos);
5551         Handled := True;
5552         if WheelDelta > 0 then
5553                 Delta := -1
5554         else
5555                 Delta := 1;
5556
5557         if (Wnd = BrowserTab.Handle) or
5558                  (Wnd = BrowserTab.Parent.Handle) then begin
5559                 BrowserTab.ScrollTabs(Delta);
5560         end else begin
5561                 if FIsHandledWheel then begin
5562                         FIsHandledWheel := False;
5563                         Handled := False;
5564                 end else begin
5565                         FIsHandledWheel := True;
5566                         if (Wnd = TreeView.Handle) or  (Wnd = FavoriteTreeView.Handle)
5567                         or (Wnd = ListView.Handle) or (Wnd = MessageListView.Handle)
5568                         then
5569                                 SendMessage( Wnd, WM_MOUSEWHEEL, WheelDelta shl 16, (Mouse.CursorPos.X shl 16) or Mouse.CursorPos.Y )
5570                         else
5571                                 Handled := False;
5572
5573                 end;
5574         end;
5575 end;
5576
5577 procedure TGikoForm.SetSelectWord( const text : string );
5578 begin
5579         // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
5580         ClearThreadRengeAction;
5581
5582         if Length( text ) = 0 then
5583         begin
5584                 GikoDM.AllItemAction.Checked := True;
5585                 SetListViewType( gvtAll )
5586         end else begin
5587                 SetListViewType( gvtUser, text, false );
5588         end;
5589 end;
5590
5591 procedure TGikoForm.SelectComboBoxChange(Sender: TObject);
5592 begin
5593
5594         SetSelectWord( SelectComboBox.Text );
5595
5596 end;
5597
5598 procedure TGikoForm.SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
5599         Shift: TShiftState);
5600 var
5601   IMC: HIMC;
5602   Len: integer;
5603   Str: string;
5604   tmp: string;
5605 begin
5606
5607         if Key = VK_Return then
5608         begin
5609                 ModifySelectList;
5610         end else if Key = 229 then begin
5611                 if GikoSys.Setting.UseUndecided then begin
5612                         IMC := ImmGetContext(SelectComboBox.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
5613                         Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5614                         SetLength(Str, Len + 1); //Buffer\82Ì\83\81\83\82\83\8a\82ð\90Ý\92è
5615                         ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5616                         ImmReleaseContext(SelectComboBox.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
5617                         SetLength(Str, Len);
5618                         if SelectComboBox.SelLength > 0 then begin //\91I\91ð\92\86\82Ì\95\8e\9a\97ñ\82ª\82 \82é\82©
5619                                 tmp := Copy(SelectComboBox.Text, 1, SelectComboBox.SelStart);
5620                                 Str := tmp + Str + Copy(SelectComboBox.Text, SelectComboBox.SelStart + SelectComboBox.SelLength + 1, Length(SelectComboBox.Text));
5621                         end else
5622                                 Str := SelectComboBox.Text + Str;
5623
5624                         if (Length(Str) > 0) then begin
5625                                 SetSelectWord(Str);
5626                         end;
5627                 end;
5628         end else if Length( SelectComboBox.Text ) = 0 then
5629         begin
5630                 {* SelectComboBox.Text\82ª\8bó\82Å\82à\81A\93ü\97Í\93r\92\86\82ÅEsc\82µ\82½\82Æ\82©
5631                  * \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
5632                  * \81i\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢\81j
5633                  *}
5634         end else begin
5635         // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
5636                 ClearThreadRengeAction;
5637         end;
5638
5639 end;
5640 //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
5641 procedure TGikoForm.ClearThreadRengeAction;
5642 begin
5643         // \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é
5644         if GikoDM.AllItemAction.Checked then
5645                 GikoDM.AllItemAction.Checked := False;
5646         if GikoDM.LogItemAction.Checked then
5647                 GikoDM.LogItemAction.Checked := False;
5648         if GikoDM.NewItemAction.Checked then
5649                 GikoDM.NewItemaction.Checked := False;
5650         if GikoDM.LiveItemAction.Checked then
5651                 GikoDM.LiveItemAction.Checked := False;
5652         if GikoDM.ArchiveItemAction.Checked then
5653                 GikoDM.ArchiveItemAction.Checked := False;
5654
5655 end;
5656
5657 procedure TGikoForm.SelectComboBoxExit(Sender: TObject);
5658 begin
5659
5660         ModifySelectList;
5661
5662         if Length( SelectComboBox.Text ) = 0 then
5663         begin
5664                 SelectComboBox.Text := GikoDataModule.SELECTCOMBOBOX_NAME;
5665                 SelectComboBox.Color := GikoDataModule.SELECTCOMBOBOX_COLOR;
5666         end;
5667
5668 end;
5669
5670 // \8di\82è\8d\9e\82Ý\8c\9f\8dõ\82Ì\97\9a\97ð\8dX\90V
5671 procedure TGikoForm.ModifySelectList;
5672 var
5673         idx : Integer;
5674         oldText : string;
5675 begin
5676
5677         try
5678                 if not SelectComboBoxPanel.Visible then
5679                         exit;
5680
5681                 if Length( SelectComboBox.Text ) > 0 then
5682                 begin
5683                         oldText := SelectComboBox.Text;
5684                         idx := GikoSys.Setting.SelectTextList.IndexOf( oldText );
5685                         if idx <> -1 then
5686                                 GikoSys.Setting.SelectTextList.Delete( idx );
5687                         idx := SelectComboBox.Items.IndexOf( oldText );
5688                         if idx <> -1 then
5689                                 SelectComboBox.Items.Delete( idx );
5690                         GikoSys.Setting.SelectTextList.Insert( 0, oldText );
5691                         SelectComboBox.Items.Insert( 0, oldText );
5692                         SelectComboBox.Text := oldText;
5693                 end;
5694         except
5695         end;
5696
5697 end;
5698
5699
5700 procedure TGikoForm.SelectComboBoxSplitterMouseMove(Sender: TObject;
5701         Shift: TShiftState; X, Y: Integer);
5702 var
5703         pos                             : TPoint;
5704         w                                       : Integer;
5705 begin
5706         If (SelectComboBoxPanel.Visible) and (IsDraggingSelectComboBox) Then begin
5707                 pos.X := X;
5708                 pos.Y := Y;
5709                 pos := SelectComboBoxSplitter.ClientToScreen( pos );
5710                 //w := SelectComboBox.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5711                 w := SelectComboBoxPanel.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5712
5713                 If w <= 50 Then Begin
5714                         // \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­
5715                         // \81u\8e~\82Ü\82Á\82½(50pixel)\88Ê\92u\81v\82É\82È\82é\82æ\82¤\82É
5716                         pos.X := pos.X + (50 - w);
5717
5718                         // \8f¬\82³\82­\82È\82è\82·\82¬\82È\82¢\82æ\82¤\82É
5719                         w := 50;
5720                 End;
5721
5722                 // \83`\83\89\82Â\82«\8cy\8c¸\82Ì\88×
5723                 //If SelectComboBox.Width <> w Then Begin
5724                 If SelectComboBoxPanel.Width <> w Then Begin
5725                         SelectComboBoxPanel.Width := w;
5726                         SelectComboBox.Width := SelectComboBoxPanel.Width - SelectComboBoxSplitter.Width;
5727                         GikoSys.Setting.SelectComboBoxWidth := w;
5728                         DraggingSelectComboBoxPosition := pos;
5729
5730                         // \83V\83F\83u\83\8d\83\93\88Ê\92u\82ª\95Ï\82í\82é\82Ì\82Å BandInfo \82Ì\8dÄ\90Ý\92è
5731                         ResetBandInfo( ListCoolBar, ListToolBar );
5732                 End;
5733         End;
5734
5735 end;
5736
5737 procedure TGikoForm.SelectComboBoxSplitterMouseDown(Sender: TObject;
5738         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5739 var
5740         pos : TPoint;
5741 begin
5742         IsDraggingSelectComboBox := True;
5743         pos.X := X;
5744         pos.Y := Y;
5745         DraggingSelectComboBoxPosition := SelectComboBoxSplitter.ClientToScreen( pos );
5746
5747 end;
5748
5749 procedure TGikoForm.SelectComboBoxSplitterMouseUp(Sender: TObject;
5750         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5751 begin
5752         IsDraggingSelectComboBox := False;
5753
5754 end;
5755
5756 procedure TGikoForm.StatusBarResize(Sender: TObject);
5757 begin
5758         StatusBar.Panels[1].Width := StatusBar.Width -
5759                                         StatusBar.Panels[0].Width -
5760                                         StatusBar.Panels[THREADSIZE_PANEL].Width -
5761                                         StatusBar.Panels[NGWORDNAME_PANEL].Width;
5762 end;
5763 procedure TGikoForm.SelectComboBoxEnter(Sender: TObject);
5764 begin
5765
5766         if (Length( SelectComboBox.Text ) = 0) or
5767                 (SelectComboBox.Text = GikoDataModule.SELECTCOMBOBOX_NAME) then
5768         begin
5769                 SelectComboBox.Text := '';
5770                 SelectComboBox.Color := clWindow;
5771         end;
5772
5773 end;
5774
5775 procedure TGikoForm.FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
5776 begin
5777
5778         if (SenderNode = nil) or (SourceNode = nil) or (SenderNode = SourceNode) then
5779                 Exit;
5780
5781         if TObject(SenderNode.Data) is TFavoriteFolder then
5782                 SourceNode.MoveTo(SenderNode, naAddChild)
5783         else
5784                 SourceNode.MoveTo(SenderNode, naInsert);
5785
5786 end;
5787
5788 procedure TGikoForm.FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
5789 var
5790         Node: TTreeNode;
5791         FavNode: TTreeNode;
5792         FavoBoardItem: TFavoriteBoardItem;
5793         FavoThreadItem: TFavoriteThreadItem;
5794         Board: TBoard;
5795         ThreadItem: TThreadItem;
5796 begin
5797
5798         if (SenderNode = nil) or (Source = nil) then
5799                 Exit;
5800
5801         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
5802                 FavNode := SenderNode.Parent
5803         else
5804                 FavNode := SenderNode;
5805
5806         Node := nil;
5807
5808         if Source is TBoard then begin
5809                 Board := TBoard( Source );
5810                 FavoBoardItem                           := TFavoriteBoardItem.CreateWithItem( Board );
5811                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, FavoBoardItem);
5812                 Node.ImageIndex := 15;
5813                 Node.SelectedIndex := 15;
5814         end else if Source is TFavoriteBoardItem then begin
5815                 FavoBoardItem := TFavoriteBoardItem( Source );
5816                 Board := FavoBoardItem.Item;
5817                 if Board <> nil then
5818                         if not Board.IsThreadDatRead then
5819                                 GikoSys.ReadSubjectFile(Board);
5820                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, Source);
5821                 Node.ImageIndex := 15;
5822                 Node.SelectedIndex := 15;
5823         end else if Source is TThreadItem then begin
5824                 ThreadItem := TThreadItem( Source );
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 TBrowserRecord then begin
5830                 ThreadItem := TBrowserRecord( Source ).Thread;
5831                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
5832                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
5833                 Node.ImageIndex := 16;
5834                 Node.SelectedIndex := 16;
5835         end else if Source is TFavoriteThreadItem then begin
5836                 FavoThreadItem := TFavoriteThreadItem( Source );
5837                 ThreadItem := FavoThreadItem.Item;
5838                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, Source);
5839                 Node.ImageIndex := 16;
5840                 Node.SelectedIndex := 16;
5841         end;
5842
5843         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
5844                 if Node <> nil then
5845                         FavoriteMoveTo( SenderNode, Node );
5846
5847 end;
5848
5849 procedure TGikoForm.FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
5850 var
5851         idx: Integer;
5852         SourceNode: TTreeNode;
5853         LinkToolButton: TLinkToolButton;
5854 begin
5855
5856         if SenderNode = nil then
5857                 Exit;
5858
5859         if not (TObject( SenderNode.Data ) is TFavoriteFolder) then
5860                 if FDropSpaceNode <> nil then
5861                         SenderNode := FDropSpaceNode;
5862
5863         if Source = FavoriteTreeView then begin
5864                 SourceNode := FavoriteTreeView.Selected;
5865                 FavoriteMoveTo( SenderNode, SourceNode );
5866         end else if Source is TLinkToolButton then begin
5867                 LinkToolButton := TLinkToolButton( Source );
5868                 SourceNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
5869                 FavoriteMoveTo( SenderNode, SourceNode );
5870         end else if Source = BrowserTab then begin
5871                 idx := BrowserTab.TabIndex;
5872                 FavoriteAddTo( SenderNode, BrowserTab.Tabs.Objects[idx] );
5873         end else if Source = ListView then begin
5874                 FavoriteAddTo( SenderNode, ListView.Selected.Data );
5875         end else if Source = TreeView then begin
5876                 FavoriteAddTo( SenderNode, TreeView.Selected.Data );
5877         end;
5878 end;
5879
5880 procedure TGikoForm.FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
5881         Y: Integer);
5882 var
5883         SenderNode: TTreeNode;
5884 begin
5885
5886         SenderNode := FavoriteTreeView.GetNodeAt(X, Y);
5887         if SenderNode <> nil then begin
5888                 FavoriteDragDrop( SenderNode, Source );
5889         end;
5890
5891         //\8bó\94\92\8d\80\96Ú\82ª\82¢\82½\82ç\8dí\8f\9c\82·\82é
5892         if FDropSpaceNode <> nil then begin
5893                 try
5894                         FDropSpaceNode.Delete;
5895                 finally
5896                         FDropSpaceNode := nil;
5897                 end;
5898         end;
5899         //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
5900         FavoriteDM.Modified := true;
5901
5902         SetLinkBar;
5903
5904 end;
5905
5906 procedure TGikoForm.FavoriteTreeViewEdited(Sender: TObject;
5907         Node: TTreeNode; var S: String);
5908 begin
5909         //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
5910         FavoriteDM.Modified := true;
5911
5912         FavoriteTreeView.ReadOnly := True;
5913         SetLinkBar;
5914
5915 end;
5916
5917 procedure TGikoForm.FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
5918         Shift: TShiftState);
5919 begin
5920         if not TTreeView(Sender).IsEditing then begin
5921                 Case Key of
5922                 VK_F2:
5923                         begin
5924                                 FClickNode := FavoriteTreeView.Selected;
5925                                 GikoDM.FavoriteTreeViewRenameActionExecute( Sender );
5926                         end;
5927                 VK_DELETE:
5928                         begin
5929                                 FClickNode := FavoriteTreeView.Selected;
5930                                 GikoDM.FavoriteTreeViewDeleteActionExecute( Sender );
5931                         end;
5932                 VK_RETURN:
5933                         begin
5934                         FavoriteClick( FavoriteTreeView.Selected );
5935                         FavoriteTreeView.Selected.Expanded := not FavoriteTreeView.Selected.Expanded;
5936                         end;
5937                 VK_SPACE:
5938                         begin
5939                         FClickNode := FavoriteTreeView.Selected;
5940                         GikoDM.FavoriteTreeViewReloadActionExecute( Sender );
5941                         end;
5942                 end;
5943         end else begin
5944                 //\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·
5945                 if Key = VK_ESCAPE then begin
5946                         if (TTreeView(Sender).Selected <> nil) then begin
5947                                 TTreeView(Sender).Selected.Text := FOrigenCaption;
5948                         end;
5949                         TTreeView(Sender).Selected.Focused := False;
5950                 end;
5951         end;
5952
5953 end;
5954
5955 procedure TGikoForm.FavoriteTreePopupMenuPopup(Sender: TObject);
5956 var
5957         i: Integer;
5958         LinkToolButton: TLinkToolButton;
5959 begin
5960
5961         if FavoriteTreePopupMenu.PopupComponent = FavoriteTreeView then begin
5962         
5963                 FClickNode := FavoriteTreeView.Selected;
5964
5965         end else if FavoriteTreePopupMenu.PopupComponent is TLinkToolButton then begin
5966
5967                 LinkToolButton := TLinkToolButton( FavoriteTreePopupMenu.PopupComponent );
5968                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5969                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5970                                 FClickNode := FavoriteTreeView.Items[i];
5971                                 Break;
5972                         end;
5973                 end;
5974                 for i := 0 to FClickNode.Count - 1 do begin
5975                         if FClickNode.Item[i].Data = LinkToolButton.Data then begin
5976                                 FClickNode := FClickNode.Item[i];
5977                                 Break;
5978                         end;
5979                 end;
5980
5981         end;
5982
5983         if FClickNode = nil then begin
5984                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
5985                 FavoriteTreeDeletePopupMenu.Visible := False;
5986                 FavoriteTreeRenamePopupMenu.Visible := False;
5987                 FavoriteTreeNewFolderPopupMenu.Visible := False;
5988                 FavoriteTreeURLCopyPopupMenu.Visible := False;
5989                 FavoriteTreeNameCopyPopupMenu.Visible := False;
5990                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
5991                 FavoriteTreeReloadPopupMenu.Visible := False;
5992                 FavoriteTreeLogDeletePopupMenu.Visible := False;
5993                 FavoriteTreeItemNameCopyPopupMenu.Visible := False;
5994         end else if FClickNode.IsFirstNode then begin
5995                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
5996                 FavoriteTreeDeletePopupMenu.Visible := False;
5997                 FavoriteTreeRenamePopupMenu.Visible := False;
5998                 FavoriteTreeNewFolderPopupMenu.Visible := True;
5999                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6000                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6001                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6002                 FavoriteTreeReloadPopupMenu.Visible := False;
6003                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6004                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6005         end else if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
6006                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6007                 FavoriteTreeDeletePopupMenu.Visible := True;
6008                 FavoriteTreeRenamePopupMenu.Visible := False;
6009                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6010                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6011                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6012                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6013                 FavoriteTreeReloadPopupMenu.Visible := False;
6014                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6015                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6016         end else if TObject(FClickNode.Data) is TFavoriteFolder then begin
6017                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6018                 FavoriteTreeDeletePopupMenu.Visible := True;
6019                 FavoriteTreeRenamePopupMenu.Visible := True;
6020                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6021                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6022                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6023                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6024                 FavoriteTreeReloadPopupMenu.Visible := False;
6025                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6026                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6027         end else if TObject(FClickNode.Data) is TFavoriteThreadItem then begin
6028                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6029                 FavoriteTreeDeletePopupMenu.Visible := True;
6030                 FavoriteTreeRenamePopupMenu.Visible := True;
6031                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6032                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6033                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6034                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6035                 FavoriteTreeReloadPopupMenu.Visible := True;
6036                 FavoriteTreeLogDeletePopupMenu.Visible := True;
6037                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6038         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
6039                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6040                 FavoriteTreeDeletePopupMenu.Visible := True;
6041                 FavoriteTreeRenamePopupMenu.Visible := True;
6042                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6043                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6044                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6045                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6046                 FavoriteTreeReloadPopupMenu.Visible := True;
6047                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6048                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6049         end else begin
6050                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6051                 FavoriteTreeDeletePopupMenu.Visible := False;
6052                 FavoriteTreeRenamePopupMenu.Visible := False;
6053                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6054                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6055                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6056                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6057                 FavoriteTreeReloadPopupMenu.Visible := False;
6058                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6059                 FavoriteTreeItemNameCopyPopupMenu.Visible := False;
6060         end;
6061
6062 end;
6063
6064 procedure TGikoForm.FavoriteBrowseFolder( node: TTreeNode );
6065 var
6066         i: Integer;
6067 begin
6068
6069         if not (TObject(node.Data) is TFavoriteFolder) then
6070                 exit;
6071
6072         for i := 0 to node.Count - 1 do
6073         begin
6074                 if TObject(node.Item[i].Data) is TFavoriteFolder then
6075                         FavoriteBrowseFolder( node.Item[i] )
6076                 else if TObject(node.Item[i].Data) is TFavoriteThreadItem then
6077                         FavoriteClick( node.Item[i], False );
6078         end;
6079
6080 end;
6081 function TGikoForm.TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
6082 var
6083         Found: TTreeNode;
6084         i: Integer;
6085 begin
6086
6087         for i := 0 to Node.Count - 1 do begin
6088                 if Node.Item[i].Data = FindPointer then begin
6089                         Result := Node.Item[i];
6090                         Exit;
6091                 end else if Node.Item[i].Count > 0 then begin
6092                         Found := TreeNodeDataFind( Node.Item[i], FindPointer );
6093                         if Found <> nil then begin
6094                                 Result := Found;
6095                                 Exit;
6096                         end;
6097                 end;
6098         end;
6099
6100         Result := nil;
6101
6102 end;
6103
6104 procedure TGikoForm.LinkToolBarDragDrop(Sender, Source: TObject; X,
6105         Y: Integer);
6106 var
6107         i: Integer;
6108         SenderNode: TTreeNode;
6109 begin
6110
6111         SenderNode := nil;
6112         for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6113                 if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6114                         SenderNode := FavoriteTreeView.Items[i];
6115                         Break;
6116                 end;
6117         end;
6118         SenderNode.Selected := False;
6119         
6120         FavoriteDragDrop( SenderNode, Source );
6121
6122         SetLinkBar;
6123 end;
6124
6125 procedure TGikoForm.BrowserTabMouseUp(Sender: TObject;
6126         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6127 begin
6128         if FDragWFirst = true then
6129                 FDragWFirst := false;
6130
6131     if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6132         if GikoSys.Setting.ListWidthState = glsMin then begin
6133             GikoDM.BrowserMaxAndFocusAction.Execute;
6134         end;
6135     end else begin
6136         if GikoSys.Setting.ListHeightState = glsMin then begin
6137             GikoDM.BrowserMaxAndFocusAction.Execute;
6138         end;
6139     end;
6140 end;
6141
6142 procedure TGikoForm.LinkToolBarDragOver(Sender, Source: TObject; X,
6143         Y: Integer; State: TDragState; var Accept: Boolean);
6144 begin
6145
6146         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
6147
6148 end;
6149
6150 procedure TGikoForm.FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
6151         Y: Integer);
6152 begin
6153
6154         if FDropSpaceNode <> nil then begin
6155                 try
6156                         FDropSpaceNode.Delete;
6157                 finally
6158                         FDropSpaceNode := nil;
6159                 end;
6160                 //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
6161                 FavoriteDM.Modified := true;
6162                 SetLinkBar;
6163         end;
6164
6165 end;
6166
6167 procedure TGikoForm.SetListViewBackGroundColor(value: TColor);
6168 begin
6169         if FListViewBackGroundColor <> value then begin
6170                 FListViewBackGroundColor := value;
6171                 ListView.Color := FListViewBackGroundColor;
6172         end;
6173 end;
6174 procedure TGikoForm.FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
6175 var
6176         threadItem      : TThreadItem;
6177         boardItem               : TBoard;
6178 begin
6179
6180         if FClickNode = nil then Exit;
6181
6182         if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
6183
6184                 threadItem := TFavoriteThreadItem( FClickNode.Data ).Item;
6185                 if threadItem = nil then
6186                         Exit;
6187                 GikoSys.OpenBrowser( threadItem.ParentBoard.URL, gbtAuto );
6188
6189         end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin
6190
6191                 boardItem := TFavoriteBoardItem( FClickNode.Data ).Item;
6192                 if boardItem = nil then
6193                         Exit;
6194                 GikoSys.OpenBrowser( boardItem.URL, gbtAuto );
6195
6196         end;
6197
6198 end;
6199
6200 procedure TGikoForm.BrowserTabContextPopup(Sender: TObject;
6201         MousePos: TPoint; var Handled: Boolean);
6202 var
6203         idx : Integer;
6204 begin
6205                 idx := BrowserTab.IndexOfTabAt(MousePos.X, MousePos.Y);
6206                 if BrowserTab.TabIndex <> idx then begin
6207                 BrowserTab.TabIndex := idx;
6208                         BrowserTab.OnChange(nil);
6209                 end;
6210 end;
6211
6212 procedure TGikoForm.KonoresCopy(Number: Integer; ReplaceTag : Boolean);
6213 var
6214         ThreadItem: TThreadItem;
6215         tmp: string;
6216         FileName: string;
6217         Res: TResRec;
6218         Header: string;
6219         Body: string;
6220         boardPlugIn : TBoardPlugIn;
6221 begin
6222         if Number = 0 then Exit;
6223         ThreadItem := GetActiveContent(True);
6224
6225         if ThreadItem <> nil then begin
6226                 //if ThreadItem.IsBoardPlugInAvailable then begin
6227         if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6228                         //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
6229                         //boardPlugIn           := ThreadItem.BoardPlugIn;
6230             boardPlugIn         := ThreadItem.ParentBoard.BoardPlugIn;
6231
6232                         // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
6233                         // \95\8e\9a\83R\81[\83h\82Í\83v\83\89\83O\83C\83\93\82É\94C\82¹\82é
6234                         //\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
6235                         tmp := boardPlugIn.GetDat( DWORD( threadItem ), Number );
6236                 end else begin
6237       FileName := ThreadItem.FilePath;
6238       tmp := GikoSys.ReadThreadFile(FileName, Number);
6239                 end;
6240                 if tmp <> '' then begin
6241                         THTMLCreate.DivideStrLine(tmp, @Res);
6242
6243                         Header := IntToStr(Number) + ' \81F' + Res.FName + ' \81F' + Res.FDateTime + #13#10;
6244                         if ReplaceTag then begin
6245                                 Header := CustomStringReplace(Header, '</b>', '',true);
6246                                 Header := CustomStringReplace(Header, '<b>', '',true);
6247                                 Header := CustomStringReplace(Header, '<br>', '',true);
6248                                 Header := DeleteFontTag(Header);
6249                         end;
6250                         //if ThreadItem.IsBoardPlugInAvailable then begin
6251             if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6252                                 Body := CustomStringReplace(Res.FBody, '<br>', #13#10,true);
6253                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6254                         end else begin
6255                                 Body := CustomStringReplace(Res.FBody, ' <br> ', #13#10,true);
6256                                 Body := CustomStringReplace(Body, ' <br>', #13#10,true);
6257                                 Body := CustomStringReplace(Body, '<br> ', #13#10,true);
6258                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6259
6260                         end;
6261                         Body := CustomStringReplace(Body, '</a>', '',true);
6262
6263                         Body := HTMLCreater.DeleteLink(Body);
6264                         if ReplaceTag then begin
6265                                 Body := CustomStringReplace(Body, '&lt;', '<');
6266                                 Body := CustomStringReplace(Body, '&gt;', '>');
6267                                 Body := CustomStringReplace(Body, '&quot;', '"');
6268                                 Body := CustomStringReplace(Body, '&amp;', '&');
6269                                 //Body := CustomStringReplace(Body, '&nbsp;', ' ');
6270                         end;
6271
6272                         Header := Header + Body;
6273
6274                         Clipboard.SetTextBuf( PChar(Header) );
6275                 end;
6276         end;
6277 end;
6278
6279
6280 procedure TGikoForm.BrowserTabPopupMenuPopup(Sender: TObject);
6281 begin
6282         AddRoundNameMenu(dummy1);
6283     AddMenuSameBoardThread;
6284 end;
6285 //! \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Á
6286 procedure TGikoForm.AddMenuSameBoardThread;
6287 var
6288         i: Integer;
6289         Item: TMenuItem;
6290 begin
6291     SameBoardThreadItem.Clear;
6292     for i := 0 to BrowserTab.Tabs.Count - 1 do begin
6293         // \93¯\82\94Â\82©\82Ç\82¤\82©
6294         if (FActiveContent.Thread.ParentBoard =
6295             TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ParentBoard) then begin
6296             // \8e©\95ª\82Í\8aO\82·
6297             if FActiveContent.Thread <>
6298                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread then begin
6299                 Item := TMenuItem.Create(Self);
6300                 Item.Caption := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.Title;
6301                 Item.OnClick := SameBoardThreadSubItemOnClick;
6302                 SameBoardThreadItem.Add(Item);
6303             end;
6304         end;
6305     end;
6306     // \89½\82à\96³\82¢\82È\82ç\8eg\97p\82Å\82«\82È\82¢\82æ\82¤\82É\82·\82é
6307     SameBoardThreadItem.Enabled := SameBoardThreadItem.Count > 0;
6308 end;
6309 //!  \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
6310 procedure TGikoForm.SameBoardThreadSubItemOnClick(Sender: TObject);
6311 var
6312         i, j: Integer;
6313         MenuItem: TMenuItem;
6314 begin
6315         if Sender is TMenuItem then begin
6316         try
6317             j := 0;
6318             MenuItem := TMenuItem(Sender);
6319             for i := 0 to BrowserTab.Tabs.Count - 1 do begin
6320                 // \93¯\82\94Â\82©\82Ç\82¤\82©
6321                 if (FActiveContent.Thread.ParentBoard =
6322                     TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ParentBoard) then begin
6323                     if FActiveContent.Thread <>
6324                         TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread then begin
6325                         if (SameBoardThreadItem.Items[j] = MenuItem) then begin
6326                             MoveToURL( TBrowserRecord(BrowserTab.Tabs.Objects[i])
6327                                 .Thread.URL);
6328                             Exit;
6329                         end;
6330                         Inc(j);
6331                     end;
6332                 end;
6333             end;
6334         except
6335         end;
6336         end;
6337 end;
6338 procedure TGikoForm.FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
6339 begin
6340         FavoriteDM.URLReplace(oldURLs, newURLs);
6341 end;
6342
6343 procedure TGikoForm.RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
6344 begin
6345         RoundList.URLReplace(oldURLs, newURLs);
6346 end;
6347
6348 procedure TGikoForm.TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
6349 const
6350         Filename = 'tab.sav';
6351         bFilename = '~tab.sav';
6352 var
6353         i, j: Integer;
6354         tempString: string;
6355         tmpURL: string;
6356         oldHost: string;
6357         oldBoardName: string;
6358         newHost: string;
6359         newBoardName: string;
6360         TabList: TStringList;
6361 begin
6362
6363         if oldURLs.Count <> newURLs.Count then begin
6364                 Exit;
6365         end;
6366         if FileExists(GikoSys.GetAppDir + 'tab.sav') then begin
6367                 TabList := TStringList.Create;
6368                 try
6369                         TabList.LoadFromFile(GikoSys.GetAppDir + Filename);
6370
6371                         //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
6372                         //\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
6373                         for i := 0 to oldURLs.Count - 1 do begin
6374                                         tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
6375                                         oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6376                                         oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6377                                         tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
6378                                         newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6379                                         newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6380
6381                                         for j := 0 to TabList.Count - 1 do begin
6382                                                         tempString := TabList[j];
6383                                                         if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
6384                                                                 tempString := StringReplace(tempString, oldHost, newHost,[]);
6385                                                                 TabList[j] := tempString;
6386                                                         end;
6387                                         end;
6388                         end;
6389                         //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
6390
6391                         if FileExists( GikoSys.GetAppDir + Filename) then begin
6392                                 if FileExists( GikoSys.GetAppDir + bFilename) then
6393                                         DeleteFile(GikoSys.GetAppDir + bFilename);
6394
6395                                 //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
6396                                 RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
6397                         end;
6398
6399                         TabList.SaveToFile(GikoSys.GetAppDir + Filename);
6400                 finally
6401                         TabList.Free;
6402                 end;
6403         end;
6404
6405 end;
6406
6407 /// \8dÅ\8f¬\89»\82³\82ê\82é
6408 procedure TGikoForm.OnMinimize;
6409 begin
6410         if FActiveContent <> nil then begin
6411                 FIsMinimize := mtMinimizing;
6412                 FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
6413         end;
6414 end;
6415
6416 /// \8dÅ\8f¬\89»\82³\82ê\82½ (OnResized \82©\82ç\8cÄ\82Î\82ê\82é)
6417 procedure TGikoForm.OnMinimized;
6418 begin
6419         FIsMinimize := mtMinimized;
6420 end;
6421
6422
6423 procedure TGikoForm.BrowserTabResize(Sender: TObject);
6424 begin
6425         CoolBarResized( Sender, BrowserCoolBar );
6426 end;
6427
6428 // *************************************************************************
6429 // ExternalBoardPlugInMain
6430 // \83v\83\89\83O\83C\83\93\83\81\83j\83\85\81[\82Ì\8d\80\96Ú\82ª\8eÀ\8ds\82³\82ê\82½
6431 // *************************************************************************
6432 procedure TGikoForm.OnPlugInMenuItem( Sender : TObject );
6433 var
6434         item                            : TMenuItem;
6435         boardPlugIn     : TBoardPlugIn;
6436 begin
6437
6438         if not (Sender is TMenuItem) then
6439                 Exit;
6440
6441         item := TMenuItem( Sender );
6442         if not Assigned( Pointer( item.Tag ) ) then
6443                 Exit;
6444
6445         // \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·
6446         boardPlugIn := TBoardPlugIn( item.Tag );
6447         boardPlugIn.PlugInMenu( item.Handle );
6448
6449 end;
6450 // TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
6451 procedure TGikoForm.TreeClick( Node : TTreeNode );
6452 begin
6453
6454         if Node = nil then
6455                 Exit;
6456
6457         if FTreeType = gttHistory then begin
6458                 if Node <> nil then
6459                         if TObject( Node.Data ) is TFavoriteThreadItem then
6460                                 if GetActiveContent <> TFavoriteThreadItem( Node.Data ).Item then
6461                                         FavoriteClick( Node );
6462                 Exit;
6463         end;
6464     //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\82Ì\82Æ\93¯\82\82È\82ç\8dÄ\95`\89æ\82µ\82È\82¢
6465         if ActiveList = Node.Data then
6466                 Exit;
6467
6468         ActiveListColumnSave;
6469
6470         if TObject(Node.Data) is TBBS then begin
6471                 SetActiveList(Node.data);
6472         end else if TObject(Node.Data) is TCategory then begin
6473                 SetActiveList(Node.data);
6474         end else if TObject(Node.Data) is TBoard then begin
6475                 if not TBoard(Node.Data).IsThreadDatRead then begin
6476                         Screen.Cursor := crHourGlass;
6477                         try
6478                 if not TBoard(Node.Data).IsThreadDatRead then
6479                                         GikoSys.ReadSubjectFile(Node.Data);
6480                         finally
6481                                 Screen.Cursor := crDefault;
6482                         end;
6483                 end;
6484                 Sort.SetSortDate(Now());
6485                 SetActiveList(Node.data);
6486         end;
6487
6488         if TObject( Node.Data ) is TBoard then begin // not TCategory
6489                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6490                         if GikoSys.Setting.ListWidthState = glsMax then begin
6491                                 GikoDM.BrowserMinAction.Execute;
6492                                 if GikoForm.Visible then
6493                                         ListView.SetFocus;
6494                         end;
6495                 end else begin
6496                         if GikoSys.Setting.ListHeightState = glsMax then begin
6497                                 GikoDM.BrowserMinAction.Execute;
6498                                 if GikoForm.Visible then
6499                                         ListView.SetFocus;
6500                         end;
6501                 end;
6502         end;
6503
6504 end;
6505
6506 // TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
6507 procedure TGikoForm.TreeDoubleClick( Node : TTreeNode );
6508 var
6509         Board                           : TBoard;
6510         ThreadItem      : TThreadItem;
6511         shiftDown       : Boolean;
6512 begin
6513
6514         if Node = nil then Exit;
6515
6516         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
6517
6518         if FTreeType = gtt2ch then begin
6519                 if not (TObject(Node.Data) is TBoard) then Exit;
6520                 Board := TBoard(Node.Data);
6521                 DownloadList(Board, shiftDown);
6522         end else if FTreeType = gttHistory then begin
6523                 if not (TObject(Node.Data) is TFavoriteThreadItem) then Exit;
6524                 ThreadItem := TFavoriteThreadItem(Node.Data).Item;
6525                 DownloadContent(ThreadItem, shiftDown);
6526         end;
6527
6528 end;
6529 // *************************************************************************
6530 //! \83c\83\8a\81[\83r\83\85\81[\82ÌKeyDown\83C\83x\83\93\83g
6531 // *************************************************************************
6532 procedure TGikoForm.TreeViewKeyDown(Sender: TObject; var Key: Word;
6533         Shift: TShiftState);
6534 begin
6535         if Key = VK_BACK then begin
6536 //              UpFolderButtonClick(Sender);
6537         end else if Key = VK_SPACE then begin
6538                 TreeDoubleClick( TreeView.Selected );
6539         end else if Key = VK_RETURN then begin
6540                 TreeClick( TreeView.Selected );
6541         // \97\9a\97ð\82Ì\8fê\8d\87\81A\8fÁ\82³\82ê\82Ä\82¢\82é\82Ì\82Å\83`\83F\83b\83N\82·\82é
6542         if (TreeView.Selected <> nil) then begin
6543                 TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
6544         end;
6545         end;
6546 end;
6547 //! \82¨\8bC\82É\93ü\82è\82ÌMouseDown\83C\83x\83\93\83g
6548 procedure TGikoForm.FavoriteTreeViewMouseDown(Sender: TObject;
6549         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6550 var
6551         favItem                         : TTreeNode;
6552         favThreadItem   : TFavoriteThreadItem;
6553         rect: TRect;
6554 begin
6555         case Button of
6556         mbLeft:
6557                 begin
6558                         if not (ssAlt in Shift) and (FavoriteTreeView.Selected <> nil) and 
6559                                 (FavoriteTreeView.Selected = FavoriteTreeView.GetNodeAt(X, Y)) then begin
6560                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
6561                                 rect := FavoriteTreeView.Selected.DisplayRect(true);
6562                                 // \83A\83C\83R\83\93\95ª\8d\82É\82¸\82ç\82·
6563                                 if ((rect.Left - FavoriteTreeView.Indent <= X) and (rect.Right >= X)) and
6564                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
6565                                         if ssDouble in Shift then begin
6566                                                 FClickNode := FavoriteTreeView.Selected;
6567                                                 GikoDM.FavoriteTreeViewReloadActionExecute(Sender);
6568                                                 FClickNode := nil;
6569                                         end else begin
6570                                                 FavoriteClick(
6571                                                         TObject(FavoriteTreeView.Selected));
6572                                         end;
6573                                 end;
6574                         end;
6575                 end;
6576         mbMiddle:
6577                 begin
6578                         favItem := FavoriteTreeView.GetNodeAt( X, Y );
6579                         if favItem = nil then Exit;
6580
6581                         if TObject( favItem.Data ) is TFavoriteThreadItem then begin
6582                                 favThreadItem := TFavoriteThreadItem( favItem.Data );
6583                                 if favThreadItem.Item <> nil then
6584                                         InsertBrowserTab( favThreadItem.Item, False );
6585                         end;
6586                 end;
6587         end;
6588
6589 end;
6590
6591 procedure TGikoForm.MessagePanelResize(Sender: TObject);
6592 begin
6593
6594         if FIsIgnoreResize <> rtNone then
6595                 Exit;
6596
6597         if GikoSys.Setting.ListOrientation = gloVertical then begin
6598                 if GikoSys.Setting.ListHeightState = glsMin then begin
6599                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
6600                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
6601                 end;
6602         end;
6603
6604 end;
6605
6606 procedure TGikoForm.OnResized;
6607 var
6608         doc                                             : Variant;
6609 begin
6610
6611         FOldFormWidth := Width;
6612         FIsIgnoreResize := rtNone;
6613
6614         case FIsMinimize of
6615         mtMinimizing:
6616                 begin
6617                         // \8dÅ\8f¬\89»\92\86\82Å\82 \82é
6618                         PostMessage( Handle, USER_MINIMIZED, 0, 0 );
6619                 end;
6620
6621         mtMinimized:
6622                 begin
6623                         // \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)
6624                         if FActiveContent <> nil then begin
6625                                 doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
6626                                 doc.Body.ScrollTop := FActiveContent.Thread.ScrollTop;
6627                         end;
6628                         FIsMinimize := mtNone;
6629                 end;
6630         end;
6631
6632 end;
6633 // *************************************************************************
6634 //! \82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83}\83E\83X\83A\83b\83v\83C\83x\83\93\83g
6635 // *************************************************************************
6636 function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
6637 const
6638     LIMIT = 20;
6639 var
6640         p : TPoint;
6641         e: IHTMLElement;
6642         AID: string;
6643         stlist : TStringList;
6644         i, count: Integer;
6645         body : String;
6646     limited : Integer;
6647     FOleInPlaceActiveObject: IOleInPlaceActiveObject;
6648 begin
6649   result := true;
6650   try
6651         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
6652         FOleInPlaceActiveObject := FActiveContent.Browser.ControlInterface as IOleInPlaceActiveObject;
6653         FOleInPlaceActiveObject.OnFrameWindowActivate(True);
6654                 try
6655                         GetCursorPos(p);
6656                         p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
6657                         p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
6658                         e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
6659                         if (Assigned(e)) then begin
6660                                 if (e.className = 'date') or (e.id = 'date') then begin
6661                                         AID := e.innerText;
6662                                         if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
6663                                                 AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
6664                         if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
6665                                 AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
6666                         end;
6667                                         end else begin
6668                                                 stlist := TStringList.Create;
6669                                                 try
6670                                                         stList.DelimitedText := AID;
6671                                                         AID := '';
6672                                                         for i := 0 to stList.Count - 1 do
6673                                                                 if Length(WideString(stList[i])) = 8 then begin
6674                                                                         if GikoSys.NotDateorTimeString(stList[i]) then begin
6675                                                                                 AID := stList[i];
6676                                                                                 break;
6677                                                                         end;
6678                                                                 end;
6679                                                 finally
6680                                                         stList.Free;
6681                                                 end;
6682                                         end;
6683                     count := GikoSys.GetSameIDResCount(AID, FActiveContent.Thread);
6684                     limited := LIMIT;
6685                     if count > LIMIT then begin
6686                         if (GikoUtil.MsgBox(Handle,
6687                                 IntToStr(LIMIT) + '\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
6688                                 'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
6689                                                                 MB_YESNO or MB_ICONQUESTION) = ID_YES) then begin
6690                             limited := -1;
6691                         end
6692                     end;
6693                                         body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
6694                                         FActiveContent.IDAnchorPopup(body);
6695                                 end;
6696                         end;
6697                 except
6698                 end;
6699   except
6700   end;
6701 end;
6702
6703 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
6704 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
6705 begin
6706         SelectTimer.Interval := 0;
6707         if not (ListView.Selected = nil) then
6708                 if( FActiveContent = nil) or
6709                                 (GetActiveContent <> TThreadItem(ListView.Selected.Data) ) then begin
6710                         ListClick;
6711                 end;
6712 end;
6713
6714 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
6715 procedure TGikoForm.ActiveListColumnSave;
6716 var
6717         ActivListObj    : TObject;
6718         i, id, idx              : Integer;
6719         BBSOrder                        : TGikoBBSColumnList;
6720         CategoryOrder   : TGikoCategoryColumnList;
6721         BoardOrder              : TGikoBoardColumnList;
6722 begin
6723
6724         ActivListObj := ActiveList;
6725         if ActivListObj is TBBS then begin
6726                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6727                 BBSOrder := TGikoBBSColumnList.Create;
6728                 try
6729                         for i := 0 to ListView.Columns.Count - 1 do begin
6730                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6731                                 idx := ListView.Column[ i ].Tag;
6732                                 id := Ord( GikoSys.Setting.BBSColumnOrder[ idx ] );
6733                                 BBSOrder.Add( TGikoBBSColumnID( id ) );
6734                                 // \95\9d\82Ì\95Û\91
6735                                 GikoSys.Setting.BBSColumnWidth[ id ] := ListView.Column[ i ].Width;
6736                         end;
6737                         for i := 0 to ListView.Columns.Count - 1 do
6738                                 // \8f\87\8f\98\82Ì\95Û\91
6739                                 GikoSys.Setting.BBSColumnOrder[ i ] := BBSOrder[ i ];
6740                 finally
6741                         BBSOrder.Free;
6742                 end;
6743         end else if ActivListObj is TCategory then begin
6744                 //===== \94Â\83\8a\83X\83g =====
6745                 CategoryOrder := TGikoCategoryColumnList.Create;
6746                 try
6747                         for i := 0 to ListView.Columns.Count - 1 do begin
6748                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6749                                 idx := ListView.Column[ i ].Tag;
6750                                 id := Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] );
6751                                 CategoryOrder.Add( TGikoCategoryColumnID( id ) );
6752                                 // \95\9d\82Ì\95Û\91
6753                                 GikoSys.Setting.CategoryColumnWidth[ id ] := ListView.Column[ i ].Width;
6754                         end;
6755                         for i := 0 to ListView.Columns.Count - 1 do
6756                                 // \8f\87\8f\98\82Ì\95Û\91
6757                                 GikoSys.Setting.CategoryColumnOrder[ i ] := CategoryOrder[ i ];
6758                 finally
6759                         CategoryOrder.Free;
6760                 end;
6761         end else if ActivListObj is TBoard then begin
6762                 //===== \83X\83\8c\83\8a\83X\83g =====
6763                 BoardOrder := TGikoBoardColumnList.Create;
6764                 try
6765                         for i := 0 to ListView.Columns.Count - 1 do begin
6766                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6767                                 idx := ListView.Column[ i ].Tag;
6768                                 id := Ord( GikoSys.Setting.BoardColumnOrder[ idx ] );
6769                                 BoardOrder.Add( TGikoBoardColumnID( id ) );
6770                                 // \95\9d\82Ì\95Û\91
6771                                 GikoSys.Setting.BoardColumnWidth[ id ] := ListView.Column[ i ].Width;
6772                         end;
6773                         for i := 0 to ListView.Columns.Count - 1 do
6774                                 // \8f\87\8f\98\82Ì\95Û\91
6775                                 GikoSys.Setting.BoardColumnOrder[ i ] := BoardOrder[ i ];
6776                 finally
6777                         BoardOrder.Free;
6778                 end;
6779         end;
6780
6781 end;
6782
6783 procedure TGikoForm.ListViewColumnRightClick(Sender: TObject;
6784         Column: TListColumn; Point: TPoint);
6785 var
6786         i, j    : Integer;
6787         item    : TMenuItem;
6788 begin
6789
6790         // \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82ð\83N\83\8a\83A
6791         for i := ListColumnPopupMenu.Items.Count - 1 downto 0 do
6792                 ListColumnPopupMenu.Items.Items[ i ].Free;
6793
6794         // \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¢)
6795         if TObject( FActiveList ) is TBBS then begin
6796
6797                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6798                 for i := 1 to Length( GikoBBSColumnCaption ) - 1 do begin
6799                         item := TMenuItem.Create( ListColumnPopupMenu );
6800                         item.Caption := GikoBBSColumnCaption[ i ];
6801                         item.Tag := i;
6802                         item.OnClick := ListColumnPopupMenuOnClick;
6803                         for j := GikoSys.Setting.BBSColumnOrder.Count - 1 downto 0 do begin
6804                                 if GikoSys.Setting.BBSColumnOrder[ j ] = TGikoBBSColumnID( i ) then begin
6805                                         item.Checked := True;
6806                                         Break;
6807                                 end;
6808                         end;
6809                         ListColumnPopupMenu.Items.Add( item );
6810                 end;
6811
6812         end else if TObject( FActiveList ) is TCategory then begin
6813
6814                 //===== \94Â\83\8a\83X\83g =====
6815                 for i := 1 to Length( GikoCategoryColumnCaption ) - 1 do begin
6816                         item := TMenuItem.Create( ListColumnPopupMenu );
6817                         item.Caption := GikoCategoryColumnCaption[ i ];
6818                         item.Tag := i;
6819                         item.OnClick := ListColumnPopupMenuOnClick;
6820                         for j := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 0 do begin
6821                                 if GikoSys.Setting.CategoryColumnOrder[ j ] = TGikoCategoryColumnID( i ) then begin
6822                                         item.Checked := True;
6823                                         Break;
6824                                 end;
6825                         end;
6826                         ListColumnPopupMenu.Items.Add( item );
6827                 end;
6828
6829         end else if TObject( FActiveList ) is TBoard then begin
6830
6831                 //===== \83X\83\8c\83\8a\83X\83g =====
6832                 for i := 1 to Length( GikoBoardColumnCaption ) - 1 do begin
6833                         item := TMenuItem.Create( ListColumnPopupMenu );
6834                         item.Caption := GikoBoardColumnCaption[ i ];
6835                         item.Tag := i;
6836                         item.OnClick := ListColumnPopupMenuOnClick;
6837                         for j := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 0 do begin
6838                                 if GikoSys.Setting.BoardColumnOrder[ j ] = TGikoBoardColumnID( i ) then begin
6839                                         item.Checked := True;
6840                                         Break;
6841                                 end;
6842                         end;
6843                         ListColumnPopupMenu.Items.Add( item );
6844                 end;
6845
6846         end;
6847
6848         // \83\81\83j\83\85\81[\82Ì\95\\8e¦
6849         Point := ListView.ClientToScreen( Point );
6850         if ListColumnPopupMenu.Items.Count > 0 then
6851                 ListColumnPopupMenu.Popup( Point.X, Point.Y );
6852
6853 end;
6854
6855 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
6856 procedure       TGikoForm.ListColumnPopupMenuOnClick( Sender : TObject );
6857 var
6858         i                                       : Integer;
6859         orderList       : TList;
6860         item                    : TMenuItem;
6861 begin
6862
6863         if not (Sender is TMenuItem) then
6864                 Exit;
6865
6866         ActiveListColumnSave;
6867         item := TMenuItem( Sender );
6868
6869         if TObject( FActiveList ) is TBBS then
6870                 orderList := GikoSys.Setting.BBSColumnOrder
6871         else if TObject( FActiveList ) is TCategory then
6872                 orderList := GikoSys.Setting.CategoryColumnOrder
6873         else if TObject( FActiveList ) is TBoard then
6874                 orderList := GikoSys.Setting.BoardColumnOrder
6875         else
6876                 Exit;
6877
6878         if item.Checked then begin
6879                 // \83J\83\89\83\80\82Ì\8dí\8f\9c
6880                 for i := orderList.Count - 1 downto 0 do begin
6881                         if Integer( orderList[ i ] ) = item.Tag then begin
6882                                 orderList.Delete( i );
6883                                 Break;
6884                         end;
6885                 end;
6886         end else begin
6887                 // \83J\83\89\83\80\82Ì\92Ç\89Á
6888                 orderList.Add( Pointer( item.Tag ) );
6889         end;
6890
6891         SetActiveList( FActiveList );
6892
6893 end;
6894
6895 procedure TGikoForm.OnGestureStart(Sender: TObject);
6896 begin
6897 //
6898 end;
6899
6900 procedure TGikoForm.OnGestureMove(Sender: TObject);
6901 var
6902         s: string;
6903         Action: TAction;
6904         ActStr: string;
6905         P : TPoint;
6906 begin
6907         //\83}\83E\83X\88Ê\92u\82Ì\8eæ\93¾
6908         GetCursorPos(P);
6909         //\83R\83\93\83|\81[\83l\83\93\83g\96¼\8eæ\93¾
6910         s := MouseGesture.GetGestureStr;
6911         ActStr := '';
6912         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
6913         if Action <> nil then
6914                 ActStr := '\81i' + Action.Caption + '\81j';
6915         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
6916         StatusBar.Panels[1].Text := s;
6917 end;
6918
6919 procedure TGikoForm.OnGestureEnd(Sender: TObject);
6920 var
6921         s: string;
6922         Action: TAction;
6923 begin
6924         s := MouseGesture.GetGestureStr;
6925     MouseGesture.Clear;
6926         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
6927         if Action <> nil then
6928                 Action.Execute;
6929         StatusBar.Panels[1].Text := '';
6930 end;
6931
6932 procedure TGikoForm.ListViewCustomDrawItem(Sender: TCustomListView;
6933   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
6934 var
6935         ThreadItem: TThreadItem;
6936 begin
6937         DefaultDraw := true;
6938         if TObject(Item.Data) is TThreadItem then begin
6939                 ThreadItem := TThreadItem(Item.Data);
6940                 if ( FUseOddResOddColor ) and ( ThreadItem.Count <> 0 ) and ( ThreadItem.AllResCount <> ThreadItem.Count) then begin
6941                         ListView.Canvas.Brush.Color := FOddColor;
6942                         //\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
6943                         if (GikoSys.Setting.UnFocusedBold) and
6944                          (Item.Selected) and (not ListView.Focused) then begin
6945                                 ListView.Canvas.Font.Style := [fsBold];
6946                         end;
6947                 end else begin
6948                         ListView.Canvas.Brush.Color := FListViewBackGroundColor;
6949                 end;
6950
6951                 if ThreadItem.UnRead then
6952                         ListView.Canvas.Font.Style := [fsBold];
6953         end;
6954
6955 end;
6956
6957 procedure TGikoForm.FormActivate(Sender: TObject);
6958 begin
6959         if GikoSys.Setting.GestureEnabled then begin
6960                 GikoSys.Setting.Gestures.ClearGesture;
6961                 GikoSys.Setting.Gestures.LoadGesture(
6962                         GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
6963                 MouseGesture.UnHook;
6964                 MouseGesture.OnGestureStart := OnGestureStart;
6965                 MouseGesture.OnGestureMove := OnGestureMove;
6966                 MouseGesture.OnGestureEnd := OnGestureEnd;
6967                 MouseGesture.SetHook(Handle);
6968         end else begin
6969                 //MouseGesture.UnHook;
6970                 MouseGesture.OnGestureStart := nil;
6971                 MouseGesture.OnGestureMove := nil;
6972                 MouseGesture.OnGestureEnd := nil;
6973         end;
6974 end;
6975
6976 procedure TGikoForm.BrowserPanelResize(Sender: TObject);
6977 begin
6978     if (FIsMinimize <> mtMinimizing) then begin
6979         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
6980                 MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
6981         end;
6982     end;
6983 end;
6984 procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
6985 var
6986         coolSet                         : TCoolSet;
6987         toolbar                         : TToolBar;
6988         band                                    : TCoolBand;
6989         affectedBand    : TCoolBand;
6990         i                                                       : Integer;
6991 begin
6992         if (FOldFormWidth = Width) and not IsIconic( Handle ) and (FIsIgnoreResize = rtNone) then begin
6993                 FIsIgnoreResize := rtResizing;
6994                 PostMessage( Handle, USER_RESIZED, 0, 0 );
6995                 band := nil;
6996                 // \95Ï\8dX\82³\82ê\82½\83N\81[\83\8b\83o\81[\82Ì\92l\82ð\95Û\91
6997                 if CoolBar = MainCoolBar then begin
6998                         for i := 0 to MAIN_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.MainCoolSet[i] := CoolSet;
7003                         end;
7004                 end else if CoolBar = ListCoolBar then begin
7005                         for i := 0 to LIST_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.ListCoolSet[i] := CoolSet;
7010                         end;
7011                 end else if CoolBar = BrowserCoolBar then begin
7012                         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
7013                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7014                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7015                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7016                                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
7017                         end;
7018                 end;
7019                 if not (Sender is TToolBar) or (CoolBar = nil) then
7020                         Exit;
7021                 toolbar := TToolBar( Sender );
7022                 // \95\9d\82Ì\95Ï\8dX\82³\82ê\82½\83o\83\93\83h\82ð\8c©\82Â\82¯\82é
7023                 affectedBand := nil;
7024                 for i := CoolBar.Bands.Count - 1 downto 0 do begin
7025                         if CoolBar.Bands[ i ].Control.Handle = toolbar.Handle then begin
7026                                 band    := CoolBar.Bands[ i ];
7027                                 if band.Break or (i = 0) then begin
7028                                         if i + 1 < CoolBar.Bands.Count then
7029                                                 if not CoolBar.Bands[ i + 1 ].Break then
7030                                                         affectedBand := CoolBar.Bands[ i + 1 ];
7031                                 end else begin
7032                                         if i > 0 then
7033                                                 affectedBand := CoolBar.Bands[ i - 1 ];
7034                                 end;
7035                                 Break;
7036                         end;
7037                 end;
7038                 // \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·
7039                 if CoolBar = MainCoolBar then begin
7040                         coolSet := GikoSys.Setting.MainCoolSet[ band.ID ];
7041                         coolSet.FCoolWidth := toolbar.Width + 25;
7042                         GikoSys.Setting.MainCoolSet[ band.ID ] := coolSet;
7043                         if affectedBand <> nil then begin
7044                                 coolSet := GikoSys.Setting.MainCoolSet[ affectedBand.ID ];
7045                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7046                                 GikoSys.Setting.MainCoolSet[ affectedBand.ID ] := coolSet;
7047                         end;
7048                 end else if CoolBar = ListCoolBar then begin
7049                         coolSet := GikoSys.Setting.ListCoolSet[ band.ID ];
7050                         coolSet.FCoolWidth := toolbar.Width + 25;
7051                         GikoSys.Setting.ListCoolSet[ band.ID ] := coolSet;
7052                         if affectedBand <> nil then begin
7053                                 coolSet := GikoSys.Setting.ListCoolSet[ affectedBand.ID ];
7054                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7055                                 GikoSys.Setting.ListCoolSet[ affectedBand.ID ] := coolSet;
7056                         end;
7057                 end else if CoolBar = BrowserCoolBar then begin
7058                         coolSet := GikoSys.Setting.BrowserCoolSet[ band.ID ];
7059                         coolSet.FCoolWidth := toolbar.Width + 25;
7060                         GikoSys.Setting.BrowserCoolSet[ band.ID ] := coolSet;
7061                         if affectedBand <> nil then begin
7062                                 coolSet := GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ];
7063                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7064                                 GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ] := coolSet;
7065                         end;
7066                 end;
7067         end;
7068 end;
7069
7070
7071 procedure TGikoForm.MenuToolBarResize(Sender: TObject);
7072 begin
7073         CoolBarResized( Sender, MainCoolBar );
7074 end;
7075
7076 procedure TGikoForm.ListToolBarResize(Sender: TObject);
7077 begin
7078         CoolBarResized( Sender, ListCoolBar );
7079 end;
7080
7081 procedure TGikoForm.BrowserToolBarResize(Sender: TObject);
7082 begin
7083         CoolBarResized( Sender, BrowserCoolBar );
7084 end;
7085
7086 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
7087 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
7088 var
7089         ThreadItem      : TThreadItem;
7090         ReadList                : TStringList;
7091         wordCount               : TWordCount;
7092 begin
7093         ThreadItem      := GetActiveContent(True);
7094         ReadList                := TStringList.Create;
7095         wordCount               := TWordCount.Create;
7096         try
7097                 ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7098 {$IFDEF SPAM_FILTER_ENABLED}
7099                 // \83X\83p\83\80\82É\90Ý\92è
7100                 ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7101                 GikoSys.SpamCountWord( ReadList[ ATag - 1 ], wordCount );
7102                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7103                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7104 {$ENDIF}
7105                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7106                 GikoSys.FAbon.AddIndividualAbon(Atag, Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7107         finally
7108                 wordCount.Free;
7109                 ReadList.Free;
7110         end;
7111         FActiveContent.Repaint := true;
7112         if ThreadItem <> nil then
7113                 InsertBrowserTab( ThreadItem, True );
7114 end;
7115
7116 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
7117 procedure TGikoForm.IndividualAbonID(Atype : Integer);
7118 var
7119         ThreadItem : TThreadItem;
7120         i, No : Integer;
7121         body : TStringList;
7122         ReadList                : TStringList;
7123         wordCount               : TWordCount;
7124 begin
7125         No := KokoPopupMenu.Tag;
7126         if No = 0 then Exit;
7127         ThreadItem := GetActiveContent(True);
7128         if ThreadItem = nil then Exit;
7129         body := TStringList.Create;
7130         try
7131                 GikoSys.GetSameIDRes(No, ThreadItem, body);
7132
7133                 ReadList                := TStringList.Create;
7134                 wordCount               := TWordCount.Create;
7135                 try
7136                         ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7137 {$IFDEF SPAM_FILTER_ENABLED}
7138                         // \83X\83p\83\80\82É\90Ý\92è
7139                         ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7140 {$ENDIF}
7141                         for i := 0 to body.Count - 1 do begin
7142 {$IFDEF SPAM_FILTER_ENABLED}
7143                                 GikoSys.SpamCountWord( ReadList[ i ], wordCount );
7144                                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7145                                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7146 {$ENDIF}
7147                                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7148                                 GikoSys.FAbon.AddIndividualAbon(StrToInt(body[i]), Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7149                         end;
7150                 finally
7151                         wordCount.Free;
7152                         ReadList.Free;
7153                 end;
7154                 FActiveContent.Repaint := true;
7155                 if ThreadItem <> nil then
7156                         InsertBrowserTab( ThreadItem, True );
7157         finally
7158                 body.Free;
7159         end;
7160
7161 end;
7162
7163 procedure TGikoForm.KokoPopupMenuPopup(Sender: TObject);
7164 var
7165         firstElement: IHTMLElement;
7166         document: IHTMLDocument2;
7167 begin
7168         document := FActiveContent.Browser.Document as IHTMLDocument2;
7169         if Assigned(document) then
7170                 firstElement := document.all.item('idSearch', 0) as IHTMLElement;
7171                 if Assigned(firstElement) then
7172                         if firstElement.style.visibility <> 'hidden' then
7173                                 firstElement.style.visibility := 'hidden';
7174 end;
7175
7176 procedure TGikoForm.RepaintAllTabsBrowser();
7177 var
7178         i : Integer;
7179         ThreadItem: TThreadItem;
7180 begin
7181         for i := BrowserTab.Tabs.Count - 1 downto 0 do
7182                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
7183
7184         ThreadItem := GetActiveContent;
7185         if ThreadItem <> nil then
7186                 InsertBrowserTab( ThreadItem, True );
7187
7188 end;
7189
7190 //ListView\82Ì\91I\91ð\8fó\91Ô\82ð\89ð\8f\9c\82·\82é
7191 procedure TGikoForm.ListViewKeyUp(Sender: TObject; var Key: Word;
7192   Shift: TShiftState);
7193 begin
7194         //\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Ì
7195         //\96³\8cø\8e\9e\8aÔ\82ÌTimer\82Ì\8f\88\97\9d
7196         //\82Æ\82è\82 \82¦\82¸\81A\83^\83C\83}\81[\82ð\92â\8e~\82·\82é\81B
7197         SelectTimer.Interval := 0;
7198         if not (GikoSys.Setting.BrowserTabVisible) then begin
7199                 if (GetActiveList is TBoard) then begin
7200                         //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
7201                         if not ((ssShift in Shift) or (ssAlt in Shift) or (ssCtrl in Shift))  and
7202                                 (( Key = VK_LEFT) or (Key = VK_RIGHT) or
7203                                                 (Key = VK_UP) or (Key = VK_DOWN)) then
7204                                         SelectTimer.Interval := GikoSys.Setting.SelectInterval;
7205                 end;
7206         end;
7207 end;
7208 // *************************************************************************
7209 //! \82¨\8bC\82É\93ü\82è\82Ì\95Ò\8fW\8aJ\8en\83C\83x\83\93\83g
7210 // *************************************************************************
7211 procedure TGikoForm.FavoriteTreeViewEditing(Sender: TObject;
7212   Node: TTreeNode; var AllowEdit: Boolean);
7213 begin
7214         //\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ\82ð\88ê\8e\9e\95Û\91\82·\82é
7215         FOrigenCaption := Node.Text;
7216 end;
7217 // *************************************************************************
7218 //! Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
7219 // *************************************************************************
7220 function TGikoForm.GetMainForm(): TComponent;
7221 begin
7222         Result := Application.MainForm;
7223 end;
7224 // *************************************************************************
7225 //! \8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
7226 // *************************************************************************
7227 function TGikoForm.GetScreenCursor(): TCursor;
7228 begin
7229         Result := Screen.Cursor;
7230 end;
7231 // *************************************************************************
7232 //! \83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
7233 // *************************************************************************
7234 procedure TGikoForm.SetScreenCursor(Cursor : TCursor);
7235 begin
7236         if (Screen.Cursor <> Cursor) then
7237                 Screen.Cursor := Cursor;
7238 end;
7239 // *************************************************************************
7240 //! \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
7241 // *************************************************************************
7242 procedure TGikoForm.CabinetCloseSpeedButtonClick(Sender: TObject);
7243 begin
7244         //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Ì
7245         //\8cÄ\82Ñ\8fo\82µ\82É\82µ\82½\81@by \82à\82\82ã
7246         if GikoDM.CabinetVisibleAction.Enabled then begin
7247                 GikoDM.CabinetVisibleAction.Execute;
7248         end;
7249 end;
7250 // *************************************************************************
7251 //! \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
7252 // *************************************************************************
7253 procedure TGikoForm.FavoriteArrangeToolButtonClick(Sender: TObject);
7254 begin
7255         if GikoDM.FavoriteArrangeAction.Enabled then begin
7256                 GikoDM.FavoriteArrangeAction.Execute;
7257         end;
7258 end;
7259 // *************************************************************************
7260 //! \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
7261 // *************************************************************************
7262 procedure TGikoForm.GikoApplicationEventsMessage(var Msg: tagMSG;
7263   var Handled: Boolean);
7264 var
7265         wmMsg: TWMKey;
7266 begin
7267         //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ß
7268         if Self.Active then begin
7269                 case Msg.message of
7270                         //\83L\81[\93ü\97Í\82·\82×\82Ä
7271                         WM_KEYFIRST..WM_KEYLAST :
7272                         begin
7273                                 //\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ç
7274                                 if (Msg.message <> WM_KEYUP)
7275                     and (Msg.message <> WM_CHAR)
7276                     and (Msg.message <> WM_SYSKEYUP) then begin
7277                                         wmMsg.Msg := Msg.message;
7278                                         wmMsg.CharCode := Word(Msg.wParam);
7279                                         wmMsg.KeyData := Msg.lParam;
7280                                         //\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\82Ì\8f\88\97\9d\82É\93]\91\97
7281                                         Self.OnShortCut(wmMsg, Handled);
7282                                 end;
7283                         end;
7284                 end;
7285         end;
7286 end;
7287 // *************************************************************************
7288 //! \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
7289 // *************************************************************************
7290 procedure TGikoForm.GikoApplicationEventsDeactivate(Sender: TObject);
7291 begin
7292         Application.ProcessMessages;
7293         if not Application.Terminated then begin
7294                 if PreviewTimer.Enabled then
7295                 PreviewTimer.Enabled := False;
7296                 //\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
7297         if (FResPopupBrowser <> nil) then
7298             FResPopupBrowser.Clear;
7299
7300                 //\83v\83\8c\83r\83\85\81[\82ð\89B\82·
7301                 if FPreviewBrowser <> nil then
7302                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
7303         end;
7304
7305 end;
7306 // *************************************************************************
7307 //! \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
7308 // *************************************************************************
7309 procedure TGikoForm.GikoApplicationEventsException(Sender: TObject;
7310   E: Exception);
7311 var
7312         s : String;
7313 begin
7314         if (Sender <> nil) then begin
7315                 s := ' [' + Sender.ClassName + ']' + #13#10;
7316         end else begin
7317                 s := ' [ Sender is nil ] ' + #13#10;
7318         end;
7319         s := s + E.Message;
7320         MsgBox(Handle, s, '\8f\88\97\9d\82³\82ê\82È\82©\82Á\82½\97á\8aO', MB_OK or MB_ICONSTOP);
7321 end;
7322 // *************************************************************************
7323 //! \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¬
7324 // *************************************************************************
7325 procedure TGikoForm.CreateControlThread();
7326 begin
7327         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
7328         FControlThread := TThreadControl.Create(True);
7329         FControlThread.MaxThreadCount := 1;
7330         FControlThread.Resume;
7331         FControlThread.OnDownloadEnd := DownloadEnd;
7332         FControlThread.OnDownloadMsg := DownloadMsg;
7333         FControlThread.OnWork := Work;
7334         FControlThread.OnWorkBegin := WorkBegin;
7335         FControlThread.OnWorkEnd := WorkEnd;
7336 end;
7337 // *************************************************************************
7338 //! \83u\83\89\83E\83U\82Ì\90\90¬
7339 // *************************************************************************
7340 procedure TGikoForm.CreateBrowsers(count: Integer);
7341 var
7342         i: Integer;
7343         newBrowser: TWebBrowser;
7344 begin
7345         BrowserNullTab := TBrowserRecord.Create;
7346         BrowserNullTab.Browser := Browser;
7347         BrowserNullTab.Browser.Navigate(BLANK_HTML);
7348
7349         FBrowsers := TList.Create;
7350         for i := 0 to count -1 do begin
7351                 FBrowsers.Add(TWebBrowser.Create(BrowserPanel));
7352                 newBrowser := FBrowsers[FBrowsers.Count - 1];
7353                 TOleControl(newBrowser).Parent := BrowserPanel;
7354                 TOleControl(newBrowser).Align := alNone;
7355                 TOleControl(newBrowser).Left    := 0;
7356                 TOleControl(newBrowser).Top     := 0;
7357                 newBrowser.RegisterAsDropTarget := False;
7358                 newBrowser.OnDocumentComplete   := BrowserDocumentComplete;
7359                 newBrowser.OnBeforeNavigate2    := BrowserBeforeNavigate2;
7360                 newBrowser.OnEnter                              := BrowserEnter;
7361                 newBrowser.OnNewWindow2                 := BrowserNewWindow2;
7362                 newBrowser.OnStatusTextChange   := BrowserStatusTextChange;
7363                 newBrowser.Navigate(BLANK_HTML);
7364                 ShowWindow(newBrowser.Handle, SW_HIDE);
7365         end;
7366         BrowserNullTab.Browser.BringToFront;
7367         ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
7368
7369         //\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Ì
7370         //\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Å
7371         //\82±\82±\82Å\8fI\82í\82ç\82¹\82Ä\82¨\82­
7372         while (Browser.ReadyState <> READYSTATE_COMPLETE) and
7373                 (Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
7374                 Application.ProcessMessages;
7375         end;
7376 end;
7377 // *************************************************************************
7378 //! \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é
7379 // *************************************************************************
7380 procedure TGikoForm.SetSelectComboBox();
7381 const
7382         DUMMYCOMPNAME = 'SelectComboBoxDummy';
7383 var
7384         i: Integer;
7385         ToolButton: TToolButton;
7386 begin
7387         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
7388         SelectComboBoxPanel.Visible := False;
7389         try
7390                 for i := ListToolBar.ControlCount - 1 downto 0 do
7391                 begin
7392                         if ListToolBar.Controls[ i ].Action = GikoDM.SelectItemAction then
7393                         begin
7394                                 SelectComboBoxPanel.Left := ListToolBar.Controls[ i ].Left;
7395                                 SelectComboBoxPanel.Width := GikoSys.Setting.SelectComboBoxWidth;
7396                                 SelectComboBoxPanel.Parent := ListToolBar;
7397                                 SelectComboBoxPanel.Visible := True;
7398
7399                                 SelectComboBox.Left := 0;
7400                                 SelectComboBox.Top  := 0;
7401                                 SelectComboBox.Height := SelectComboBoxPanel.ClientHeight;
7402                                 SelectComboBox.Width := SelectComboBoxPanel.Width -
7403                                                                                 SelectComboBoxSplitter.Width;
7404
7405                                 //\88ê\82Â\8c©\82¦\82È\82¢\83{\83^\83\93\82ð\93Ë\82Á\8d\9e\82Þ
7406                                 ToolButton := TToolButton(ListToolBar.FindComponent(DUMMYCOMPNAME));
7407                                 if ToolButton = nil then begin
7408                                         ToolButton := TToolButton.Create(ListToolBar);
7409                                         ToolButton.Name := DUMMYCOMPNAME;
7410                                 end;
7411                                 ToolButton.Style := tbsSeparator;
7412                                 ToolButton.Width := 0;
7413                                 ToolButton.Left  := ListToolBar.Controls[ i ].Left;
7414                                 ListToolBar.InsertControl(ToolButton);
7415                                 ToolButton.Visible := False;
7416
7417                                 // \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·
7418                                 if (i + 1) < ListToolBar.ControlCount then
7419                                         if ListToolBar.Controls[ i + 1 ] is TToolButton then
7420                                                 if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
7421                                                         ListToolBar.Controls[ i + 1 ].Visible := False;
7422
7423
7424                                 // \83X\83\8c\83b\83h\8di\8d\9e\83{\83^\83\93\82ð\89B\82·
7425                                 ListToolBar.Controls[ i ].Visible := False;
7426
7427                                 break;
7428                         end;
7429                 end;
7430         except
7431         end;
7432 end;
7433 //! \83L\83\83\83r\83l\83b\83g\82Ì\83}\83E\83X\83_\83E\83\93\83C\83x\83\93\83g
7434 procedure TGikoForm.TreeViewMouseDown(Sender: TObject;
7435   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
7436 var
7437         rect : TRect;
7438 begin
7439         case Button of
7440         mbLeft:
7441                 begin
7442                         if (TreeView.Selected <> nil) and
7443                                 (TreeView.Selected = TreeView.GetNodeAt(X, Y)) then begin
7444                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
7445                                 rect := TreeView.Selected.DisplayRect(true);
7446                                 // \83A\83C\83R\83\93\95ª\82¾\82¯\8d\82É\82¸\82ç\82·
7447                                 if ((rect.Left - TreeView.Indent <= X) and (rect.Right >= X)) and
7448                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
7449                                         // \83N\83\8a\83b\83N\82Æ\83_\83u\83\8b\83N\83\8a\83b\83N\82ð\83R\83R\82Å\94»\92è
7450                                         if ssDouble in Shift then begin
7451                                                 TreeDoubleClick( TreeView.Selected );
7452                                         end else begin
7453                                                 TreeClick(TreeView.Selected);
7454                                         end;
7455                                 end;
7456                         end;
7457                 end;
7458         end;
7459 end;
7460 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
7461 procedure TGikoForm.GetGroupIndex(ActionList: TActionList);
7462 var
7463         i: Integer;
7464 begin
7465         if ActionList <> nil then begin
7466                 SetLength(FActionListGroupIndexes, ActionList.ActionCount);
7467
7468                 for i := 0 to ActionList.ActionCount - 1 do begin
7469                         try
7470                                 FActionListGroupIndexes[i] :=
7471                                         TCustomAction(ActionList.Actions[i]).GroupIndex;
7472                                 TCustomAction(ActionList.Actions[i]).GroupIndex
7473                                         := 0;
7474                         except
7475                                 ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7476                         end;
7477                 end;
7478
7479         end;
7480 end;
7481 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
7482 procedure TGikoForm.SetGroupIndex(ActionList: TActionList);
7483 var
7484         i: Integer;
7485 begin
7486         if ActionList <> nil then begin
7487                 if Length( FActionListGroupIndexes ) = ActionList.ActionCount then begin
7488                         for i := 0 to ActionList.ActionCount - 1 do begin
7489                                 try
7490                                         TCustomAction(ActionList.Actions[i]).GroupIndex
7491                                                 := FActionListGroupIndexes[i];
7492                                 except
7493                                         ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7494                                 end;
7495                         end;
7496                 end;
7497         end;
7498 end;
7499 //! \82±\82Ì\83\8c\83X\82ÌURL\8eæ\93¾
7500 procedure TGikoForm.GetResURLMenuClick(Sender: TObject);
7501 begin
7502 ;
7503 end;
7504 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
7505 procedure TGikoForm.RefreshListView(Thread: TThreadItem);
7506 begin
7507         //Thread\82Ì\94Â\82Æ\95\\8e¦\82µ\82Ä\82¢\82é\94Â\82ª\93¯\82\82È\82ç\95`\89æ\82ð\8dX\90V\82·\82é
7508         if (FActiveList is TBoard) and (TBoard(ActiveList) = Thread.ParentBoard) then begin
7509                 ListView.Refresh;
7510         end;
7511 end;
7512
7513 procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
7514   MousePos: TPoint; var Handled: Boolean);
7515 var
7516     pos : TPoint;
7517     coolBar: TGikoCoolBar;
7518 begin
7519     Handled := False;
7520     if (Sender <> nil) and (Sender is TGikoCoolBar) then begin
7521         coolBar := TGikoCoolBar(Sender);
7522         if (coolBar = MainCoolBar) then begin
7523             FToolBarSettingSender := tssMain;
7524         end else if (coolBar = ListCoolBar) then begin
7525             FToolBarSettingSender := tssList;
7526         end else if (coolBar = BrowserCoolBar) then begin
7527             FToolBarSettingSender := tssBrowser;
7528         end else begin
7529             FToolBarSettingSender := tssNone;
7530         end;
7531         pos := coolBar.ClientToScreen( MousePos );
7532         MainCoolBarPopupMenu.Popup( pos.X, pos.Y );
7533         Handled := True;
7534     end;
7535 end;
7536
7537 procedure TGikoForm.TaskTrayIconMessage(var Msg: TMsg);
7538 begin
7539     //  \8d\83N\83\8a\83b\83N\82È\82ç\95\9c\8c³\82·\82é
7540     if  (Msg.wParam = WM_LBUTTONUP) then  begin
7541         UnStoredTaskTray;
7542     end;
7543 end;
7544 //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
7545 procedure TGikoForm.StoredTaskTray;
7546 begin
7547     try
7548         if (FIconData.uID = 0) then begin
7549             FIconData.cbSize  :=  SizeOf(TNotifyIconData);
7550             FIconData.uID     :=  Self.Handle;
7551             FIconData.Wnd     :=  Handle;
7552             FIconData.uFlags  :=  NIF_MESSAGE or NIF_ICON or NIF_TIP;
7553             FIconData.uCallbackMessage  :=  USER_TASKTRAY;
7554             FIconData.hIcon   :=  Application.Icon.Handle;  {\83A\83C\83R\83\93\8ew\92è}
7555             FIconData.szTip   :=  '\83M\83R\83i\83r';      {\83q\83\93\83g\95\8e\9a\97ñ}
7556             Shell_NotifyIcon(NIM_ADD, @FIconData);
7557             ShowEditors(SW_HIDE);
7558             ShowWindow(Self.Handle, SW_HIDE);
7559         end;
7560     except
7561     end;
7562 end;
7563 //! \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¦
7564 procedure TGikoForm.UnStoredTaskTray;
7565 begin
7566     try
7567         try
7568             Shell_NotifyIcon(NIM_DELETE, @FIconData);
7569             SetForegroundWindow(Application.Handle);
7570         except
7571         end;
7572     finally
7573         FIconData.uID := 0;
7574         // Action\82©\82ç\8ai\94[\82µ\82½\82Æ\82«\82ÍTag\82Ì\92l\82Í0\88È\8aO
7575         if (GikoDM.StoredTaskTrayAction.Tag = 0) then begin
7576             ShowWindow(Self.Handle, SW_RESTORE);
7577         end else begin
7578             ShowWindow(Self.Handle, SW_SHOW);
7579         end;
7580         ShowEditors(SW_SHOW);
7581         GikoDM.StoredTaskTrayAction.Tag := 0;
7582     end;
7583 end;
7584 {
7585 \brief \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
7586 \param nCmdShow Windows.ShowWindow\82É\91\97\82é\83p\83\89\83\81\81[\83^\82Æ\93¯\82
7587 }
7588 procedure TGikoForm.ShowEditors(nCmdShow: Integer);
7589 var
7590     i : Integer;
7591 begin
7592     // \83\8c\83X\83G\83f\83B\83^\82ð\92T\82·
7593     for i := 0 to Screen.CustomFormCount - 1 do begin
7594         if TObject(Screen.CustomForms[i]) is TEditorForm then
7595             ShowWindow(Screen.CustomForms[i].Handle, nCmdShow);
7596
7597     end;
7598 end;
7599 //! \83|\83b\83v\83A\83b\83v\83u\83\89\83E\83U\8dì\90¬
7600 procedure TGikoForm.CreateResPopupBrowser;
7601 begin
7602     if (FResPopupBrowser = nil) then begin
7603         FResPopupBrowser := TResPopupBrowser.Create(BrowserPanel);
7604     end;
7605 end;
7606 //! \8aO\82©\82ç\82ÌD&D\8f\88\97\9d
7607 procedure TGikoForm.WMDropFiles(var Msg: TWMDropFiles);
7608 var
7609     FileName: Array[0..MAX_PATH] of Char;
7610     Cnt, K: Integer;
7611     Board: TBoard;
7612     LogFolder: String;
7613     datList: TStringList;
7614 begin
7615     // \95\\8e¦\82µ\82Ä\82¢\82é\82Ì\94Â\82Ì\82Æ\82«\88È\8aO\82Í\8b\91\94Û
7616     if GetActiveList is TBoard then begin
7617         Board := TBoard(GetActiveList);
7618         if MsgBox(Handle, Board.Title
7619             + ' \94Â\82É\93ü\82ê\82Ä\82¢\82¢\82Å\82·\82©\81H', '\83M\83R\83i\83r', MB_YESNO or MB_ICONQUESTION) = IDYES       then begin
7620             // \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
7621             datList := TStringList.Create;
7622             try
7623                 Cnt := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, SizeOf(FileName));
7624                 for K := 0 to Cnt - 1 do begin
7625                     DragQueryFile(Msg.Drop, K, FileName, SizeOf(FileName));
7626                     {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}
7627                     // \83t\83@\83C\83\8b\82Ì\83`\83F\83b\83N
7628                     if (isValidFile(FileName)) then begin
7629                         LogFolder := ExtractFilePath(Board.FilePath);
7630                         if (FileExists( LogFolder + ExtractFileName(FileName))) then begin
7631                             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);
7632                         end else begin
7633                             if (not DirectoryExists(LogFolder)) then begin
7634                                 if (not GikoSys.ForceDirectoriesEx(LogFolder) ) then begin
7635                                     GikoUtil.MsgBox(Handle, LogFolder + '\82Ì\90\90¬\82É\8e¸\94s\82µ\82Ü\82µ\82½\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
7636                                 end;
7637                             end;
7638                             if (not Windows.CopyFile(FileName,  PChar(LogFolder + ExtractFileName(FileName)), true)) then begin
7639                                 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);
7640                             end else begin
7641                                 datList.Add(ExtractFileName(FileName));
7642                             end;
7643                         end;
7644                     end;
7645                 end;
7646                 DragFinish(Msg.Drop);
7647                 if (datList.Count > 0) then begin
7648                     GikoSys.AddOutofIndexDat(Board, datList, False);
7649                     ShowMessage(IntToStr(datList.Count) + '\8cÂ\82Ìdat\83t\83@\83C\83\8b\82ª\83R\83s\81[\82³\82ê\82Ü\82µ\82½\81B' );
7650                         if GikoForm.TreeView.Visible then
7651                                 GikoForm.TreeView.Refresh;
7652                             if GikoForm.ListView.Visible then
7653                                 GikoForm.ListView.Refresh;
7654                 end else begin
7655                     ShowMessage('\88ê\82Â\82à\83R\83s\81[\82³\82ê\82Ü\82¹\82ñ\82Å\82µ\82½\81B' );
7656                 end;
7657             finally
7658                 datList.Free;
7659             end;
7660
7661         end;
7662     end else begin
7663         ShowMessage('\94Â\82ð\95\\8e¦\82µ\82Ä\82­\82¾\82³\82¢\81B');
7664     end;
7665 end;
7666 //! \83t\83@\83C\83\8b\83`\83F\83b\83N
7667 function TGikoForm.isValidFile(FileName: String) : boolean;
7668 var
7669     dt: TDateTime;
7670 begin
7671     Result := True;
7672     // \91\8dÝ\82·\82é\82©\81A\8ag\92£\8eqdat\81A\83t\83@\83C\83\8b\96¼
7673     if ( not FileExists(FileName) ) then begin
7674         Result := False;
7675         GikoUtil.MsgBox(Handle, FileName + '\82Í\91\8dÝ\82µ\82Ü\82¹\82ñ\81B', '\83G\83\89\81[', MB_ICONSTOP or MB_OK);
7676     end else if (ExtractFileExt(ExtractFileName(FileName)) <> '.dat' ) then begin
7677         Result := False;
7678         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);
7679     end else begin
7680         // \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
7681         try
7682             dt := GikoSys.GetCreateDateFromName(FileName);
7683             if ((UnixToDateTime(ZERO_DATE) + OffsetFromUTC) = dt) then begin
7684                 Result := False;
7685                 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);
7686             end;
7687         except
7688             Result := False;
7689             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);
7690         end;
7691     end;
7692 end;
7693
7694 initialization
7695                                 OleInitialize(nil);
7696 finalization
7697                                 OleUninitialize;
7698
7699 end.