OSDN Git Service

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