OSDN Git Service

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