OSDN Git Service

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