OSDN Git Service

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