OSDN Git Service

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