OSDN Git Service

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