OSDN Git Service

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