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