OSDN Git Service

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