OSDN Git Service

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