OSDN Git Service

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