OSDN Git Service

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