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                 C2: TMenuItem;
288                 SelectComboBox: TComboBox;
289                 MainCoolBarPopupMenu: TPopupMenu;
290                 StdToolBarVisiblePMenu: TMenuItem;
291                 AddressToolBarVisiblePMenu: TMenuItem;
292                 LinkToolBarVisiblePMenu: TMenuItem;
293                 NG1: TMenuItem;
294                 NG2: TMenuItem;
295                 N43: TMenuItem;
296                 N44: TMenuItem;
297                 L9: TMenuItem;
298                 I3: TMenuItem;
299                 N45: TMenuItem;
300                 B9: TMenuItem;
301                 R5: TMenuItem;
302                 T12: TMenuItem;
303                 Show3: TMenuItem;
304                 N46: TMenuItem;
305                 T13: TMenuItem;
306                 B10: TMenuItem;
307                 N47: TMenuItem;
308                 A12: TMenuItem;
309                 U4: TMenuItem;
310                 F4: TMenuItem;
311                 N48: TMenuItem;
312                 T14: TMenuItem;
313                 ToolButton16: TToolButton;
314                 N50: TMenuItem;
315                 A11: TMenuItem;
316                 S5: TMenuItem;
317                 Reload: TMenuItem;
318                 GoBack: TMenuItem;
319                 GoFoward: TMenuItem;
320                 IndividualAbon1: TMenuItem;
321                 N41: TMenuItem;
322                 IndividualAbon2: TMenuItem;
323     AntiIndivAbonMenuItem: TMenuItem;
324                 AntiIndividualAbon: TMenuItem;
325                 N49: TMenuItem;
326                 N51: TMenuItem;
327                 N52: TMenuItem;
328                 SearchBoardName: TMenuItem;
329     TreeSelectLogDeleteSeparator: TMenuItem;
330                 N54: TMenuItem;
331                 A13: TMenuItem;
332                 FavoriteTreePopupMenu: TPopupMenu;
333                 FavoriteTreeRenamePopupMenu: TMenuItem;
334                 FavoriteTreeNewFolderPopupMenu: TMenuItem;
335                 N56: TMenuItem;
336                 FavoriteTreeDeletePopupMenu: TMenuItem;
337                 FavoriteToolBar: TToolBar;
338     FavoriteAddToolButton: TToolButton;
339     FavoriteArrangeToolButton: TToolButton;
340                 FavoriteTreeBrowseFolderPopupMenu: TMenuItem;
341                 N57: TMenuItem;
342                 FavoriteTreeReloadPopupMenu: TMenuItem;
343                 N58: TMenuItem;
344                 FavoriteTreeURLCopyPopupMenu: TMenuItem;
345                 FavoriteTreeNameCopyPopupMenu: TMenuItem;
346                 FavoriteTreeLogDeletePopupMenu: TMenuItem;
347                 N59: TMenuItem;
348                 FavoriteTreeNameURLCopyPopupMenu: TMenuItem;
349                 ToolButton20: TToolButton;
350                 N60: TMenuItem;
351                 ExportFavoriteFileAction1: TMenuItem;
352                 N6: TMenuItem;
353                 N17: TMenuItem;
354     N18: TMenuItem;
355     N20: TMenuItem;
356         N24: TMenuItem;
357     N62: TMenuItem;
358         N61: TMenuItem;
359         N63: TMenuItem;
360     N64: TMenuItem;
361     dummy1: TMenuItem;
362         TreeSelectLogDeletePopupMenu: TMenuItem;
363         N65: TMenuItem;
364     BBSSelectPopupMenu: TPopupMenu;
365                 PlugInMenu: TMenuItem;
366         TreeSelectNamePupupMenu: TMenuItem;
367     BrowserPanel: TPanel;
368         SelectTimer: TTimer;
369     SelectThreadSave: TMenuItem;
370     N55: TMenuItem;
371     N66: TMenuItem;
372     dat1: TMenuItem;
373                 OpenLogFolder: TMenuItem;
374     Browser: TWebBrowser;
375     TabSave: TMenuItem;
376         TabOpen: TMenuItem;
377     ResRangePopupMenu: TPopupMenu;
378     ResRangeHundPMenuItem: TMenuItem;
379     ResRangeKokoPMenuItem: TMenuItem;
380     ResRangeNewPMenuItem: TMenuItem;
381     ResRangeAllPMenuItem: TMenuItem;
382         BrowsBoradHeadAction1: TMenuItem;
383     ThreadRangePopupMenu: TPopupMenu;
384     A15: TMenuItem;
385     L8: TMenuItem;
386         N67: TMenuItem;
387     N68: TMenuItem;
388     S6: TMenuItem;
389     N69: TMenuItem;
390     ResRangeSelectPMenuItem: TMenuItem;
391     ListColumnPopupMenu: TPopupMenu;
392     N70: TMenuItem;
393     ID1: TMenuItem;
394     ID2: TMenuItem;
395     N53: TMenuItem;
396     ID3: TMenuItem;
397     N71: TMenuItem;
398     N72: TMenuItem;
399     N73: TMenuItem;
400     SelectComboBoxPanel: TPanel;
401     SelectComboBoxSplitter: TImage;
402         ToolButton1: TToolButton;
403     N74: TMenuItem;
404     WikiFAQ: TMenuItem;
405     GikoApplicationEvents: TApplicationEvents;
406     N22: TMenuItem;
407     N42: TMenuItem;
408     DAT2: TMenuItem;
409     N75: TMenuItem;
410     DAT3: TMenuItem;
411     N76: TMenuItem;
412     FavoriteTreeItemNameCopyPopupMenu: TMenuItem;
413     N77: TMenuItem;
414     N78: TMenuItem;
415     SaveThreadFile: TMenuItem;
416     N79: TMenuItem;
417     HTML1: TMenuItem;
418     DAT4: TMenuItem;
419     N80: TMenuItem;
420                                 procedure FormCreate(Sender: TObject);
421                 procedure FormDestroy(Sender: TObject);
422                 procedure BrowserStatusTextChange(Sender: TObject;
423                         const Text: WideString);
424                 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
425                 procedure TreeViewChanging(Sender: TObject; Node: TTreeNode;
426                         var AllowChange: Boolean);
427                 procedure ListViewKeyDown(Sender: TObject; var Key: Word;
428                         Shift: TShiftState);
429                 procedure ListViewColumnClick(Sender: TObject; Column: TListColumn);
430                 procedure MenuToolBarCustomDrawButton(Sender: TToolBar;
431                         Button: TToolButton; State: TCustomDrawState;
432                         var DefaultDraw: Boolean);
433                 procedure BrowserBeforeNavigate2(Sender: TObject;
434                         const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
435                         Headers: OleVariant; var Cancel: WordBool);
436                 procedure TreeViewCustomDraw(Sender: TCustomTreeView;
437                         const ARect: TRect; var DefaultDraw: Boolean);
438                 procedure TreeViewCustomDrawItem(Sender: TCustomTreeView;
439                         Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
440                 procedure TreeViewExpanded(Sender: TObject; Node: TTreeNode);
441                 procedure ListViewCustomDraw(Sender: TCustomListView;
442                         const ARect: TRect; var DefaultDraw: Boolean);
443                 procedure ListViewMouseDown(Sender: TObject; Button: TMouseButton;
444                         Shift: TShiftState; X, Y: Integer);
445                 procedure TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
446                 procedure MessageListViewResize(Sender: TObject);
447                 procedure       CabinetVisible( isVisible : Boolean );
448                 procedure FormResize(Sender: TObject);
449                 procedure ListPopupMenuPopup(Sender: TObject);
450                 procedure TreePopupMenuPopup(Sender: TObject);
451                 procedure BrowserNewWindow2(Sender: TObject; var ppDisp: IDispatch;
452                         var Cancel: WordBool);
453                 procedure ListSplitterMoved(Sender: TObject);
454                 procedure BrowserTabChange(Sender: TObject);
455                 procedure BrowserTabMouseDown(Sender: TObject; Button: TMouseButton;
456                         Shift: TShiftState; X, Y: Integer);
457                 procedure BrowserTabDragOver(Sender, Source: TObject; X, Y: Integer;
458                         State: TDragState; var Accept: Boolean);
459                 procedure BrowserTabDragDrop(Sender, Source: TObject; X, Y: Integer);
460                 procedure BrowserTabMouseMove(Sender: TObject; Shift: TShiftState; X,
461                         Y: Integer);
462                 procedure BrowserDocumentComplete(Sender: TObject;
463                         const pDisp: IDispatch; var URL: OleVariant);
464                 procedure RoundNamePopupMenuPopup(Sender: TObject);
465                 procedure FormShow(Sender: TObject);
466                 procedure BrowserTabToolBarResize(Sender: TObject);
467                 procedure FavoriteMenuClick(Sender: TObject);
468                 procedure MainCoolBarResize(Sender: TObject);
469                 procedure AddressToolBarResize(Sender: TObject);
470                 procedure AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
471                         Shift: TShiftState);
472                 procedure BrowserEnter(Sender: TObject);
473                 procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
474                 procedure PreviewTimerTimer(Sender: TObject);
475                 procedure MessageHideButtonClick(Sender: TObject);
476                 procedure HistoryAllClearToolButtonClick(Sender: TObject);
477                 procedure MainCoolBarBandInfo(Sender: TObject;
478                         var BandInfo: PReBarBandInfoA);
479                 procedure MainCoolBarChevronClick(Sender: TObject;
480                         RebarChevron: PNMRebarChevron);
481                 procedure ListCoolBarBandInfo(Sender: TObject;
482                         var BandInfo: PReBarBandInfoA);
483                 procedure ListCoolBarChevronClick(Sender: TObject;
484                         RebarChevron: PNMRebarChevron);
485                 procedure BrowserCoolBarBandInfo(Sender: TObject;
486                         var BandInfo: PReBarBandInfoA);
487                 procedure BrowserCoolBarChevronClick(Sender: TObject;
488                         RebarChevron: PNMRebarChevron);
489                 procedure ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
490                 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
491                         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
492                 procedure SelectComboBoxChange(Sender: TObject);
493                 procedure SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
494                         Shift: TShiftState);
495                 procedure SelectComboBoxExit(Sender: TObject);
496                 procedure SelectComboBoxSplitterMouseMove(Sender: TObject;
497                         Shift: TShiftState; X, Y: Integer);
498                 procedure SelectComboBoxSplitterMouseDown(Sender: TObject;
499                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
500                 procedure SelectComboBoxSplitterMouseUp(Sender: TObject;
501                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
502                 procedure StatusBarResize(Sender: TObject);
503                 procedure SelectComboBoxEnter(Sender: TObject);
504                 procedure FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
505                         Y: Integer);
506                 procedure FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
507                 procedure FavoriteTreeViewEdited(Sender: TObject; Node: TTreeNode;
508                         var S: String);
509                 procedure FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
510                         Shift: TShiftState);
511                 procedure FavoriteTreePopupMenuPopup(Sender: TObject);
512                 procedure LinkToolBarDragDrop(Sender, Source: TObject; X, Y: Integer);
513                 procedure BrowserTabMouseUp(Sender: TObject; Button: TMouseButton;
514                         Shift: TShiftState; X, Y: Integer);
515                 procedure LinkToolBarDragOver(Sender, Source: TObject; X, Y: Integer;
516                         State: TDragState; var Accept: Boolean);
517                 procedure FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
518                         Y: Integer);
519                 procedure FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
520     procedure BrowserTabContextPopup(Sender: TObject; MousePos: TPoint;
521       var Handled: Boolean);
522     procedure BrowserTabPopupMenuPopup(Sender: TObject);
523     procedure BrowserTabResize(Sender: TObject);
524     procedure TreeViewKeyDown(Sender: TObject; var Key: Word;
525       Shift: TShiftState);
526     procedure FavoriteTreeViewMouseDown(Sender: TObject;
527                         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
528     procedure MessagePanelResize(Sender: TObject);
529                 procedure OnResized;
530         procedure SelectTimerTimer(Sender: TObject);
531                 procedure ListViewColumnRightClick(Sender: TObject;
532       Column: TListColumn; Point: TPoint);
533         procedure ListViewCustomDrawItem(Sender: TCustomListView;
534       Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
535     procedure FormActivate(Sender: TObject);
536     procedure BrowserPanelResize(Sender: TObject);
537     procedure MenuToolBarResize(Sender: TObject);
538     procedure ListToolBarResize(Sender: TObject);
539     procedure BrowserToolBarResize(Sender: TObject);
540         procedure KokoPopupMenuPopup(Sender: TObject);
541         procedure ListViewKeyUp(Sender: TObject; var Key: Word;
542           Shift: TShiftState);
543     procedure FavoriteTreeViewEditing(Sender: TObject; Node: TTreeNode;
544       var AllowEdit: Boolean);
545         procedure CabinetCloseSpeedButtonClick(Sender: TObject);
546     procedure FavoriteArrangeToolButtonClick(Sender: TObject);
547     procedure GikoApplicationEventsMessage(var Msg: tagMSG;
548           var Handled: Boolean);
549     procedure GikoApplicationEventsDeactivate(Sender: TObject);
550     procedure GikoApplicationEventsException(Sender: TObject; E: Exception);
551     procedure TreeViewMouseDown(Sender: TObject; Button: TMouseButton;
552       Shift: TShiftState; X, Y: Integer);
553     procedure GetResURLMenuClick(Sender: TObject);
554     procedure MainCoolBarContextPopup(Sender: TObject; MousePos: TPoint;
555       var Handled: Boolean);
556         private
557                 { Private \90é\8c¾ }
558                 FEnabledCloseButton: Boolean;
559                 FClickNode: TTreeNode;
560                 FHttpState: Boolean;
561                 FHint: TResPopup;
562                 FPreviewBrowser: TPreviewBrowser;
563                 FPreviewURL: string;
564                 FBrowserSizeHeight: Integer;
565                 FBrowserSizeWidth: Integer;
566                 FTabHintIndex: Integer;
567                 FListStyle: TViewStyle;                         //\83\8a\83X\83g\83A\83C\83R\83\93\83X\83^\83C\83\8b
568                 FItemNoVisible: Boolean;                        //\83\8a\83X\83g\94Ô\8d\86\95\\8e¦\83t\83\89\83O
569                 FViewType: TGikoViewType;                       //\83\8a\83X\83g\83A\83C\83e\83\80\95\\8e¦\83^\83C\83v
570                 FActiveList: TObject;
571                 FActiveContent: TBrowserRecord; //
572                 FActiveBBS : TBBS;
573                 FHistoryList: THistoryList;                                     //\83q\83X\83g\83\8a\83\8a\83X\83g
574                 FTreeType: TGikoTreeType;
575                 FWorkCount: Integer;
576                 FNameCookie: string;
577                 FMailCookie: string;
578                 FDownloadTitle: string;                         //\83_\83E\83\93\83\8d\81[\83h\92\86\82Ì\83^\83C\83g\83\8b\96¼
579                 FDownloadMax: Integer;                          //\83_\83E\83\93\83\8d\81[\83h\92\86\82Ì\8dÅ\91å\83T\83C\83Y
580                 FEvent: THTMLDocumentEventSink;//\83u\83\89\83E\83U\83h\83L\83\85\83\81\83\93\83g\83C\83x\83\93\83g
581                 IsDraggingSelectComboBox : Boolean;
582                 DraggingSelectComboBoxPosition : TPoint;
583                 FSearchDialog: TSearchDialog;
584                 FDropSpaceNode: TTreeNode;
585                 FDragTime : Cardinal;                                                           ///< \83\8a\83\93\83N\82ÌD&D\97p
586                 FDragButton : TToolButton;                                      ///< \83\8a\83\93\83N\82ÌD&D\97p\82ÉDrag\82µ\82Ä\82éButton\95Û\91
587                 FDragWFirst : Boolean;                                                  ///< WebTab\82ÌD&D\97p
588                 FListViewBackGroundColor : TColor;      ///< ListView\82ÌBackGroundColor
589                 FUseOddResOddColor : Boolean;                   ///< \8eæ\93¾\83\8c\83X\90\94\82Æ\83X\83\8c\83b\83h\82Ì\83\8c\83X\90\94\82ª\88á\82Á\82½\82Æ\82«\82É\91¼\82Ì\90F\82Å\95\\8e¦
590                 FOddColor : TColor;                                                                     ///< \82»\82Ì\90F
591                 FSelectResWord  : string;                                               ///< \83\8c\83X\8di\8d\9e\83\8f\81[\83h
592                 FIsIgnoreResize : TResizeType;                  ///< \83\8a\83T\83C\83Y\83C\83x\83\93\83g\82ð\96³\8e\8b\82·\82é\82©\82Ç\82¤\82©
593                 FIsMinimize                     : TMinimizeType;                ///< \8dÅ\8f¬\89»\82µ\82Ä\82¢\82é\8dÅ\92\86\82©
594                 FOldFormWidth           : Integer;                                      ///< \92¼\91O\82Ì\83E\83B\83\93\83h\83E\82Ì\95\9d
595                 FToolBarSettingSender : TToolBarSettingSenderType;      ///< \83c\81[\83\8b\83o\81[\90Ý\92è\82ð\83N\83\8a\83b\83N\82µ\82½\83N\81[\83\8b\83o\81[
596                 FMouseDownPos           : TPoint;                                       ///< \83u\83\89\83E\83U\83^\83u\82Å\83}\83E\83X\82ð\89\9f\82µ\82½\82Æ\82«\82Ì\8dÀ\95W
597                 FBrowsers: TList;
598                 FResRangeMenuSelect     : Longint;                      ///< ResRangeButton \82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\8d\80\96Ú (\83t\83H\81[\83}\83b\83g\82Í ResRange \8cÝ\8a·)
599                 FStartUp : Boolean;
600                 FIsHandledWheel : Boolean;                      ///< \8aù\82É\8eó\82¯\8eæ\82Á\82½ WM_MOUSEWHEEL \82©\82Ç\82¤\82©
601                                 DiffComp: Boolean;                      //Add by Genyakun \83X\83\8c\82ª\8dX\90V\82³\82ê\82½\82Æ\82«\82ÉTrue\82É\82È\82é
602                 FOrigenCaption: String;                         //\82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83A\83C\83e\83\80\95Ò\8fW\8e\9e\82Ì\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ
603                 FPreviewBrowserRect: TRect;                     ///< \83v\83\8c\83r\83\85\81[\82Ì\95\\8e¦\88Ê\92u\82ð\8bL\89¯\82·\82é
604                 FActionListGroupIndexes: array of Integer;      ///<GikoDM\8fã\82Ì\83A\83N\83V\83\87\83\93\83\8a\83X\83g\82Ì\8ae\83A\83N\83V\83\87\83\93\82É\90Ý\92è\82³\82ê\82½GroupIndex\82ð\95Û\91\82·\82é\94z\97ñ
605
606                 procedure DownloadEnd(Sender: TObject; Item: TDownloadItem);
607                 procedure DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
608                 procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
609                 procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
610                 procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
611                 procedure ListClick;
612                 procedure ListDoubleClick(Shift: TShiftState);
613                 function Hook(var Message: TMessage): Boolean;
614                 procedure AddRoundNameMenu(MenuItem: TMenuItem);
615                 procedure SetMenuFont;
616                 procedure CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
617                 procedure FavoriteClick(Sender: TObject; ActiveTab: Boolean); overload;
618                 procedure FavoriteClick(Sender: TObject); overload;
619                 procedure FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
620                 function OnDocumentContextMenu(Sender: TObject): WordBool;
621                 procedure ShowTextPopup;
622                 function GetWidthAllToolButton(ToolBar: TToolBar): Integer;
623                 procedure MenuBarChevronMenu;
624                 procedure LinkBarChevronMenu;
625                 procedure ToolBarChevronMenu(ToolBar: TToolBar);
626                 procedure LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
627                 procedure LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
628                 procedure LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
629                 procedure LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
630                 procedure LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
631                 function TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
632                 procedure FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
633                 procedure FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
634                 procedure FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
635                 //
636                 procedure SetListViewBackGroundColor(value: TColor);
637                 procedure BBSMenuItemOnClick( Sender : TObject );
638                 /// CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
639                 procedure       SaveCoolBarSettings;
640                 procedure       SaveMainCoolBarSettings;
641                 procedure       SaveBoardCoolBarSettings;
642                 procedure       SaveBrowserCoolBarSettings;
643                 /// CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82©\82ç\95\9c\8c³
644                 procedure       LoadCoolBarSettings;
645                 /// \8dÅ\8f¬\89»\82³\82ê\82é
646                 procedure OnMinimize;
647                 /// \8dÅ\8f¬\89»\82³\82ê\82½
648                 procedure OnMinimized;
649                 /// TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
650                 procedure TreeClick( Node : TTreeNode );
651                 /// TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
652                 procedure TreeDoubleClick( Node : TTreeNode );
653                 /// \8ae\8f\8a\82É\82 \82é\83L\83\83\83r\83l\83b\83g\81E BBS \83\81\83j\83\85\81[\82ð\83Z\83b\83g\81^\8dX\90V
654                 procedure SetBBSMenu;
655                 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
656                 procedure       ListColumnPopupMenuOnClick( Sender : TObject );
657                 //! \8di\82è\8d\9e\82Ý\95\8e\9a\97ñ\90Ý\92è
658                 procedure SetSelectWord( const text : string );
659                 //\8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
660                 function GetScreenCursor(): TCursor;
661                 //\83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
662                 procedure SetScreenCursor(Cursor : TCursor);
663                 //! \83_\83E\83\93\83\8d\81[\83h\83R\83\93\83g\83\8d\81[\83\8b\83X\83\8c\83b\83h\82Ì\90\90¬
664                 procedure CreateControlThread();
665                 //! \83u\83\89\83E\83U\82Ì\90\90¬
666                 procedure CreateBrowsers(count: Integer);
667                 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
668                 procedure GetGroupIndex(ActionList: TActionList);
669                 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
670                 procedure SetGroupIndex(ActionList: TActionList);
671                 //! \8ew\92è\82³\82ê\82½\83X\83\8c\83b\83h\82ð\8aJ\82­(\83\8d\83O\82ª\96³\82¢\82Æ\82« or \8ew\92èJUMP\82Ü\82Å\91«\82è\82È\82¢\82Æ\82«\82ÍDL\82·\82é)
672                 procedure OpenThreadItem(Thread: TThreadItem; URL: String);
673                 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
674                 procedure RefreshListView(Thread: TThreadItem);
675                 //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
676                 procedure ClearThreadRengeAction;
677         //! \83^\83X\83N\83g\83\8c\83C\82Ì\83A\83C\83R\83\93\8dí\8f\9c\81\95\83t\83H\81[\83\80\95\\8e¦
678         procedure UnStoredTaskTray;
679         //! \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
680         procedure ShowEditors(nCmdShow: Integer);
681         protected
682                 procedure CreateParams(var Params: TCreateParams); override;
683                 procedure WndProc(var Message: TMessage); override;
684                 procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR;
685                 procedure WMSettingChange(var Message: TWMWinIniChange); message WM_SETTINGCHANGE;
686                 procedure WMCopyData(var Message: TWMCopyData); message WM_COPYDATA;
687
688         public
689                 { Public \90é\8c¾ }
690                 LastRoundTime: TDateTime;
691                 BrowserNullTab: TBrowserRecord;
692                 FControlThread: TThreadControl;
693         FIconData : TNotifyIconData;
694                 procedure MoveToURL(const inURL: string);
695                 function InsertBrowserTab(ThreadItem: TThreadItem; ActiveTab: Boolean = True) : TBrowserRecord;
696                 procedure ReloadBBS;
697                 function GetHttpState: Boolean;
698                 procedure SetEnabledCloseButton(Enabled: Boolean);
699                 function GetTreeNode(Data: TObject): TTreeNode;
700                 procedure ListViewAllSelect;
701                 property ListStyle: TViewStyle read FListStyle write FListStyle;
702                 property ItemNoVisible: Boolean read FItemNoVisible write FItemNoVisible;
703                 property ViewType: TGikoViewType read FViewType write FViewType;
704                 property NameCookie: string read FNameCookie write FNameCookie;
705                 property MailCookie: string read FMailCookie write FMailCookie;
706                 property ClickNode: TTreeNode read FClickNode write FClickNode;
707                 property TreeType: TGikoTreeType read FTreeType write FTreeType;
708                 property ActiveContent: TBrowserRecord read FActiveContent write FActiveContent;
709                 property ResRangeMenuSelect: Longint read FResRangeMenuSelect write FResRangeMenuSelect;
710                 property SelectResWord  : string read FSelectResWord write FSelectResWord;
711                 property BrowserSizeWidth: Integer read FBrowserSizeWidth write FBrowserSizeWidth;
712                 property BrowserSizeHeight: Integer read FBrowserSizeHeight write FBrowserSizeHeight;
713                 property SearchDialog: TSearchDialog read FSearchDialog write FSearchDialog;
714                 property ToolBarSettingSender : TToolBarSettingSenderType
715                                                  read FToolBarSettingSender write FToolBarSettingSender;
716                 property ScreenCursor : TCursor read GetScreenCursor write SetScreenCursor;
717                 property ActiveBBS : TBBS read FActiveBBS write FActiveBBS;
718                 property WorkCount: Integer read FWorkCount write FWorkCount;
719                 procedure SetContent(inThread: TBrowserRecord);
720                 function GetActiveContent: TThreadItem;
721                 function GetActiveList: TObject;
722
723                 procedure SetListViewType(AViewType: TGikoViewType); overload;
724                 procedure SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean); overload;
725                 procedure PlaySound(SoundEventName: string);
726                 procedure ShowBBSTree( inBBS : TBBS );
727                 procedure ShowBBSTreeOld( inBBS : TBBS );
728                 procedure ShowHistoryTree;
729                 procedure AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
730                 procedure SetBrowserTabState;
731                 procedure SetToolBarPopup;
732                 procedure ShowFavoriteAddDialog( Item : TObject );
733                 procedure FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
734                 procedure RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
735                 property ListViewBackGroundColor: TColor read FListViewBackGroundColor write SetListViewBackGroundColor;
736                 property UseOddResOddColor : Boolean read FUseOddResOddColor write FUseOddResOddColor;
737                 property OddColor : TColor read FOddColor write FOddColor;
738                 function FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
739                 procedure OnPlugInMenuItem( Sender : TObject );
740                 procedure TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
741                 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91¶ KuroutSetting\82©\82ç\82æ\82Ñ\82¾\82µ\82½\82¢\82Ì\82Å
742                 procedure ActiveListColumnSave;
743                 procedure SetActiveList(Obj: TObject);
744                 property ActiveList: TObject read GetActiveList write SetActiveList;
745                 /// CoolBar \82ª\83T\83C\83Y\95Ï\8dX\82³\82ê\82½
746                 procedure       CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
747                 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
748                 procedure IndividualAbonID(Atype : Integer);
749                 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
750                 procedure IndividualAbon(Atag, Atype : Integer);
751                 //\83u\83\89\83E\83U\82Ì\8dÄ\95`\89æ true:\91S\82Ä\82Ì\83^\83u false:\83A\83N\83e\83B\83u\82È\83^\83u\82Ì\82Ý
752                 procedure RepaintAllTabsBrowser();
753                 //\83\8a\83\93\83N\83o\81[\90Ý\92è
754                 procedure SetLinkBar;
755                 procedure FavoriteBrowseFolder( node: TTreeNode );
756                 //\83X\83\8c\83b\83h\82Ì\83_\83E\83\93\83\8d\81[\83h
757                 procedure DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
758                 //\94Â\82Ì\83_\83E\83\93\83\8d\81[\83h
759                 procedure DownloadList(Board: TBoard; ForceDownload: Boolean = False);
760                 //\97\9a\97ð\82©\82ç\8dí\8f\9c
761                 procedure DeleteHistory( threadItem: TThreadItem );
762                 //\83^\83u\82ð\8dí\8f\9c \83X\83\8c\83b\83h\8ew\92è
763                 procedure DeleteTab(ThreadItem: TThreadItem); overload;
764                 //\83^\83u\82ð\8dí\8f\9c \83u\83\89\83E\83U\83\8c\83R\81[\83h\81i\83^\83u\81j\8ew\92è
765                 procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
766         // \83^\83u\8dí\8f\9c\81i\8eÀ\91\95\95\94\81j
767         procedure DeleteTab(index, selectIndex: Integer); overload;
768                 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
769                 procedure BrowserMovement(const AName: string);
770                 //Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
771                 function GetMainForm(): TComponent;
772                 procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
773                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\8en
774                 procedure OnGestureStart(Sender: TObject);
775                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\92\86
776                 procedure OnGestureMove(Sender: TObject);
777                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8fI\97¹
778                 procedure OnGestureEnd(Sender: TObject);
779                 /// \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
780                 procedure ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
781                 //ListView\82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é
782                 procedure SelectListItem(List: TList);
783                 //\8ew\92è\82µ\82½\83\8c\83X\82ð\83R\83s\81[\82·\82é
784                 procedure KonoresCopy(Number: Integer; ReplaceTag : Boolean);
785                 //
786                 procedure ModifySelectList;
787                 //
788                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string); overload;
789                 //
790                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string); overload;
791                 //
792                 procedure SetSelectRoundName(Sender: TObject);
793                 //
794                 function GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
795                 //
796                 function WebBrowserClick(Sender: TObject): WordBool;
797                 //! \83c\81[\83\8b\83o\81[\82É\83X\83\8c\8di\8d\9e\82Ý\83R\83\93\83{\83{\83b\83N\83X\82ð\90Ý\92è\82·\82é
798                 procedure SetSelectComboBox();
799
800         //! \83^\83X\83N\83g\83\8c\83C\82É\8ai\94[\82µ\82½\83A\83C\83R\83\93\82ð\83N\83\8a\83b\83N\82µ\82½\82Æ\82«\82Ì\8f\88\97\9d
801         procedure TaskTrayIconMessage(var Msg : TMsg); message WM_USER + 2010;
802         //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
803         procedure StoredTaskTray;
804         published
805                 property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
806         end;
807
808         TFavoriteMenuItem = class(TMenuItem)
809         private
810                 FData : Pointer;
811         public
812                 property Data: Pointer read FData write FData;
813         end;
814
815         TBBSMenuItem = class(TMenuItem)
816         private
817                 FData : Pointer;
818         public
819                 property Data: Pointer read FData write FData;
820         end;
821
822         TLinkToolButton = class(TToolButton)
823         private
824                 FData : Pointer;
825         public
826                 property Data: Pointer read FData write FData;
827         end;
828
829 var
830         GikoForm: TGikoForm;
831
832 implementation
833
834 uses
835         GikoUtil, IndividualAbon, Math, Kotehan, KeySetting,
836         YofUtils, ToolBarUtil, ToolBarSetting,
837         GikoXMLDoc, RoundName, IniFiles, FavoriteAdd,
838         FavoriteArrange, AddressHistory, Gesture,
839         About, Option, Round, Splash, Sort, ListSelect, Imm,
840         NewBoard, MojuUtils, Clipbrd, GikoBayesian,Y_TextConverter,
841         HTMLCreate, ListViewUtils, GikoDataModule, GikoMessage,
842   InputAssistDataModule, Types;
843
844 const
845         BLANK_HTML: string = 'about:blank';
846         BROWSER_COUNT           = 5;    //\83u\83\89\83E\83U\82Ì\90\94
847         //D&D臒l
848         DandD_THRESHOLD = 5;    //D&D\82Ìè\87\92l\81ipixcel)
849         //\83v\83\8c\83r\83\85\81[\83t\83@\83C\83\8b\96¼
850         HTML_FILE_NAME  = 'temp_preview.html';
851         //\83\81\83b\83Z\81[\83WID
852         USER_TREECLICK                                  = WM_USER + 2000;
853         USER_RESIZED            = WM_USER + 2001;
854         USER_MINIMIZED                                  = WM_USER + 2002;
855         USER_SETLINKBAR                                 = WM_USER + 2003;
856         USER_DOCUMENTCOMPLETE           = WM_USER + 2004;       ///< wParam : TWebBrowser
857     USER_TASKTRAY               = WM_USER + 2010;
858 {$R *.DFM}
859
860 procedure TGikoForm.CreateParams(var Params: TCreateParams);
861 begin
862         inherited;
863         if FormStyle in [fsNormal, fsStayOnTop] then begin
864                 if BorderStyle in [bsSingle, bsSizeable] then begin
865                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
866                         Params.WndParent := 0;
867                 end;
868         end;
869 end;
870
871 procedure TGikoForm.FormCreate(Sender: TObject);
872 const
873         TVS_NOTOOLTIPS = $0080;
874 var
875         FileName: string;
876         Style: DWORD;
877         msg: string;
878         i: Integer;
879         wp: TWindowPlacement;
880 begin
881 {$IFDEF DEBUG}
882         AllocConsole;
883         Writeln('============================================================');
884         Writeln(' \83M\83R\83i\83r\83f\83o\83b\83\83R\83\93\83\\81[\83\8b');
885         Writeln('');
886         Writeln(' \82±\82Ì\89æ\96Ê\82ð\95Â\82\82È\82¢\82Å\82­\82¾\82³\82¢\81B');
887         Writeln(' \8fI\97¹\8e\9e\82Í\81A\83M\83R\83i\83r\83E\83B\83\93\83h\83E\82ð\95Â\82\82Ä\82­\82¾\82³\82¢');
888         Writeln('============================================================');
889 {$ENDIF}
890 //try
891         Sort.SetSortDate(Now());
892         
893         FTreeType := gttNone;
894         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô
895         FStartUp := true;
896         Application.HookMainWindow(Hook);
897         FIsIgnoreResize := rtResizing;
898         //ActionList\82ÌGuoupIndex\82ð\95Û\91\82µ\82Ä\81A0\82É\83N\83\8a\83A\82·\82é\81B
899         //(\8bN\93®\8e\9e\82É\83c\81[\83\8b\83{\83^\83\93\82ÌDown\83v\83\8d\83p\83e\83B\82ð\94½\89f\82³\82¹\82é\93s\8d\87\8fãGroupIndex\82Í\90Ý\92è\82Å\82«\82È\82¢)
900         //\82±\82ê\88È\8cãSet\81`\82Å\8dÄ\90Ý\92è\82·\82é\82Ü\82Å\81AAction\82ÌChecked\82ð\82¢\82\82é\82Æ\82«\82Í\92\8d\88Ó\81I
901         GetGroupIndex(GikoDM.GikoFormActionList);
902         FSearchDialog := nil;
903         CreateBrowsers(BROWSER_COUNT);
904     FIconData.uID := 0;
905     
906         //\83\81\83j\83\85\81[\83t\83H\83\93\83g
907         SetMenuFont;
908
909         //\8eè\82Ì\83J\81[\83\\83\8b
910         Screen.Cursors[5] := LoadCursor(HInstance, 'GIKOHAND');
911
912         //\83A\83h\83\8c\83X\97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
913         AddressHistoryDM.ReadHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
914
915         EnabledCloseButton := True;
916
917         //\83\8a\83X\83g\83X\83^\83C\83\8b
918         ListView.ViewStyle := GikoSys.Setting.ListStyle;
919
920         //\83A\83j\83\81\83p\83l\83\8b\88Ê\92u
921         AnimePanel.Top := 0;
922         AnimePanel.Left := 0;
923
924         //\8ae\8eí\89Â\8e\8b\8fó\91Ô\82È\82Ç\90Ý\92è
925
926         //\83L\83\83\83r\83l\83b\83g
927         CabinetPanel.Width := GikoSys.Setting.CabinetWidth;
928
929         //\83\81\83b\83Z\81[\83W\83o\81[
930         GikoDM.MsgBarVisibleAction.Checked := GikoSys.Setting.MessageBarVisible;
931         GikoDM.MsgBarVisibleActionExecute(nil);
932         MessagePanel.Height := GikoSys.Setting.MessegeBarHeight;
933
934         //\83X\83e\81[\83^\83X\83o\81[
935         GikoDM.StatusBarVisibleAction.Checked := GikoSys.Setting.StatusBarVisible;
936         GikoDM.StatusBarVisibleActionExecute(nil);
937
938         //\83t\83H\83\93\83g\81E\90F\90Ý\92è
939         TreeView.Items.BeginUpdate;
940         FavoriteTreeView.Items.BeginUpdate;
941         ListView.Items.BeginUpdate;
942         try
943                 TreeView.Font.Name := GikoSys.Setting.CabinetFontName;
944                 TreeView.Font.Size := GikoSys.Setting.CabinetFontSize;
945                 TreeView.Font.Color := GikoSys.Setting.CabinetFontColor;
946                 TreeView.Color := GikoSys.Setting.CabinetBackColor;
947                 FavoriteTreeView.Font.Assign(TreeView.Font);
948                 FavoriteTreeView.Color := GikoSys.Setting.CabinetBackColor;
949
950                 ListView.Font.Name := GikoSys.Setting.ListFontName;
951                 ListView.Font.Size := GikoSys.Setting.ListFontSize;
952                 ListView.Font.Color := GikoSys.Setting.ListFontColor;
953                 ListView.Font.Style := [];
954                 if GikoSys.Setting.ListFontBold then
955                         ListView.Font.Style := [fsbold];
956                 if GikoSys.Setting.ListFontItalic then
957                         ListView.Font.Style := ListView.Font.Style + [fsitalic];
958
959                 ListViewBackGroundColor := clWhite;                                                                                             // \83f\83t\83H\83\8b\83g\82É\90Ý\92è\82µ\82½\82Ì\82¿
960                 ListViewBackGroundColor := GikoSys.Setting.ListBackColor;       // \83\86\81[\83U\92è\8b`\82É\95Ï\8dX
961                 FUseOddResOddColor := GikoSys.Setting.UseOddColorOddResNum;
962                 FOddColor := GikoSys.Setting.OddColor;
963
964         finally
965                 TreeView.Items.EndUpdate;
966                 FavoriteTreeView.Items.EndUpdate;
967                 ListView.Items.EndUpdate;
968         end;
969         //ViewNoButton.Down := GikoSys.Setting.ListViewNo;
970         GikoDM.ListNumberVisibleAction.Checked := GikoSys.Setting.ListViewNo;
971
972         //\83~\83\85\81[\83g\82Ì\8fó\91Ô\82ð\90Ý\92è
973         GikoDM.MuteAction.Checked := GikoSys.Setting.Mute;
974
975         // \83\8c\83X\95\\8e¦\94Í\88Í
976         FResRangeMenuSelect := GikoSys.ResRange;
977         case GikoSys.ResRange of
978         Ord( grrAll ):
979                 begin
980                         GikoDM.AllResAction.Execute;
981                 end;
982         Ord( grrSelect ):
983                 begin
984                         SelectComboBox.Text := SelectComboBox.Items[ 1 ];
985                         GikoDM.SelectResAction.Checked := True;
986                 end;
987         else
988                 case FResRangeMenuSelect of
989                 Ord( grrKoko ): GikoDM.OnlyKokoResAction.Checked        := True;
990                 Ord( grrNew ):  GikoDM.OnlyNewResAction.Checked := True;
991                 100:                    GikoDM.OnlyAHundredResAction.Checked            := True;
992                 end;
993         end;
994
995         // \83X\83\8c\83b\83h\88ê\97\97\95\\8e¦\94Í\88Í
996         case GikoSys.Setting.ThreadRange of
997         gtrAll:
998                 begin
999                         GikoDM.AllItemAction.Checked := True;
1000                         ViewType := gvtAll;
1001                 end;
1002         gtrLog:
1003                 begin
1004                         GikoDM.LogItemAction.Checked := True;
1005                         ViewType := gvtLog;
1006                 end;
1007         gtrNew:
1008                 begin
1009                         GikoDM.NewItemAction.Checked := True;
1010                         ViewType := gvtNew;
1011                 end;
1012         gtrLive:
1013                 begin
1014                         GikoDM.LiveItemAction.Checked := True;
1015                         ViewType := gvtLive;
1016                 end;
1017         gtrArch:
1018                 begin
1019                         GikoDM.ArchiveItemAction.Checked := True;
1020                         ViewType := gvtArch;
1021                 end;
1022         end;
1023
1024
1025         //\83u\83\89\83E\83U\83^\83u\83t\83H\83\93\83g
1026         BrowserTab.Font.Name := GikoSys.Setting.BrowserTabFontName;
1027         BrowserTab.Font.Size := GikoSys.Setting.BrowserTabFontSize;
1028         BrowserTab.Font.Style := [];
1029         if GikoSys.Setting.BrowserTabFontBold then
1030                 BrowserTab.Font.Style := [fsBold];
1031         if GikoSys.Setting.BrowserTabFontItalic then
1032                 BrowserTab.Font.Style := GikoForm.BrowserTab.Font.Style + [fsItalic];
1033         BrowserTab.DoubleBuffered := True;
1034         FDragWFirst := false;
1035         SetContent(BrowserNullTab);                                                                                                     //\83u\83\89\83E\83U\82ð\8bó\94\92\95\\8e¦
1036
1037         //\83u\83\89\83E\83U\83^\83u
1038         GikoDM.BrowserTabVisibleAction.Checked := GikoSys.Setting.BrowserTabVisible;
1039
1040         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
1041                 GikoDM.BrowserTabTopAction.Checked := True;
1042         end else begin
1043                 GikoDM.BrowserTabBottomAction.Checked := True;
1044         end;
1045
1046         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
1047                 GikoDM.BrowserTabTabStyleAction.Checked := True;
1048         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
1049                 GikoDM.BrowserTabButtonStyleAction.Checked := True;
1050         end else begin
1051                 GikoDM.BrowserTabFlatStyleAction.Checked := True;
1052         end;
1053
1054         //\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\8f\89\8aú\89»
1055         ProgressBar.Parent := StatusBar;
1056         ProgressBar.Top := 2;
1057         ProgressBar.Left := 0;
1058         ProgressBar.Width := StatusBar.Panels[0].Width;
1059         ProgressBar.Height := StatusBar.Height - 2;
1060         ProgressBar.Position := 0;
1061
1062         // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1063         InitializeBoardPlugIns;
1064
1065         // \83{\81[\83h\83t\83@\83C\83\8b\97ñ\8b\93(ReadFavorite \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1066         GikoSys.ListBoardFile;
1067         //\81@\98A\91±\8bN\93®\8e\9e\82É\83X\83v\83\89\83b\83V\83\85\83E\83B\83\93\83h\83E\82Ì\83\81\83\82\83\8a\82ª\95s\92è\82É
1068         try
1069         // \83X\83v\83\89\83b\83V\83\85\83E\83B\83\93\83h\83E\82Ì\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\90Ý\92è
1070                 if (SplashWindow <> nil) then begin
1071                         SplashWindow.ProgressBar.Max := Length(BBSs) * 20;
1072                 end;
1073         except
1074         end;
1075         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1076         for i := Length(BBSs) - 1 downto 0 do begin
1077                 if not BBSs[i].IsBoardFileRead then
1078                         GikoSys.ReadBoardFile(BBSs[i]);
1079
1080                 if SplashWindow <> nil then begin
1081                         SplashWindow.ProgressBar.StepBy(20);
1082                         SplashWindow.Update;
1083                 end;
1084         end;
1085
1086         //\8f\84\89ñ\83f\81[\83^\93Ç\82Ý\8d\9e\82Ý
1087         RoundList := TRoundList.Create;
1088         RoundList.LoadRoundBoardFile;
1089         RoundList.LoadRoundThreadFile;
1090
1091         //TreeView\82Ì\8e×\96\82\8fL\82¢ToolTip\82ð\94ñ\95\\8e¦
1092         Style := GetWindowLong(TreeView.Handle, GWL_STYLE);
1093         Style := Style or TVS_NOTOOLTIPS;
1094         SetWindowLong(TreeView.Handle, GWL_STYLE, Style);
1095
1096         // \83c\83\8a\81[\82ð\83\81\83C\83\93\82¾\82¯\95\\8e¦\82É\82µ\82Ä\8dÅ\91å\89»
1097         TreeView.Align := alClient;
1098         FavoriteTreeView.Align := alClient;
1099         FavoriteTreeView.Visible := False;
1100
1101         // \83\81\83j\83\85\81[\82É\92Ç\89Á
1102         SetBBSMenu;
1103
1104         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95\9c\8c³
1105         wp.length := sizeof(wp);
1106         wp.rcNormalPosition.Top := GikoSys.Setting.WindowTop;
1107         wp.rcNormalPosition.Left := GikoSys.Setting.WindowLeft;
1108         wp.rcNormalPosition.Bottom := GikoSys.Setting.WindowTop + GikoSys.Setting.WindowHeight;
1109         wp.rcNormalPosition.Right := GikoSys.Setting.WindowLeft + GikoSys.Setting.WindowWidth;
1110         wp.showCmd := SW_HIDE;
1111         SetWindowPlacement(Handle, @wp);
1112         //Self.Update;
1113
1114         if GikoSys.Setting.WindowMax then
1115                 WindowState := wsMaximized;
1116
1117         //\83M\83R\83A\83j\83\81
1118         try
1119                 FileName := GikoSys.GetAppDir + 'gikoNavi.avi';
1120                 if FileExists(FileName) then
1121                         Animate.FileName := FileName;
1122         except
1123         end;
1124
1125         //\83N\83b\83L\81[
1126         FNameCookie := '';
1127         FMailCookie := '';
1128
1129         //\83u\83\89\83E\83U\83T\83C\83Y\95Ï\8dX\82Ì\8f\89\8aú\89»
1130         FBrowserSizeHeight := GikoSys.Setting.ListHeight;
1131         FBrowserSizeWidth := GikoSys.Setting.ListWidth;
1132
1133
1134         // \83q\83X\83g\83\8a\83\8a\83X\83g(LoadHistory \82æ\82è\82à\90æ\82É\8ds\82¤\82±\82Æ)
1135         FHistoryList := THistoryList.Create;
1136
1137         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1138         FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1139         TreeView, FTreeType);
1140
1141         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1142         FavoriteDM.SetFavTreeView(FavoriteTreeView);
1143         FavoriteDM.ReadFavorite;
1144
1145         GikoDM.ArrangeAction.Checked := not (GikoSys.Setting.ListOrientation = gloVertical);
1146         GikoDM.ArrangeAction.Execute;
1147
1148         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
1149                 case GikoSys.Setting.ListWidthState of
1150                         glsMax: begin
1151                                 ViewPanel.Width := 1;
1152                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1153                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1154                         end;
1155                         glsMin: begin
1156                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1157                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1158                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1159                         end;
1160                         else begin
1161                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1162                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1163                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1164                         end;
1165                 end;
1166         end else begin
1167                 case GikoSys.Setting.ListHeightState of
1168                         glsMax: begin
1169                                 ViewPanel.Height := 1;
1170                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1171                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1172                         end;
1173                         glsMin: begin
1174                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1175                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1176                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1177                         end;
1178                         else begin
1179                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1180                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1181                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1182                         end;
1183                 end;
1184         end;
1185
1186         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
1187         CreateControlThread();
1188
1189         // \8di\8d\9e\8c\9f\8dõ\97\9a\97ð
1190         SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
1191
1192         //\83u\83\89\83E\83U\83^\83u\90Ý\92è
1193         SetBrowserTabState;
1194
1195         BrowserBoardNameLabel.Caption := '';
1196         BrowserNameLabel.Caption := '';
1197         FWorkCount := 0;
1198
1199         FTabHintIndex := -1;
1200
1201         //\83c\81[\83\8b\83o\81[Wrapable
1202         ListToolBar.Wrapable := GikoSys.Setting.ListToolBarWrapable;
1203         BrowserToolBar.Wrapable := GikoSys.Setting.BrowserToolBarWrapable;
1204
1205         MakeDefaultINIFile();
1206         //\83c\81[\83\8b\83{\83^\83\93\93Ç\82Ý\8d\9e\82Ý
1207         ReadToolBarSetting(GikoDM.GikoFormActionList, StdToolBar);
1208         ReadToolBarSetting(GikoDM.GikoFormActionList, ListToolBar);
1209         ReadToolBarSetting(GikoDM.GikoFormActionList, BrowserToolBar);
1210         SetToolBarPopup;
1211
1212         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
1213         SetSelectComboBox();
1214
1215         //\83A\83h\83\8c\83X\83o\81[
1216         AddressComboBox.TabStop := GikoSys.Setting.AddressBarTabStop;
1217
1218         //\83\8a\83\93\83N\83o\81[
1219         SetLinkBar;
1220         //\83N\81[\83\8b\83o\81[\95\9c\8c³\82ÍFormShow\82É\88Ú\93®\82µ\82½
1221
1222         //\83{\81[\83h\83t\83@\83C\83\8b\82ª\96³\82¢\8fê\8d\87\82Í\83\81\83b\83Z\81[\83W\95\\8e¦
1223         if not FileExists(GikoSys.GetBoardFileName) then begin
1224                 msg := '\82±\82Ì\83\81\83b\83Z\81[\83W\82Í\83M\83R\83i\83r\82ð\8f\89\82ß\82Ä\8eg\97p\82·\82é\82Æ\82«\82É\82P\89ñ\82¾\82¯\95\\8e¦\82³\82ê\82Ü\82·' + #13#10#13#10
1225                                  + '\82±\82ê\82©\82ç\81A\81u\82Q\82¿\82á\82ñ\82Ë\82é\81v\82Ì\83A\83h\83\8c\83X\88ê\97\97\82ð\83_\83E\83\93\83\8d\81[\83h\82µ\82Ü\82·' + #13#10
1226                                  + '\8e\9f\82É\8fo\82Ä\82­\82é\89æ\96Ê\82Å\81A\81u\8dX\90V\81v\83{\83^\83\93\82ð\89\9f\82µ\82Ä\82­\82¾\82³\82¢\81B';
1227                 MsgBox(SplashWindow.Handle, msg, '\83M\83R\83i\83r', MB_OK or MB_ICONINFORMATION);
1228                 GikoDM.NewBoardAction.Execute;
1229         end;
1230
1231         //\83L\81[\90Ý\92è\93Ç\82Ý\8d\9e\82Ý
1232         GikoSys.LoadKeySetting(GikoDM.GikoFormActionList, GikoSys.GetMainKeyFileName);
1233
1234         //\8dÅ\8fI\8f\84\89ñ\8e\9e\8aÔ
1235 //      FLastRoundTime := 0;
1236
1237         //ResHint
1238         FHint := TResPopup.Create(Self);
1239
1240         ListView.OnData := TListViewUtils.ListViewData;
1241
1242         // \8dÅ\8cã\82É\91I\91ð\82³\82ê\82½\83L\83\83\83r\83l\83b\83g\82Ì\95\9c\8c³
1243         CabinetVisible( False );
1244         if GikoSys.Setting.CabinetVisible then begin
1245                 i := CabinetSelectPopupMenu.Items.Count - 1;
1246                 if GikoSys.Setting.CabinetIndex = i - 1 then
1247                         GikoDM.CabinetHistoryAction.Execute
1248                 else if GikoSys.Setting.CabinetIndex = i then
1249                         GikoDM.CabinetFavoriteAction.Execute
1250                 else begin
1251                         if GikoSys.Setting.CabinetIndex < Length( BBSs ) then
1252                                 ShowBBSTree( BBSs[ GikoSys.Setting.CabinetIndex ] );
1253                         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô 2
1254                         FIsIgnoreResize := rtResizing;
1255                         GikoDM.CabinetBBSAction.Execute;
1256                 end;
1257         end else begin
1258                 ShowBBSTreeOld( BBSs[ 0 ] );
1259                 PostMessage( Handle, USER_TREECLICK, 0, 0 );
1260         end;
1261
1262         //\88ø\90\94\82ª\82 \82Á\82½\82ç\83X\83\8c\82ð\8aJ\82­\81i\96¢\8eæ\93¾\82È\82ç\83_\83E\83\93\83\8d\81[\83h\81j
1263         for i := 1 to ParamCount do     begin
1264                 MoveToURL(ParamStr(i));
1265         end;
1266
1267         GikoDM.RepaintStatusBar;
1268         StatusBarResize(Sender);
1269
1270         dummy1.Caption  := ItemReservPMenu.Caption;
1271         dummy1.Hint     := ItemReservPMenu.Hint;
1272
1273 {$IFDEF SPAM_FILTER_ENABLED}
1274         // \83X\83p\83\80\83t\83B\83\8b\83^\8aw\8fK\97\9a\97ð
1275         GikoSys.Bayesian.LoadFromFile( GikoSys.Setting.GetSpamFilterFileName );
1276 {$ENDIF}
1277
1278         // \83}\83E\83X\83W\83F\83X\83`\83\83\81[
1279         MouseGesture := TMouseGesture.Create;
1280         GikoSys.Setting.Gestures.LoadGesture(
1281                 GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
1282         MouseGesture.Margin := GikoSys.Setting.Gestures.Margin;
1283         MouseGesture.OnGestureStart := OnGestureStart;
1284         MouseGesture.OnGestureMove := OnGestureMove;
1285         MouseGesture.OnGestureEnd := OnGestureEnd;
1286         if GikoSys.Setting.GestureEnabled then
1287                 MouseGesture.SetHook( Handle );
1288
1289         //2ch\8c¾\8cê\93Ç\82Ý\8fo\82µ
1290         GikoSys.SetGikoMessage;
1291
1292         //\83I\81[\83g\83\8d\83O\83C\83\93
1293         if GikoSys.Setting.AutoLogin then
1294                 GikoDM.LoginAction.Execute;
1295
1296         GikoSys.Setting.BeLogin := GikoSys.Setting.BeAutoLogin;
1297
1298         //\83L\83\83\83v\83V\83\87\83\93\82ª\8fã\8f\91\82«\82³\82ê\82Ä\82µ\82Ü\82¤\82Ì\82Å\81A\82±\82±\82Å\8dÄ\90Ý\92è
1299         FavoriteAddToolButton.Caption := '\92Ç\89Á...';
1300         AntiIndivAbonMenuItem.Caption := '\8cÂ\95Ê\82 \82Ú\81`\82ñ\89ð\8f\9c';
1301
1302         //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\8f\89\8aú\89»
1303         InputAssistDM.Init(GikoSys.GetInputAssistFileName);
1304
1305 end;
1306
1307 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82É\95Û\91
1308 procedure TGikoForm.SaveCoolBarSettings;
1309 begin
1310
1311         if IsIconic( Handle ) or (FIsIgnoreResize <> rtNone) then
1312                 Exit;
1313         SaveMainCoolBarSettings;
1314         SaveBoardCoolBarSettings;
1315         SaveBrowserCoolBarSettings;
1316
1317 end;
1318 procedure TGikoForm.SaveMainCoolBarSettings;
1319 var
1320         i : Integer;
1321         CoolSet : TCoolSet;
1322 begin
1323         //\83N\81[\83\8b\83o\81[\95Û\91¶(Main)
1324         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
1325                 CoolSet.FCoolID := MainCoolBar.Bands[i].ID;
1326                 CoolSet.FCoolWidth := MainCoolBar.Bands[i].Width;
1327                 CoolSet.FCoolBreak := MainCoolBar.Bands[i].Break;
1328                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
1329         end;
1330 end;
1331 procedure TGikoForm.SaveBoardCoolBarSettings;
1332 var
1333         i : Integer;
1334         CoolSet : TCoolSet;
1335 begin
1336         //\83N\81[\83\8b\83o\81[\95Û\91¶(Board)
1337         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
1338                 CoolSet.FCoolID := ListCoolBar.Bands[i].ID;
1339                 CoolSet.FCoolWidth := ListCoolBar.Bands[i].Width;
1340                 CoolSet.FCoolBreak := ListCoolBar.Bands[i].Break;
1341                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
1342         end;
1343 end;
1344 procedure TGikoForm.SaveBrowserCoolBarSettings;
1345 var
1346         i : Integer;
1347         CoolSet : TCoolSet;
1348 begin
1349         //\83N\81[\83\8b\83o\81[\95Û\91¶(Browser)
1350         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
1351                 CoolSet.FCoolID := BrowserCoolBar.Bands[i].ID;
1352                 CoolSet.FCoolWidth := BrowserCoolBar.Bands[i].Width;
1353                 CoolSet.FCoolBreak := BrowserCoolBar.Bands[i].Break;
1354                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
1355         end;
1356 end;
1357 // CoolBar \82Ì\90Ý\92è\82ð\95Ï\90\94\82©\82ç\95\9c\8c³
1358 procedure TGikoForm.LoadCoolBarSettings;
1359 var
1360         i                               : Integer;
1361         CoolSet : TCoolSet;
1362 begin
1363
1364         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Main)
1365         MainCoolBar.Bands.BeginUpdate;
1366         try
1367 //              for i := 0 to MainCoolBar.Bands.Count - 1 do begin
1368                 for i := MAIN_COOLBAND_COUNT - 1 downto 0 do begin
1369                         CoolSet := GikoSys.Setting.MainCoolSet[i];
1370                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1371                                 FIsIgnoreResize := rtNone;
1372                                 SaveCoolBarSettings;
1373                                 Exit;
1374                         end;
1375                         MainCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1376                         MainCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1377                         MainCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1378                 end;
1379         finally
1380                 MainCoolBar.Bands.EndUpdate;
1381         end;
1382
1383         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Board)
1384         ListCoolBar.Bands.BeginUpdate;
1385         try
1386 //              for i := 0 to ListCoolBar.Bands.Count - 1 do begin
1387                 for i := LIST_COOLBAND_COUNT - 1 downto 0 do begin
1388                         CoolSet := GikoSys.Setting.ListCoolSet[i];
1389                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1390                                 FIsIgnoreResize := rtNone;
1391                                 SaveCoolBarSettings;
1392                                 Exit;
1393                         end;
1394                         ListCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1395                         ListCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1396                         ListCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1397                 end;
1398         finally
1399                 ListCoolBar.Bands.EndUpdate;
1400         end;
1401
1402         //\83N\81[\83\8b\83o\81[\95\9c\8c³(Browser)
1403         BrowserCoolBar.Bands.BeginUpdate;
1404         try
1405 //              for i := 0 to BrowserCoolBar.Bands.Count - 1 do begin
1406                 for i := BROWSER_COOLBAND_COUNT - 1 downto 0 do begin
1407                         CoolSet := GikoSys.Setting.BrowserCoolSet[i];
1408                         if (CoolSet.FCoolID = -1) or (CoolSet.FCoolWidth = -1) then begin
1409                                 FIsIgnoreResize := rtNone;
1410                                 SaveCoolBarSettings;
1411                                 Exit;
1412                         end;
1413                         BrowserCoolBar.Bands.FindItemID(CoolSet.FCoolID).Index := i;
1414                         BrowserCoolBar.Bands[i].Break := CoolSet.FCoolBreak;
1415                         BrowserCoolBar.Bands[i].Width := CoolSet.FCoolWidth;
1416                 end;
1417         finally
1418                 BrowserCoolBar.Bands.EndUpdate;
1419         end;
1420
1421 end;
1422 //
1423 procedure TGikoForm.FormShow(Sender: TObject);
1424 begin
1425         if FStartUp then begin
1426                 ShowWindow(Application.Handle, SW_HIDE);
1427
1428                 //FormCreate\82Å\82â\82é\82Æ\89Â\8e\8b\90Ý\92è\82ª\94½\89f\82³\82ê\82È\82¢\8fê\8d\87\82ª\82 \82é\82Ì\82ÅFormShow\82Å\82â\82é\82±\82Æ\82É\82µ\82½
1429                 //\83c\81[\83\8b\83o\81[\95\\8e¦
1430                 GikoDM.StdToolBarVisibleAction.Checked := GikoSys.Setting.StdToolBarVisible;
1431                 GikoDM.StdToolBarVisibleActionExecute( nil );
1432                 GikoDM.AddressBarVisibleAction.Checked := GikoSys.Setting.AddressBarVisible;
1433                 GikoDM.AddressBarVisibleActionExecute( nil );
1434                 GikoDM.LinkBarVisibleAction.Checked := GikoSys.Setting.LinkBarVisible;
1435                 GikoDM.LinkBarVisibleActionExecute( nil );
1436                 GikoDM.ListToolBarVisibleAction.Checked := GikoSys.Setting.ListToolBarVisible;
1437                 GikoDM.ListToolBarVisibleActionExecute( nil );
1438                 GikoDM.ListNameBarVisibleAction.Checked := GikoSys.Setting.ListNameBarVisible;
1439                 GikoDM.ListNameBarVisibleActionExecute( nil );
1440                 GikoDM.BrowserToolBarVisibleAction.Checked := GikoSys.Setting.BrowserToolBarVisible;
1441                 GikoDM.BrowserToolBarVisibleActionExecute( nil );
1442                 GikoDM.BrowserNameBarVisibleAction.Checked := GikoSys.Setting.BrowserNameBarVisible;
1443                 GikoDM.BrowserNameBarVisibleActionExecute( nil );
1444
1445                 // CoolBar \95\9c\8c³
1446                 LoadCoolBarSettings;
1447
1448                 //\8fd\97v\81@\82±\82ê\82ª\82È\82¢\82Æ\83c\81[\83\8b\83{\83^\83\93\82Ì\8dX\90V\82ª\82¨\82©\82µ\82­\82È\82é
1449 //              ResetBandInfo( ListCoolBar, ListToolBar );
1450                 FIsIgnoreResize := rtNone;
1451
1452                 //FormCrete\82©\82ç\88Ú\93®\81B
1453                 if GikoSys.Setting.TabAutoLoadSave then begin
1454             GikoDM.TabsOpenAction.Tag := 1;
1455                         GikoDM.TabsOpenAction.Execute;
1456             GikoDM.TabsOpenAction.Tag := 0;
1457                 end;
1458
1459         //ActionList\82ÌGroupIndex\82ð\8c³\82É\96ß\82·
1460                 SetGroupIndex(GikoDM.GikoFormActionList);
1461
1462                 FStartUp := false;
1463         end;
1464 end;
1465
1466 procedure TGikoForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
1467 begin
1468 //      if GikoForm.WindowState <> wsMinimized then
1469 //              SaveCoolBarSettings;
1470         CanClose := True;
1471         if ( GikoSys.Setting.ShowDialogForEnd ) and
1472                         (MessageDlg('\83M\83R\83i\83r\82ð\8fI\97¹\82µ\82Ä\82æ\82ë\82µ\82¢\82Å\82·\82©\81H', mtConfirmation,[mbOk, mbCancel], 0) = mrCancel ) then begin
1473                 CanClose := false;
1474                         Exit;
1475         end;
1476
1477         if GikoSys.Setting.TabAutoLoadSave then begin
1478                 GikoDM.TabsSaveAction.Execute;
1479         end;
1480
1481         if (SearchDialog <> nil) then begin
1482                 if (SearchDialog.Visible) then begin
1483                         SearchDialog.Close;
1484                         try
1485                                 SearchDialog.Release;
1486                         except
1487                         end;
1488                         SearchDialog := nil;
1489                 end;
1490         end;
1491
1492         //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\95Â\82\82é
1493     GikoDM.CloseAllEditorAction.Execute;
1494
1495         Application.UnhookMainWindow(Hook);
1496         Application.Terminate;
1497 end;
1498
1499 procedure TGikoForm.FormDestroy(Sender: TObject);
1500 var
1501         i                               : Integer;
1502 //      CoolSet: TCoolSet;
1503         wp                      : TWindowPlacement;
1504         tmpBool : Boolean;
1505 begin
1506         // \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\95ú
1507         try
1508                 MouseGesture.UnHook;
1509         except
1510         end;
1511         try
1512                 ActiveListColumnSave;
1513         except
1514         end;
1515         try
1516                 //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
1517                 wp.length := sizeof(wp);
1518                 GetWindowPlacement(Handle, @wp);
1519                 GikoSys.Setting.WindowTop := wp.rcNormalPosition.Top;
1520                 GikoSys.Setting.WindowLeft := wp.rcNormalPosition.Left;
1521                 GikoSys.Setting.WindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
1522                 GikoSys.Setting.WindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
1523                 GikoSys.Setting.WindowMax := WindowState = wsMaximized;
1524
1525                 GikoSys.Setting.ListStyle := ListView.ViewStyle;
1526                 GikoSys.Setting.CabinetVisible := GikoDM.CabinetVisibleAction.Checked;
1527                 GikoSys.Setting.CabinetWidth := CabinetPanel.Width;
1528                 GikoSys.Setting.ListHeight := FBrowserSizeHeight;
1529                 GikoSys.Setting.ListWidth := FBrowserSizeWidth;
1530                 if GikoDM.ArrangeAction.Checked then
1531                         GikoSys.Setting.ListOrientation := gloVertical
1532                 else
1533                         GikoSys.Setting.ListOrientation := gloHorizontal;
1534                 GikoSys.Setting.MessegeBarHeight := MessagePanel.Height;
1535         except
1536         end;
1537
1538         try
1539                 // \83\8c\83X\95\\8e¦\94Í\88Í
1540                 if not GikoSys.Setting.ResRangeHold then
1541                         GikoSys.Setting.ResRange := FResRangeMenuSelect;
1542         except
1543         end;
1544         if WindowState <> wsNormal then
1545                 WindowState := wsNormal;
1546         SaveCoolBarSettings;
1547         try
1548                 GikoSys.Setting.WriteWindowSettingFile;
1549                 GikoSys.Setting.WriteNameMailSettingFile;
1550         except
1551         end;
1552         // \83\8a\83A\83\8b\83^\83C\83\80\82É\95Û\91\82³\82ê\82é\82Ì\82Å\81A\82Ü\82½\81A\83E\83B\83\93\83h\83E\83T\83C\83Y\82ª CoolBar \82æ\82è
1553         // \8f¬\82³\82­\82È\82Á\82Ä\82¢\82é\82Æ\82«\82É\95Û\91\82·\82é\82Æ\92l\82ª\8fã\8f\91\82«\82³\82ê\82Ä\82µ\82Ü\82¤\82Ì\82Å\82±\82±\82Å\82Í\95Û\91\82µ\82È\82¢
1554
1555                 // \81ªFormDestroy\92\86\82É\88Ú\93®\82µ\82½\82Ì\82Å\81A\82±\82±\82Å\95Û\91\82µ\82È\82¢\82Æ\82¢\82¯\82È\82¢\82Æ\8ev\82¤\81B\81i\82à\82\82ã\81@2004/04/09\81j
1556         // CoolBar \95Û\91
1557         //if (GikoForm.WindowState <> wsMinimized) and (GikoForm.WindowState <> wsMaximized) then
1558
1559         //\93ü\97Í\83A\83V\83X\83g\8b@\8d\\82Ì\90Ý\92è\82Ì\95Û\91
1560         InputAssistDM.SaveToFile(GikoSys.GetInputAssistFileName);
1561
1562         //\82¨\8bC\82É\93ü\82è\95Û\91
1563         try
1564                 //FavoriteDM\82Í\8e©\93®\90\90¬\83t\83H\81[\83\80\82È\82Ì\82Å\81A\89ð\95ú\82Í\8e©\93®\93I\82É\82³\82ê\82é
1565                 FavoriteDM.WriteFavorite;
1566                 FavoriteDM.Clear;
1567         except
1568         end;
1569         LockWindowUpdate(Self.Handle);
1570         try
1571                 //\83^\83u\83N\83\8d\81[\83Y
1572                 tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
1573                 GikoSys.Setting.ShowDialogForAllTabClose := false;
1574                 GikoDM.AllTabCloseAction.Execute;
1575                 GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
1576         except
1577         end;
1578         try
1579                 for i := FBrowsers.Count - 1 downto 0 do begin
1580                         TWebBrowser(FBrowsers[i]).Free;
1581                 end;
1582                 FBrowsers.Clear;
1583                 FBrowsers.Capacity := 0;
1584         finally
1585                 FBrowsers.Free;
1586         end;
1587         try
1588                 if BrowserNullTab <> nil then begin
1589                         BrowserNullTab.Browser := nil;  {*BrowserNullTab\82ÌBrowser\82Í\90Ý\8cv\8e\9e\82É\93\\82è\95t\82¯\82Ä\82é\93z
1590                                                                                          *\82È\82Ì\82Å\82±\82±\82ÅFree\82³\82ê\82é\82Æ\8d¢\82é\82Ì\82Å\82Í\82¸\82µ\82Ä\82µ\82Ü\82¤\81B
1591                                                                                          *}
1592                         BrowserNullTab.Free;
1593                 end;
1594         except
1595         end;
1596
1597         try
1598                 TreeView.Items.BeginUpdate;
1599                 TreeView.Items.GetFirstNode.Free;
1600                 TreeView.Items.Clear;
1601                 TreeView.Items.EndUpdate;
1602         except
1603         end;
1604
1605         //\83A\83h\83\8c\83X\97\9a\97ð\95Û\91
1606         try
1607                 //AddressHistoryDM\82Í\8e©\93®\90\90¬\83t\83H\81[\83\80\82È\82Ì\82Å\81A\89ð\95ú\82Í\8e©\93®\93I\82É\82³\82ê\82é\81B
1608                 AddressHistoryDM.WriteHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
1609         except
1610         end;
1611
1612         //\83q\83X\83g\83\8a\83\8a\83X\83g\95Û\91
1613         try
1614                 FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1615         except
1616         end;
1617         try
1618                 try
1619                         FHistoryList.Clear;
1620                 except
1621                 end;
1622         finally
1623                 FHistoryList.Free;
1624         end;
1625
1626         //\8f\84\89ñ\83\8a\83X\83g\95Û\91¶&\94j\8aü
1627         try
1628                 RoundList.SaveRoundFile;
1629         except
1630         end;
1631         try
1632                 try
1633                         RoundList.Clear;
1634                 except
1635                 end;
1636         finally
1637                 RoundList.Free;
1638          end;
1639
1640         try
1641                 try
1642                         FControlThread.Terminate;
1643                         FControlThread.WaitFor;
1644                 except
1645                 end;
1646         finally
1647                 FControlThread.Free;
1648         end;
1649     // \83v\83\89\83O\83C\83\93\82É\82æ\82Á\82Ä\92Ç\89Á\82³\82ê\82½\83\81\83j\83\85\81[\82ð\8aJ\95ú\82·\82é
1650     for i := GikoForm.PlugInMenu.Count - 1 downto 0 do begin
1651                 GikoForm.PlugInMenu.items[i].Free;
1652         end;
1653     GikoForm.PlugInMenu.Clear;
1654
1655
1656         // TBBS \82Í\95Û\8e\9d\82µ\82Ä\82¢\82é TCategory, TBoard, TThreadItem \82·\82×\82Ä\82ð\8aJ\95ú\82·\82é
1657         // TBoard, TThreadItem \82Ì\83f\83X\83g\83\89\83N\83^\82Í\83v\83\89\83O\83C\83\93\82É\94j\8aü\82ð\93`\82¦\82é\82Ì\82Å
1658         // BoardPluteIns \82Ì\8aJ\95ú\82æ\82è\90æ\82É\8ds\82¤\82±\82Æ
1659         for i := Length(BoardGroups) - 1 downto 0 do begin
1660                 //BoardGroups[i].Clear;
1661                 BoardGroups[i].Free;
1662         end;
1663
1664         try
1665                 for i := Length( BBSs ) - 1 downto 0 do begin
1666                         if BBSs[ i ] <> nil then
1667                                 BBSs[ i ].Free;
1668                         BBSs[ i ] := nil;
1669                 end;
1670         except
1671         end;
1672
1673         try
1674                 if FEvent <> nil then
1675                         FEvent.Free;
1676
1677                 //Hint\94j\8aü
1678                 if FHint <> nil then begin
1679                         FHint.ReleaseHandle;
1680                         FHint.Free;
1681                         FHint := nil;
1682                 end;
1683                 //Preview\94j\8aü
1684                 if TPreviewBrowser <> nil then begin
1685                         FPreviewBrowser.Free;
1686                         FPreviewBrowser := nil;
1687                 end;
1688         except
1689         end;
1690         LockWindowUpdate(0);
1691 end;
1692
1693 // \8ae\8f\8a\82É\82 \82é\83L\83\83\83r\83l\83b\83g\81E BBS \83\81\83j\83\85\81[\82ð\83Z\83b\83g\81^\8dX\90V
1694 procedure TGikoForm.SetBBSMenu;
1695 var
1696         i                       : Integer;
1697         item    : TBBSMenuItem;
1698 begin
1699
1700         // \83\81\83j\83\85\81[\82ð\8dí\8f\9c
1701         for i := CabinetSelectPopupMenu.Items.Count - 1 downto 0 do begin
1702                 try
1703                         if CabinetSelectPopupMenu.Items[ i ] is TBBSMenuItem then begin
1704                                 CabinetSelectPopupMenu.Items[ i ].Free;
1705                                 CabinetMenu.Items[ i ].Free;
1706                                 BBSSelectPopupMenu.Items[ i ].Free;
1707                         end;
1708                 except
1709                 end;
1710         end;
1711
1712         // \83\81\83j\83\85\81[\82ð\90Ý\92è
1713         for i := Length( BBSs ) - 1 downto 0 do begin
1714                 try
1715                         item                                    := TBBSMenuItem.Create( PopupMenu );
1716                         item.Caption    := BBSs[ i ].Title;
1717                         item.Data                       := BBSs[ i ];
1718                         item.OnClick    := BBSMenuItemOnClick;
1719                         CabinetSelectPopupMenu.Items.Insert( 0, item );
1720                         item                                    := TBBSMenuItem.Create( PopupMenu );
1721                         item.Caption    := BBSs[ i ].Title;
1722                         item.Data                       := BBSs[ i ];
1723                         item.OnClick    := BBSMenuItemOnClick;
1724                         CabinetMenu.Insert( 0, item );
1725                         item                                    := TBBSMenuItem.Create( PopupMenu );
1726                         item.Caption    := BBSs[ i ].Title;
1727                         item.Data                       := BBSs[ i ];
1728                         item.OnClick    := BBSMenuItemOnClick;
1729                         BBSSelectPopupMenu.Items.Insert( 0, Item );
1730                 except
1731                 end;
1732         end;
1733
1734 end;
1735
1736 procedure TGikoForm.ReloadBBS;
1737 var
1738         i                       : Integer;
1739         tmpBool: Boolean;
1740 begin
1741     LockWindowUpdate(Self.Handle);
1742
1743         //\83^\83u\83N\83\8d\81[\83Y
1744         tmpBool := GikoSys.Setting.ShowDialogForAllTabClose;
1745         GikoSys.Setting.ShowDialogForAllTabClose := false;
1746         GikoDM.AllTabCloseAction.Execute;
1747         GikoSys.Setting.ShowDialogForAllTabClose := tmpBool;
1748         SetContent(BrowserNullTab);
1749         //TreeView\83N\83\8a\83A\81iBBS2ch.Free\82Ì\8cã\82É\83N\83\8a\83A\82·\82é\82ÆXP\83X\83^\83C\83\8b\8e\9e\82É\83G\83\89\81[\8fo\82é\81j
1750         TreeView.Items.Clear;
1751
1752         //\8f\84\89ñ\83\8a\83X\83g\95Û\91
1753         try
1754                 RoundList.SaveRoundFile;
1755         except
1756         end;
1757         //\8f\84\89ñ\83\8a\83X\83g\82ð\94j\8aü
1758         try
1759                 RoundList.Clear;
1760         except
1761         end;
1762
1763         //\97\9a\97ð\82Ì\95Û\91\82Æ\94j\8aü
1764         try
1765                 FHistoryList.SaveToFile(GikoSys.GetConfigDir + 'History.xml');
1766                 FHistoryList.Clear;
1767         except
1768         end;
1769
1770         //\82¨\8bC\82É\93ü\82è\82Ì\95Û\91\82Æ\94j\8aü
1771         try
1772                 FavoriteDM.WriteFavorite;
1773                 FavoriteDM.Clear;
1774         except
1775         end;
1776
1777         //\94Â\81E\83X\83\8c\81EPLUGIN\82Ì\94j\8aü
1778         for i := Length(BoardGroups) - 1 downto 0 do begin
1779                 try
1780                         BoardGroups[i].Free;
1781                 except
1782                 end;
1783         end;
1784         //BBS\94j\8aü
1785         try
1786                 for i := Length( BBSs ) - 1 downto 0 do begin
1787                         if BBSs[ i ] <> nil then
1788                                 BBSs[ i ].Free;
1789                         BBSs[ i ] := nil;
1790                 end;
1791         except
1792         end;
1793
1794         ActiveList := nil;
1795
1796         FTreeType := gttNone;
1797
1798         //============\82±\82±\82©\82ç\89º\82Å\81A\8dÄ\90¶================================//
1799
1800         // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1801         InitializeBoardPlugIns;
1802
1803         GikoSys.ListBoardFile;          //\83{\81[\83h\83t\83@\83C\83\8b\93Ç\8d\9e
1804
1805         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1806         for i := Length(BBSs) - 1 downto 0 do begin
1807                 if not BBSs[i].IsBoardFileRead then
1808                         GikoSys.ReadBoardFile(BBSs[i]);
1809         end;
1810
1811         // BBS \83\81\83j\83\85\81[\82Ì\8dX\90V
1812         SetBBSMenu;
1813
1814         ShowBBSTree( BBSs[ 0 ] );
1815
1816         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1817     FHistoryList.LoadFromFile(GikoSys.GetConfigDir + 'History.xml',
1818         TreeView, FTreeType);
1819
1820         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1821         FavoriteDM.ReadFavorite;
1822
1823         SetLinkBar;
1824
1825         //\8f\84\89ñ\82Ì\93Ç\82Ý\8d\9e\82Ý
1826         RoundList.LoadRoundBoardFile;
1827         RoundList.LoadRoundThreadFile;
1828
1829         LockWindowUpdate(0);
1830 end;
1831
1832 {!
1833 \todo \89½\8cÌ IE 7 \82Å\82Í about:.. \82É\82È\82é\82Ì\82©
1834       (IE 7 \82ª about:.. \82ð\92Ç\89Á\82µ\82Ä\82¢\82é\82Ì\82©\81A\83M\83R\83i\83r\82ª\92Ç\89Á\82µ\82Ä\82¢\82é\82Ì\82©)
1835       \92²\8d¸\82·\82é\82±\82Æ
1836 }
1837 procedure TGikoForm.BrowserStatusTextChange(Sender: TObject; const Text: WideString);
1838 var
1839         p: TPoint;
1840         s: string;
1841         tmp2: string;
1842         URL: string;
1843         ATitle: Boolean;
1844
1845         threadItem      : TThreadItem;
1846         board                           : TBoard;
1847         Protocol, Host, Path, Document, Port, Bookmark: string;
1848
1849         wkInt: Integer;
1850         wkIntSt: Integer;
1851         wkIntTo: Integer;
1852         ActiveFileName: string;
1853         e: IHTMLElement;
1854         Ext: string;
1855         PathRec: TPathRec;
1856   Text2: string;
1857 begin
1858         // \83M\83R\83i\83r\82Í\83\8c\83X\83A\83\93\83J\81[\82ª about:blank.. \82Å\8en\82Ü\82é\82±\82Æ\82ð\8aú\91Ò\82µ\82Ä\82¢\82é\82ª
1859   // IE 7 \82Å\82Í about:blank.. \82Å\82Í\82È\82­ about:.. \82É\82È\82é\82Ì\82Å\81A\92u\8a·\82·\82é(\93\8a\82°\82â\82è)
1860         if Pos('about:..', Text) = 1 then
1861         Text2 := 'about:blank..' + Copy( Text, Length('about:..')+1, Length(Text) )
1862   else
1863         Text2 := Text;
1864         if not( TObject(Sender) is TWebBrowser )then
1865                 Exit;
1866         try
1867                 try
1868                         if (TWebBrowser(Sender) <> nil) and (not TWebBrowser(Sender).Busy) and (Assigned(TWebBrowser(Sender).Document)) then begin
1869                                 if LowerCase(OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset) <> 'shift_jis' then begin
1870                                         OleVariant(IHTMLDocument2(TWebBrowser(Sender).Document)).charset := 'shift_jis';
1871                                 end;
1872                         end;
1873                 except
1874                 end;
1875         finally
1876         end;
1877         if PreviewTimer.Enabled then
1878                 PreviewTimer.Enabled := False;
1879         Application.CancelHint;
1880         try
1881                 if GetActiveContent <> nil then
1882                         ActiveFileName := ChangeFileExt(ExtractFileName(GetActiveContent.FileName), '')
1883                 else
1884                         ActiveFileName := '';
1885         except
1886                 FActiveContent := nil;
1887                 Exit;
1888         end;
1889
1890         StatusBar.Panels[1].Text := Text2;
1891
1892         if FHint <> nil then begin
1893                 FHint.ReleaseHandle;
1894                 FHint.ClearAllRes;
1895         end;
1896         if FPreviewBrowser <> nil then
1897                 ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
1898
1899         if not GikoSys.Setting.UnActivePopup then
1900                 if not GikoForm.Active then
1901                         Exit;
1902
1903 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10
1904 //file:///C:/Borland/Projects/gikoNavi/test/read.cgi/qa/990576336/10-15
1905
1906         s := '';
1907         Ext := AnsiLowerCase(ExtractFileExt(Text2));
1908         if (Pos('http://', Text2) = 1) and (GikoSys.Setting.PreviewVisible) and
1909                         ((Ext = '.jpg') or (Ext = '.jpeg') or (Ext = '.gif') or (Ext = '.png')) then begin
1910                 if FPreviewBrowser = nil then begin
1911                         FPreviewBrowser := TPreviewBrowser.Create(Self);
1912                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
1913                         TOleControl(FPreviewBrowser).Parent := nil;
1914                 end;
1915                 FPreviewBrowser.Navigate(BLANK_HTML);//\91O\89ñ\82Ì\83v\83\8c\83r\83\85\81[\89æ\91\9c\8fÁ\8b\8e\97p
1916                 FPreviewURL := Text2;
1917                 PreviewTimer.Interval := GikoSys.Setting.PreviewWait;
1918                 PreviewTimer.Enabled := True;
1919         end else if (Pos('about:blank', Text2) = 1) or (Pos('http://', Text2) = 1) or (Pos('mailto:', Text2) = 1) then begin
1920                 if Pos('mailto:', Text2) = 1 then begin
1921                         s := StringReplace(Text2, 'mailto:', '', [rfIgnoreCase]);
1922                         //\83M\83R\83i\83r\83X\83\8c \83p\81[\83g3\82Ì466\8e\81\82É\8a´\8eÓ
1923                         GetCursorPos(p);
1924                         p.x := p.x - TWebBrowser(Sender).ClientOrigin.x;
1925                         p.y := p.y - TWebBrowser(Sender).ClientOrigin.y;
1926                         e := IHTMLDocument2(TWebBrowser(Sender).Document).elementFromPoint(p.x, p.y);
1927                         if (Assigned(e)) then begin
1928                                 tmp2 := ZenToHan(e.Get_outerText);
1929                                 if (GikoSys.IsNumeric(tmp2)) then begin
1930                                         //\82\93\82Í\83\8c\83X\94Ô\8d\86\82Á\82Û\82¢\82Á\82·\81B
1931                                         wkIntSt := StrToInt64(tmp2);
1932                                         wkIntTo := StrToInt64(tmp2);
1933                                                 //s := GetThreadText(wkBBS, wkKey, wkIntSt, wkIntTo, False, False);
1934                                         FHint.PopupType := gptThread;
1935                                         HTMLCreater.SetResPopupText(FHint, GetActiveContent, wkIntSt, wkIntTo, False, False);
1936                                 end else begin
1937                                         FHint.PopupType := gptRaw;
1938                                         FHint.Caption := s;
1939                                 end;
1940                         end;
1941                 end else begin
1942                         threadItem := GetActiveContent;
1943                         URL := THTMLCreate.GetRespopupURL(Text2, threadItem.URL);
1944                         PathRec := Gikosys.Parse2chURL2(URL);
1945                         if (PathRec.FNoParam) then begin
1946                                 PathRec.FSt := 1;
1947                                 PathRec.FTo := 1;
1948                         end else begin
1949                                 Gikosys.GetPopupResNumber(URL,PathRec.FSt,PathRec.FTo);
1950                         end;
1951                         GikoSys.ParseURI( URL, Protocol, Host, Path, Document, Port, Bookmark );
1952
1953                         if PathRec.FDone or (not GikoSys.Is2chHost( Host )) then begin
1954
1955                                 URL := GikoSys.GetBrowsableThreadURL( URL );
1956                                 wkIntSt := PathRec.FSt;
1957                                 wkIntTo := PathRec.FTo;
1958
1959                                 if (wkIntSt = 0) and (wkIntTo = 0) then begin
1960                                         wkIntSt := 1;
1961                                         wkIntTo := 1;
1962                                 end else if (wkIntSt = 0) and (wkIntTo > 0) then begin
1963                                         wkIntSt := wkIntTo;
1964                                 end else if (wkIntSt > 0) and (wkIntTo = 0) then begin
1965                                         wkIntTo := wkIntSt;
1966                                 end else if wkIntSt > wkIntTo then begin
1967                                         wkInt := wkIntTo;
1968                                         wkIntTo := wkIntSt;
1969                                         wkIntSt := wkInt;
1970                                 end;
1971                                 if (FActiveContent <> nil) and (FActiveContent.Thread.URL = URL) then
1972                                         ATitle := false
1973                                 else
1974                                         ATitle := true;
1975
1976                                 threadItem := BBSsFindThreadFromURL( URL );
1977
1978                                 if (threadItem = nil) and GikoSys.Is2chHost( Host ) then begin
1979                                         board := BBSs[ 0 ].FindBBSID( PathRec.FBBS );
1980                                         if board <> nil then begin
1981                                                 if not board.IsThreadDatRead then
1982                                                         GikoSys.ReadSubjectFile( board );
1983                                                 threadItem := board.FindThreadFromFileName( PathRec.FKey + '.dat' );
1984                                         end;
1985                                 end;
1986
1987                                 if threadItem <> nil then begin
1988                                         //HintData := GetThreadText(PathRec.FBBS, PathRec.FKey, wkIntSt, wkIntTo, ATitle, PathRec.FFirst);
1989                                         //URL\82Ì\8dÅ\8cã\82É/\82ª\95t\82¢\82Ä\82¢\82È\82¢\82Æ\82«\97p
1990                                         if ( IntToStr(wkIntSt) = ChangeFileExt(threadItem.FileName, '') ) then begin
1991                                                 wkIntSt := 1;
1992                                                 wkIntTo := 1;
1993                                         end;
1994                                         FHint.PopupType := gptThread;
1995                                         HTMLCreater.SetResPopupText(FHint, threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
1996                                 end;
1997                         end;
1998                 end;
1999
2000                 if FHint.PopupType = gptRaw then begin
2001                         if FHint.Caption <> '' then
2002                                 ShowTextPopup;
2003                 end else begin
2004                         if (FHint.ResCount <> 0) or (FHint.Title <> '') then
2005                                 ShowTextPopup;
2006                 end;
2007         end;
2008 end;
2009
2010 procedure TGikoForm.SetEnabledCloseButton(Enabled: Boolean);
2011 var
2012         SysMenu: HMenu;
2013 begin
2014         FEnabledCloseButton := Enabled;
2015         SysMenu := GetSystemMenu(Handle, False);
2016
2017         if Enabled then begin
2018                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
2019         end else begin
2020                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
2021         end;
2022
2023         DrawMenuBar(Handle);
2024 end;
2025
2026 procedure TGikoForm.TreeViewChanging(Sender: TObject; Node: TTreeNode;
2027         var AllowChange: Boolean);
2028 begin
2029 //\83\\81[\83g\8f\87\82ð\95Û\91\82·\82é\82æ\82¤\82É\82µ\82½\82Ì\82Å\8dí\8f\9c
2030 //      if FTreeType = gtt2ch then
2031 //              FSortIndex := -1;
2032 end;
2033
2034 procedure TGikoForm.ListViewKeyDown(Sender: TObject; var Key: Word;
2035         Shift: TShiftState);
2036 var
2037         pos     : TPoint;
2038 begin
2039         if GetActiveList is TBoard then begin
2040                 case Key of
2041                 VK_BACK:;       //      UpFolderButtonClick(Sender);
2042                 VK_SPACE:                       ListDoubleClick(Shift);
2043                 VK_RETURN:              ListClick;
2044                 VK_APPS:
2045                         begin
2046                                 if ListView.Selected <> nil then begin
2047                                         pos.X := ListView.Column[ 0 ].Width;
2048                                         pos.Y := ListView.Selected.Top;
2049                                 end else begin
2050                                         pos.X := ListView.Left;
2051                                         pos.Y := ListView.Top;
2052                                 end;
2053                                 Windows.ClientToScreen( ListView.Handle, pos );
2054                                 ListPopupMenu.Popup( pos.X, pos.Y );
2055                         end;
2056                 end;
2057         end else begin // TBBS, TCategory
2058                 case Key of
2059                 VK_BACK:;       //      UpFolderButtonClick(Sender);
2060                 VK_SPACE:                       ListClick;
2061                 VK_RETURN:              ListDoubleClick(Shift);
2062                 VK_APPS:
2063                         begin
2064                                 if ListView.Selected <> nil then begin
2065                                         pos.X := ListView.Column[ 0 ].Width;
2066                                         pos.Y := ListView.Selected.Top;
2067                                 end else begin
2068                                         pos.X := ListView.Left;
2069                                         pos.Y := ListView.Top;
2070                                 end;
2071                                 Windows.ClientToScreen( ListView.Handle, pos );
2072                                 ListPopupMenu.Popup( pos.X, pos.Y );
2073                         end;
2074                 end;
2075         end;
2076 end;
2077
2078 function TGikoForm.GetHttpState: Boolean;
2079 begin
2080         Result := FHttpState;
2081 end;
2082
2083 procedure TGikoForm.ListViewColumnClick(Sender: TObject;
2084         Column: TListColumn);
2085 var
2086         id, idx                 : Integer;
2087         orderList               : TList;
2088         vSortIndex              : Integer;
2089         vSortOrder              : Boolean;
2090 begin
2091         idx := TListViewUtils.ActiveListTrueColumn( Column ).Tag;
2092         if TObject( FActiveList ) is TBBS then begin
2093                 orderList := GikoSys.Setting.BBSColumnOrder;
2094                 vSortIndex := GikoSys.Setting.BBSSortIndex;
2095                 vSortOrder := GikoSys.Setting.BBSSortOrder;
2096         end else if TObject( FActiveList ) is TCategory then begin
2097                 orderList := GikoSys.Setting.CategoryColumnOrder;
2098                 vSortIndex := GikoSys.Setting.CategorySortIndex;
2099                 vSortOrder := GikoSys.Setting.CategorySortOrder;
2100         end else if TObject( FActiveList ) is TBoard then begin
2101                 orderList := GikoSys.Setting.BoardColumnOrder;
2102                 vSortIndex := GikoSys.Setting.BoardSortIndex;
2103                 vSortOrder := GikoSys.Setting.BoardSortOrder;
2104         end else
2105                 Exit;
2106
2107         id := Integer( orderList[ idx ] );
2108
2109
2110         if vSortIndex = id then
2111                 vSortOrder := not vSortOrder
2112         else begin
2113                 vSortOrder := id = 0;
2114         end;
2115
2116         TListViewUtils.ListViewSort(Sender, ListView, Column, GikoDM.ListNumberVisibleAction.Checked, vSortOrder);
2117 end;
2118
2119 procedure TGikoForm.MenuToolBarCustomDrawButton(Sender: TToolBar;
2120         Button: TToolButton; State: TCustomDrawState; var DefaultDraw: Boolean);
2121 var
2122         ARect: TRect;
2123 begin
2124         DefaultDraw := True;
2125         Exit;
2126         DefaultDraw := False;
2127         if (cdsSelected in State) or (cdsHot in State) then begin
2128                 Sender.Canvas.Brush.Color := clHighlight;
2129                 Sender.Canvas.Font.Color := clHighlightText;
2130         end else begin
2131                 Sender.Canvas.Brush.Color := clBtnFace;
2132                 Sender.Canvas.Font.Color := clBtnText;
2133         end;
2134         ARect := Rect(Button.Left, Button.Top, Button.Left + Button.Width, Button.Top + Button.Height);
2135         Sender.Canvas.FillRect(ARect);
2136         DrawText(Sender.Canvas.Handle, PChar(Button.Caption), -1, ARect, DT_SINGLELINE or DT_VCENTER or DT_CENTER);
2137 end;
2138
2139 function TGikoForm.GetTreeNode(Data: TObject): TTreeNode;
2140 var
2141         Nodes: TTreeNodes;
2142         i: integer;
2143 begin
2144         Nodes := TreeView.Items;
2145
2146         for i := 0 to Nodes.Count - 1 do begin
2147                 if Nodes.Item[i].Data = Data then begin
2148                         Result := Nodes.Item[i];
2149                         Exit;
2150                 end;
2151         end;
2152         Result := nil;
2153 end;
2154
2155 procedure TGikoForm.BrowserBeforeNavigate2(Sender: TObject;
2156         const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
2157         Headers: OleVariant; var Cancel: WordBool);
2158 var
2159         sNo: string;
2160         p: TPoint;
2161 const
2162         kMenuName: string = 'menu:';
2163 begin
2164
2165         if Pos(kMenuName, URL) <> 0 then begin
2166                 sNo := Copy( URL, Pos( kMenuName, URL ) + Length( kMenuName ), Length( URL ) );
2167                 
2168                 if not GikoSys.IsNumeric(sNo) then Exit;
2169
2170                 Cancel := True;
2171                 GetCursorpos(p);
2172                 KokoPopupMenu.Tag := StrToInt(sNo);
2173                 KokoPopupMenu.Popup(p.x, p.y);
2174         end else if Pos('mailto', LowerCase(URL)) <> 0 then begin
2175                 Cancel := not GikoSys.Setting.OpenMailer;
2176         end;
2177
2178 end;
2179
2180 procedure TGikoForm.TreeViewCustomDraw(Sender: TCustomTreeView;
2181         const ARect: TRect; var DefaultDraw: Boolean);
2182 var
2183         NodeRect: TRect;
2184         i, j: Integer;
2185         IsBoardNode: Boolean;
2186         Cnt: Integer;
2187         CntText: string;
2188         TextWidth: Integer;
2189         TextRect: TRect;
2190         Board: TBoard;
2191         Category: TCategory;
2192         Bitmap: TBitmap;
2193         NodeWidth: Integer;
2194 begin
2195         DefaultDraw := True;
2196
2197         if FTreeType = gttHistory then Exit;
2198
2199         TreeView.Canvas.Font.Color := clBlue;
2200         IsBoardNode := False;
2201         for i := 0 to TreeView.Items.Count - 1 do begin
2202                 Cnt := 0;
2203                 if not TreeView.Items[i].IsVisible then
2204                         continue;
2205
2206                 if TObject(TreeView.Items[i].Data) is TCategory then begin
2207                         if TreeView.Items[i].Expanded then
2208                                 continue;
2209
2210                         IsBoardNode := False;
2211                         Category := TCategory(TreeView.Items[i].Data);
2212                         for j := 0 to Category.Count - 1 do begin
2213                                 Board := Category.Items[j];
2214                                 if Board <> nil then begin
2215                                         if Board.UnRead > 0 then begin
2216                                                 Cnt := 1;
2217                                                 Break;
2218                                         end;
2219                                 end;
2220                         end;
2221                         if Cnt <> 1 then
2222                                 continue;
2223                 end else if TObject(TreeView.Items[i].Data) is TBoard then begin
2224                         IsBoardNode := True;
2225                         Board := TBoard(TreeView.Items[i].Data);
2226
2227                         Cnt := Board.UnRead;
2228                         if Cnt <= 0 then
2229                                 continue;
2230                 end else
2231                         continue;
2232
2233                 Bitmap := TBitmap.Create;
2234                 try
2235                         Bitmap.Canvas.Font.Assign(TreeView.Canvas.Font);
2236                         Bitmap.Canvas.Font.Style := [fsBold];
2237                         NodeWidth := Bitmap.Canvas.TextWidth(TreeView.Items[i].Text);
2238                 finally
2239                         Bitmap.Free;
2240                 end;
2241
2242                 NodeRect := TreeView.Items[i].DisplayRect(True);
2243
2244                 if IsBoardNode then
2245                         CntText := '(' + IntToStr(Cnt) + ')'
2246                 else if Cnt = 1 then
2247                         CntText := '(+)';
2248
2249
2250                 TextWidth := TreeView.Canvas.TextWidth(CntText);
2251
2252                 TextRect := Rect(NodeRect.Left + NodeWidth + 8,
2253                                                                                  NodeRect.Top,
2254                                                                                  NodeRect.Left + NodeWidth + TextWidth + 8,
2255                                                                                  NodeRect.Bottom);
2256                 DrawText(TreeView.Canvas.Handle,
2257                                                  PChar(CntText),
2258                                                  -1,
2259                                                  TextRect,
2260                                                  DT_SINGLELINE or DT_VCENTER);
2261         end;
2262         TreeViewCustomDrawItem(nil, nil, [], DefaultDraw);
2263 end;
2264
2265 procedure TGikoForm.TreeViewCustomDrawItem(Sender: TCustomTreeView;
2266         Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
2267 var
2268         Board: TBoard;
2269         Category: TCategory;
2270         i: Integer;
2271 begin
2272         DefaultDraw := True;
2273
2274         if FTreeType = gttHistory then Exit;
2275
2276         TreeView.Canvas.Font.Style := [];
2277         if Node <> nil then begin
2278                 if TObject(Node.Data) is TCategory then begin
2279                         Category := TCategory(Node.Data);
2280                         for i := 0 to Category.Count - 1 do begin
2281                                 Board := Category.Items[i];
2282                                 if Board <> nil then begin
2283                                         if Board.UnRead > 0 then begin
2284                                                 TreeView.Canvas.Font.Style := [fsBold];
2285                                                 Break;
2286                                         end;
2287                                 end;
2288                         end;
2289                 end else if TObject(Node.Data) is TBoard then begin
2290                         Board := TBoard(Node.Data);
2291                         if Board.UnRead > 0 then
2292                                 TreeView.Canvas.Font.Style := [fsBold];
2293                 end;
2294         end;
2295 end;
2296
2297 procedure TGikoForm.TreeViewExpanded(Sender: TObject; Node: TTreeNode);
2298 begin
2299         TreeView.Invalidate;
2300
2301         if TObject(Node.Data) is TBBS then begin
2302                 TBBS(Node.Data).NodeExpand := True;
2303         end else if TObject(Node.Data) is TCategory then begin
2304                 TCategory(Node.Data).NodeExpand := True;
2305         end else if TObject(Node.Data) is TBoard then begin
2306                 TBoard(Node.Data).NodeExpand := True;
2307         end;
2308 end;
2309
2310 procedure TGikoForm.ListViewAllSelect;
2311 begin
2312         ListView.SetFocus;
2313         ListView.SelectAll;
2314 end;
2315 procedure TGikoForm.DownloadMsg(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon);
2316 begin
2317         AddMessageList(Msg, nil, Icon);
2318 end;
2319 // *************************************************************************
2320 //! \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
2321 // *************************************************************************
2322 procedure TGikoForm.DownloadEnd(Sender: TObject; Item: TDownloadItem);
2323 var
2324         ATitle: string;
2325         s: string;
2326         boardPlugIn : TBoardPlugIn;
2327         i: Integer;
2328         Res : TResRec;
2329 begin
2330         try
2331                 if Item.DownType = gdtBoard then
2332                         ATitle := Item.Board.Title
2333                 else
2334                         ATitle := Item.ThreadItem.Title;
2335                 if ATitle = '' then
2336                         ATitle := GikoSys.GetGikoMessage(gmUnKnown);
2337
2338                 if Item.State in [gdsComplete, gdsDiffComplete] then begin
2339                         //\90³\8fí\8fI\97¹
2340                         if Item.DownType = gdtBoard then begin
2341                                 //\94Â
2342                                 Item.SaveListFile;
2343                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureItiran), nil, gmiOK);
2344                                 if GetActiveList = Item.Board then begin
2345                                         FActiveList := nil;
2346                                         //\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é
2347                                         if (GikoSys.Setting.AutoSortThreadList) then begin
2348                                                 GikoSys.Setting.BoardSortIndex := 0;
2349                                                 GikoSys.Setting.BoardSortOrder := True;
2350                                         end;
2351                                         Sort.SetSortDate(Now());
2352                                         SetActiveList(Item.Board);
2353                                 end;
2354                                 Item.Board.Modified := True;
2355                                 Item.Board.IsThreadDatRead := True;
2356                                 PlaySound('New');
2357                                 ListView.Refresh;
2358                         end else if Item.DownType = gdtThread then begin
2359                                 //\83X\83\8c
2360                                 Item.SaveItemFile;
2361                                 Item.ThreadItem.NewArrival := True;
2362                                 //if (Item.ThreadItem.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
2363                                 if (Item.ThreadItem.ParentBoard.IsBoardPlugInAvailable) and (Item.ThreadItem.Title = '') then begin
2364                                         //boardPlugIn           := Item.ThreadItem.BoardPlugIn;
2365                                         boardPlugIn             := Item.ThreadItem.ParentBoard.BoardPlugIn;
2366                                         THTMLCreate.DivideStrLine(boardPlugIn.GetDat( DWORD( Item.ThreadItem ), 1 ), @Res);
2367                                         Item.ThreadItem.Title := Res.FTitle;
2368                                         ATitle := Item.ThreadItem.Title;
2369                                 end else if ATitle = '\81i\96¼\8fÌ\95s\96¾\81j' then begin
2370                                         THTMLCreate.DivideStrLine(GikoSys.ReadThreadFile(Item.ThreadItem.GetThreadFileName, 1), @Res);
2371                                         ATitle := Res.FTitle;
2372                                 end;
2373                                 for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
2374                                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = Item.ThreadItem then begin
2375                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
2376                                                 break;
2377                                         end;
2378                                 end;
2379                                 if GikoSys.Setting.BrowserTabVisible then begin
2380                                         if GetActiveContent = Item.ThreadItem then
2381                                                 InsertBrowserTab(Item.ThreadItem)
2382                                         else if (ListView.Selected <> nil ) and ( TObject(ListView.Selected.Data) is TThreadItem ) and ( Item.ThreadItem = TThreadItem(ListView.Selected.Data)) then
2383                                                 InsertBrowserTab(Item.ThreadItem, True)
2384                                         else
2385                                                 InsertBrowserTab(Item.ThreadItem, False);
2386
2387                                 end else begin
2388                                         if (GetActiveContent = Item.ThreadItem) or (FActiveContent = nil) or(FActiveContent.Browser = BrowserNullTab.Browser) then
2389                                                                                                 InsertBrowserTab(Item.ThreadItem);
2390                                 end;
2391
2392                                                                 Application.ProcessMessages;
2393
2394                                 if Item.State = gdsComplete then begin
2395                                         PlaySound('New');
2396                                                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureSyutoku), nil, gmiOK);
2397                                                                                 //Add by Genyakun
2398                                                                                 DiffComp := True;
2399                                 end else begin
2400                                         PlaySound('NewDiff');
2401                                                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmSureDiff), nil, gmiOK);
2402                                                                                 //Add by Genyakun
2403                                                                                 DiffComp := True;
2404                                 end;
2405
2406                                 //\8f\84\89ñ\82 \82è\82Ì\8fê\8d\87\81\95\82P\82O\82O\82O\92´\82Í\8f\84\89ñ\8dí\8f\9c
2407                                 if (Item.ThreadItem.Round) and (Item.ThreadItem.Count > 1000) then begin
2408                                         Item.ThreadItem.Round := False;
2409                                         //Item.ThreadItem.RoundName := '';
2410                                         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);
2411                                 end;
2412                                 TreeView.Refresh;
2413                                 //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
2414                                 if (ActiveList <> nil) and (ActiveList is TBoard) then begin
2415                                         TBoard(ActiveList).LogThreadCount := TBoard(ActiveList).GetLogThreadCount;
2416                                         TBoard(ActiveList).NewThreadCount := TBoard(ActiveList).GetNewThreadCount;
2417                                         TBoard(ActiveList).UserThreadCount:= TBoard(ActiveList).GetUserThreadCount;
2418                     //ListView\82Ì\83A\83C\83e\83\80\82Ì\8cÂ\90\94\82à\8dX\90V
2419                                         case GikoForm.ViewType of
2420                                                 gvtAll: ListView.Items.Count := TBoard(ActiveList).Count;
2421                                                 gvtLog: ListView.Items.Count := TBoard(ActiveList).LogThreadCount;
2422                                                 gvtNew: ListView.Items.Count := TBoard(ActiveList).NewThreadCount;
2423                                                 gvtArch: ListView.Items.Count := TBoard(ActiveList).ArchiveThreadCount;
2424                                                 gvtLive: ListView.Items.Count := TBoard(ActiveList).LiveThreadCount;
2425                                                 gvtUser: ListView.Items.Count := TBoard(ActiveList).UserThreadCount;
2426                                         end;
2427                                 end;
2428                                 RefreshListView(Item.ThreadItem);
2429                         end;
2430
2431                 end else if Item.State = gdsNotModify then begin
2432                         //\95Ï\8dX\83i\83V
2433 {                       if (Item.DownType = gdtThread) and (AddHistory(Item.ThreadItem)) then begin
2434                                 //SetContent(Item.ThreadItem);
2435                                 InsertBrowserTab(Item.ThreadItem);
2436                         end;}
2437                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmNotMod), nil, gmiSAD);
2438                         PlaySound('NoChange');
2439                         Screen.Cursor := crDefault;
2440                 end else if Item.State = gdsAbort then begin
2441                         //\92\86\92f
2442                                                 AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiOK);
2443                 end else if Item.State = gdsError then begin
2444                         //\83G\83\89\81[
2445                         s := Item.ErrText;
2446                         if s <> '' then
2447                                 s := ':' + s;
2448                         AddMessageList(ATitle + ' ' + GikoSys.GetGikoMessage(gmError) + ' (' + IntToStr(Item.ResponseCode) + ')' + s, nil, gmiNG);
2449 //                      if Item.ResponseCode = 302 then
2450 //                              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);
2451                         PlaySound('Error');
2452                 end;
2453         finally
2454                 Item.Free;
2455                 Dec(FWorkCount);
2456                 if FWorkCount < 0 then FWorkCount := 0;
2457                 if FWorkCount = 0 then begin
2458                         try
2459                                 Animate.Active := False;
2460                         finally
2461                                 Screen.Cursor := crDefault;
2462                         end;
2463                 end;
2464
2465         end;
2466 end;
2467
2468 procedure TGikoForm.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; Number: Integer; const AWorkTitle: string);
2469 begin
2470 //      SetProgressValue(Number, 0, AWorkCountMax);
2471 //      ProgressBar.Visible := True;
2472         ProgressBar.Position := 0;
2473         ProgressBar.Max := AWorkCountMax;
2474         FDownloadTitle := AWorkTitle;
2475         StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82·';
2476         FDownloadMax := AWorkCountMax;
2477 end;
2478
2479 procedure TGikoForm.WorkEnd(Sender: TObject; AWorkMode: TWorkMode; Number: Integer);
2480 begin
2481         ProgressBar.Position := 0;
2482         if FDownloadMax <> 0 then
2483                 StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\82ª\8a®\97¹\82µ\82Ü\82µ\82½';
2484 end;
2485
2486 procedure TGikoForm.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; Number: Integer);
2487 begin
2488         ProgressBar.Position := AWorkCount;
2489 //      SetProgressValue(Number, AWorkCount);
2490         StatusBar.Panels[1].Text := FDownloadTitle + ' - \83_\83E\83\93\83\8d\81[\83h\92\86 (' + IntToStr(AWorkCount) + '/' + IntToStr(FDownloadMax) + ')';
2491 end;
2492
2493 procedure TGikoForm.AddMessageList(ACaption: string; AObject: TObject; Icon: TGikoMessageIcon);
2494 var
2495         ListItem: TListItem;
2496 begin
2497         MessageListView.Items.BeginUpdate;
2498         try
2499                 ListItem := MessageListView.Items.Add;
2500                 ListItem.Caption := ACaption;
2501                 ListItem.Data := AObject;
2502                 ListItem.MakeVisible(False);
2503                 case Icon of
2504                         gmiOK:   ListItem.ImageIndex := 0;
2505                         gmiSAD: ListItem.ImageIndex := 1;
2506                         gmiNG:   ListItem.ImageIndex := 2;
2507                         gmiWhat: ListItem.ImageIndex := 3;
2508                 end;
2509         finally
2510                 MessageListView.Items.EndUpdate;
2511         end;
2512 end;
2513
2514
2515 function TGikoForm.InsertBrowserTab(
2516         ThreadItem      : TThreadItem;
2517         ActiveTab               : Boolean = True
2518 ) : TBrowserRecord;
2519 var
2520         i, j, idx               : Integer;
2521         favItem                 : TFavoriteThreadItem;
2522         newBrowser      : TBrowserRecord;
2523 begin
2524
2525         Result := nil;
2526         if Threaditem = nil then Exit;
2527
2528         if ThreadItem.IsLogFile then begin
2529                 //\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é
2530                 //\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é
2531                 if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) and
2532                         (FActiveContent.Browser <> BrowserNullTab.Browser)then begin
2533                         j := FBrowsers.IndexOf(FActiveContent.Browser);
2534                         if j = BROWSER_COUNT - 1 then
2535                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
2536                 end;
2537                 favItem := TFavoriteThreadItem.Create(ThreadItem.URL, ThreadItem.Title );
2538                 if not FHistoryList.AddHistory( favItem, TreeView, FTreeType ) then
2539                         favItem.Free;
2540
2541                 for i := 0 to BrowserTab.Tabs.Count - 1 do begin
2542                         if TObject(BrowserTab.Tabs.Objects[i]) is TBrowserRecord then begin
2543                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
2544                                         Result := TBrowserRecord( BrowserTab.Tabs.Objects[i] );
2545                                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = nil then begin
2546                                                 for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
2547                                                         if TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
2548                                                                 ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
2549                                                                 break;
2550                                                         end;
2551                                                 end;
2552                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2553                                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
2554                                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
2555                                         end;
2556                                         if ActiveTab then begin
2557                                                 BrowserTab.TabIndex := i;
2558                                                         BrowserTab.OnChange(nil);
2559                                                 BrowserTab.Repaint;
2560                                         end;
2561                                         Exit;
2562                                 end;
2563                         end;
2564                 end;
2565                 idx := BrowserTab.TabIndex;
2566                 if GikoSys.Setting.BrowserTabAppend = gtaFirst then begin
2567                         newBrowser := TBrowserRecord.Create;
2568                         for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
2569                                 if TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
2570                                         ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
2571                                         break;
2572                                 end;
2573                         end;
2574                         newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2575                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
2576                         //newBrowser.Browser.Navigate(BLANK_HTML);
2577                         newBrowser.thread := ThreadItem;
2578                         newBrowser.Repaint := true;
2579 //                      newBrowser.OnlyHundred := GikoSys.OnlyAHundredRes;
2580
2581                         BrowserTab.Tabs.InsertObject(0, GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
2582                         if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
2583                                 DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 1 ] ) );
2584                         end;// else begin
2585                         //end;
2586                         BrowserTab.Repaint;
2587                         if ActiveTab then begin
2588                                 BrowserTab.TabIndex := 0;
2589                         end;
2590
2591                 end else begin
2592                         newBrowser := TBrowserRecord.Create;
2593                         for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
2594                                 if TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
2595                                         ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
2596                                         break;
2597                                 end;
2598                         end;
2599                         newBrowser.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2600                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
2601                         //newBrowser.Browser.Navigate(BLANK_HTML);
2602                         newBrowser.thread := ThreadItem;
2603 //                      newBrowser.OnlyHundred := GikoSys.OnlyAHundredRes;
2604                         newBrowser.Repaint := true;
2605
2606                         i := BrowserTab.Tabs.AddObject(GikoSys.GetShortName(ThreadItem.Title, 20), newBrowser);
2607                         if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 1) then begin
2608                                 DeleteTab( TBrowserRecord( BrowserTab.Tabs.Objects[ 0 ] ) );
2609                         end;
2610                         //end;
2611                         BrowserTab.Repaint;
2612                         if ActiveTab then begin
2613                                 if (not GikoSys.Setting.BrowserTabVisible) and (BrowserTab.Tabs.Count > 0) then
2614                                         BrowserTab.TabIndex := 0
2615                                 else
2616                                         BrowserTab.TabIndex := i;
2617                         end;
2618                 end;
2619                 Result := newBrowser;
2620                 if(ActiveTab) or (idx = -1) then begin
2621                         BrowserTab.OnChange(nil);
2622                 end;
2623         end else begin
2624                 if BrowserNullTab = nil then begin
2625                         BrowserNullTab := TBrowserRecord.Create;
2626                         BrowserNullTab.Browser := Browser;
2627                 end;
2628 //              if BrowserNullTab.thread <> ThreadItem then begin
2629 //                      BrowserNullTab.Movement := '';
2630 //              end;
2631                 BrowserNullTab.thread := ThreadItem;
2632                 Result := BrowserNullTab;
2633                 BrowserTab.TabIndex := -1;
2634                 SetContent(BrowserNullTab);
2635         end;
2636
2637         if GikoSys.Setting.URLDisplay then
2638                 AddressComboBox.Text := ThreadItem.URL;
2639
2640 end;
2641
2642 procedure TGikoForm.SetContent(inThread : TBrowserRecord);
2643 var
2644         BBSID: string;
2645         FileName: string;
2646         sTitle: string;
2647         doc: Variant;
2648         s: string;
2649         i: Integer;
2650         idx: Integer;
2651         ThreadItem: TThreadItem;
2652         Thread: TBrowserRecord;
2653         ThreadTitle, ThreadPTitle: string;
2654         ThreadIsLog, {ThreadUnRead,} ThreadNewArraical: boolean;
2655 begin
2656         Thread := inThread;
2657         idx := BrowserTab.TabIndex;
2658         if (FActiveContent <> nil) and
2659                 (FActiveContent.Thread <> Thread.Thread) and
2660                 (FActiveContent.Browser <> nil) and
2661                 (Assigned(FActiveContent.Browser.Document)) then begin
2662                 try
2663                 try
2664                         FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document).Body).ScrollTop;
2665                 except
2666                         on E: Exception do
2667                                 MsgBox(Handle, E.Message, 'SetContent[<-ScrollTop]', 0);
2668                 end;
2669                 finally
2670                 end;
2671         end;
2672         if not (Assigned(Thread)) or (Thread.Thread = nil) then begin
2673                 Thread.Browser.Navigate(BLANK_HTML);
2674                 BrowserBoardNameLabel.Caption := '';
2675                 ItemBoardImage.Picture := nil;
2676                 BrowserNameLabel.Caption := '';
2677                 ItemImage.Picture := nil;
2678         BrowserNullTab.Thread := nil;
2679                 //TOleControl(BrowserNullTab.Browser).Visible := true;
2680                 ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
2681                 FActiveContent := nil;
2682                 Exit;
2683         end     else if Thread.Browser = nil then begin
2684                 if FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then
2685                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
2686                 for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
2687                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
2688                                 ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
2689                                 break;
2690                         end;
2691                 end;
2692                 Thread.Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
2693                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
2694         end;
2695
2696         ThreadTitle := Thread.Thread.Title;
2697         ThreadPTitle := Thread.Thread.ParentBoard.Title;
2698         //ThreadScrollTop := Thread.Thread.ScrollTop;
2699         ThreadIsLog := Thread.Thread.IsLogFile;
2700         ThreadItem := Thread.Thread;
2701         ThreadNewArraical :=  Thread.Thread.NewArrival;
2702         //ThreadUnRead := Thread.Thread.UnRead;
2703         BBSID := ThreadItem.ParentBoard.BBSID;
2704         FileName := ThreadItem.FileName;
2705
2706         if GetCapture = ListView.Handle then
2707                 ReleaseCapture;
2708
2709         Screen.Cursor := crHourGlass;
2710
2711
2712         try
2713                 if(FActiveContent <> nil) and (FActiveContent <> Thread) then begin
2714                         if (FActiveContent.Browser <> BrowserNullTab.Browser) then
2715                                 ShowWindow(FActiveContent.Browser.Handle, SW_HIDE);
2716                 end;
2717                 ShowWindow(Thread.Browser.Handle, SW_SHOW);
2718                 if (not Assigned(Thread.Browser.Document)) then begin
2719                         Thread.Browser.Navigate('about:blank');
2720                 end;
2721                 while (Thread.Browser.ReadyState <> READYSTATE_COMPLETE) and
2722                                 (Thread.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
2723                         Application.ProcessMessages;
2724                         if idx <> BrowserTab.TabIndex then begin
2725                                 Exit;
2726                         end;
2727                 end;
2728
2729                 if (Thread <> nil) and (ThreadItem <>nil) then begin
2730                         BrowserBoardNameLabel.Caption := ThreadPTitle;
2731                         ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
2732                         BrowserNameLabel.Caption := ThreadTitle;
2733                         ItemImage.Picture := nil;
2734                         if ThreadIsLog then
2735                                 if ThreadNewArraical then
2736                                         ItemImageList.GetBitmap(2, ItemImage.Picture.Bitmap)
2737                                 else
2738                                         ItemImageList.GetBitmap(0, ItemImage.Picture.Bitmap)
2739                         else
2740                                 ItemImageList.GetBitmap(1, ItemImage.Picture.Bitmap);
2741
2742                         ItemImage.Left := BrowserBoardNameLabel.Left + BrowserBoardNameLabel.Width + 8;
2743                         BrowserNameLabel.Left := ItemImage.Left + 20;
2744
2745                 end;
2746                 //ActiveContent\81@\82Ì\8dX\90V
2747                 FActiveContent := Thread;
2748
2749                 if not ThreadIsLog then begin
2750                         Self.Caption := GikoDataModule.CAPTION_NAME ;
2751                         //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\8fÁ\8b\8e
2752                         StatusBar.Panels[THREADSIZE_PANEL].Text := '';
2753                         try
2754                                 Thread.Browser.BringToFront;
2755                                 s := '<HTML><BODY><CENTER>\82±\82Ì\83X\83\8c\83b\83h\82Í\8eæ\93¾\82µ\82Ä\82¢\82Ü\82¹\82ñ</CENTER></BODY></HTML>';
2756                                 doc := Idispatch( olevariant(Thread.Browser.ControlInterface).Document) as IHTMLDocument2;
2757                                 doc.open;
2758                                 doc.charset := 'Shift_JIS';
2759                                 doc.Write(s);
2760                                 doc.Close;
2761                         finally
2762                                 
2763                         end;
2764                 end else begin
2765                         Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + ThreadTitle + ']';
2766                         //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
2767                         StatusBar.Panels[THREADSIZE_PANEL].Text := Format('%6.2f kB', [ThreadItem.Size / 1024]);
2768                         StatusBar.Panels[THREADSIZE_PANEL].Width :=
2769                                 Max(StatusBar.Canvas.TextWidth(StatusBar.Panels[THREADSIZE_PANEL].Text), 70);
2770                         //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«
2771                         //\90V\8bK\82ÉThread\82ð\8aJ\82¢\82½\82Æ\82«\82É\90^\82É\82È\82Á\82Ä\82¢\82é\81B
2772                         if Thread.Repaint then begin
2773                                 Thread.Repaint := false;
2774
2775                                 Thread.Browser.OnStatusTextChange := nil;
2776                                 LockWindowUpdate(Thread.Browser.ParentWindow);
2777                                 HTMLCreater.CreateHTML2(Thread.Browser, ThreadItem, sTitle);
2778                                 Thread.Browser.OnStatusTextChange := BrowserStatusTextChange;
2779                                 PostMessage( Handle, USER_DOCUMENTCOMPLETE, Integer( Thread.Browser ), 0 );
2780                         end;
2781                 end;
2782
2783                 RefreshListView(ThreadItem);
2784         finally
2785                 Screen.Cursor := crDefault;
2786         end;
2787 end;
2788
2789 function TGikoForm.GetActiveContent: TThreadItem;
2790 begin
2791         try
2792                 if FActiveContent <> nil then
2793                         Result := FActiveContent.Thread
2794                 else
2795                         Result := nil;
2796         except
2797                 Result := nil;
2798         end;
2799
2800 end;
2801
2802 procedure TGikoForm.SetActiveList(Obj: TObject);
2803 var
2804         idx     : Integer;
2805 begin
2806 //      if FActiveList <> Obj then begin
2807                 FActiveList := Obj;
2808         try
2809                         if ListView.Selected <> nil then
2810                                 idx := ListView.Selected.Index
2811                         else
2812                                 idx := -1;
2813         except
2814                 idx := -1;
2815         end;
2816                 ListView.Items.Count := 0;
2817                 ListView.Items.Clear;
2818                 ListView.Selected := nil;
2819 //      ListView.Columns.Clear;
2820                 if (FActiveContent <> nil) and (FActiveContent.Thread <> nil)
2821                         and (FActiveContent.Thread.IsLogFile) then begin
2822                         try
2823                                 Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + FActiveContent.Thread.Title + ']'
2824                         except
2825                                 on E: Exception do begin
2826                                         //\83X\83\8c\88ê\97\97DL\8cã\82È\82Ç\82ÉFActiveContent\82Ì\8e\9d\82ÂThread\82ª
2827                                         //\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é
2828                                         ReleaseBrowser(FActiveContent);
2829                                         FActiveContent.Thread := nil;
2830                                         Self.Caption := GikoDataModule.CAPTION_NAME;
2831                                 end;
2832                         end;
2833                 end else
2834                         Self.Caption := GikoDataModule.CAPTION_NAME;
2835                 //Application.Title := CAPTION_NAME;
2836
2837 //              ActiveListColumnSave;
2838
2839                 Screen.Cursor := crHourGlass;
2840                 try
2841                         if Obj is TBBS then begin
2842                                 TListViewUtils.SetCategoryListItem(TBBS(obj), ListView, GikoDM.ListNumberVisibleAction.Checked);
2843                         end else if Obj is TCategory then begin
2844                                 TListViewUtils.SetBoardListItem(TCategory(Obj), ListView, GikoDM.ListNumberVisibleAction.Checked);
2845                         end else if Obj is TBoard then begin
2846                                 TListViewUtils.SetThreadListItem(TBoard(Obj), ListView,  GikoDM.ListNumberVisibleAction.Checked);
2847                         end;
2848                 finally
2849                         Screen.Cursor := crDefault;
2850                 end;
2851
2852                 if idx >= 0  then begin
2853                         if idx >= ListView.Items.Count then
2854                                 idx := ListView.Items.Count - 1;
2855                         ListView.ItemIndex := idx;
2856                         ListView.ItemFocused := ListView.Items.Item[ idx ];
2857                 end;
2858 //      end;
2859 end;
2860
2861
2862 //\81\9a\81\9a\83q\83\8d\83\86\83L\83\81\83\82
2863 //\82»\82Ì\82¤\82¿interface\82ð\8eg\82¤
2864 function TGikoForm.GetActiveList: TObject;
2865 begin
2866         Result := FActiveList;
2867 end;
2868
2869 procedure TGikoForm.SetListViewType(AViewType: TGikoViewType);
2870 begin
2871         SetListViewType(AViewType, '', False);
2872 end;
2873
2874 procedure TGikoForm.SetListViewType(AViewType: TGikoViewType; SelectText: string; KubetsuChk: Boolean);
2875 var
2876         Board: TBoard;
2877         i: Integer;
2878 begin
2879         for i := Length( BBSs ) - 1 downto 0 do begin
2880                 BBSs[i].SelectText := SelectText;
2881                 BBSs[i].KubetsuChk := KubetsuChk;
2882         end;
2883         ViewType := AViewType;
2884         if ActiveList is TBoard then begin
2885                 Board := TBoard(ActiveList);
2886                 case ViewType of
2887                         //gvtAll: ListView.Items.Count := Board.Count;
2888                         gvtLog: Board.LogThreadCount := Board.GetLogThreadCount;
2889                         gvtNew: Board.NewThreadCount := Board.GetNewThreadCount;
2890                         gvtArch: Board.ArchiveThreadCount := Board.GetArchiveThreadCount;
2891                         gvtLive: Board.LiveThreadCount := Board.GetLiveThreadCount;
2892                         gvtUser: Board.UserThreadCount:= Board.GetUserThreadCount;
2893
2894                 end;
2895
2896                 SetActiveList(Board);
2897         end;
2898 end;
2899
2900 procedure TGikoForm.ListViewCustomDraw(Sender: TCustomListView;
2901         const ARect: TRect; var DefaultDraw: Boolean);
2902 var
2903         s: string;
2904         p: TPoint;
2905 //      Board: TBoard;
2906 begin
2907         if ListView.Items.Count = 0 then begin
2908                 DefaultDraw := true;
2909                 ListView.Canvas.Brush.Color := ListView.Color;
2910                 ListView.Canvas.FillRect(ARect);
2911
2912                 case ViewType of
2913                         gvtAll: begin
2914                                 ListView.Canvas.Font.Color := clWindowText;
2915                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
2916                         end;
2917                         gvtLog: begin
2918                                 ListView.Canvas.Font.Color := clBlue;
2919                                 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';
2920                         end;
2921                         gvtNew: begin
2922                                 ListView.Canvas.Font.Color := clGreen;
2923                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90V\92\85\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
2924                         end;
2925                         gvtArch: begin
2926                                 ListView.Canvas.Font.Color := clFuchsia;
2927                                 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';
2928                         end;
2929                         gvtLive: begin
2930                                 ListView.Canvas.Font.Color := clMaroon;
2931                                 s := '\82±\82Ì\83r\83\85\81[\82É\82Í\90\91\83A\83C\83e\83\80\82ª\82 \82è\82Ü\82¹\82ñ\81B';
2932                         end;
2933                         gvtUser: begin
2934                                 ListView.Canvas.Font.Color := clNavy;
2935                                 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';
2936                                 if GetActiveList is TBoard then
2937                                         s := Format(s, [TBoard(GetActiveList).ParentCategory.ParenTBBS.SelectText]);
2938 //                                      SelectText]);
2939                         end;
2940                         else begin
2941                                 s := '';
2942                         end;
2943                 end;
2944
2945                 p := Point((ListView.ClientWidth div 2) - (ListView.Canvas.TextWidth(s) div 2),
2946                                                          (ListView.ClientHeight div 2) - (ListView.Canvas.TextHeight(s) div 2));
2947                 ListView.Canvas.TextOut(p.X, p.Y, s);
2948         end else begin
2949                 DefaultDraw := True;
2950         end;
2951 end;
2952
2953 procedure TGikoForm.DownloadList(Board: TBoard; ForceDownload: Boolean = False);
2954 var
2955         Item: TDownloadItem;
2956 begin
2957         if not Board.IsThreadDatRead then
2958                 GikoSys.ReadSubjectFile(Board);
2959         Item := TDownloadItem.Create;
2960         try
2961                 Item.Board := Board;
2962                 Item.DownType := gdtBoard;
2963                 Item.ForceDownload := ForceDownload;
2964                 FControlThread.AddItem(Item);
2965                 if FWorkCount = 0 then begin
2966                         try
2967                                 Animate.Active := True;
2968                         except
2969                         end;
2970                         Screen.Cursor := crAppStart;
2971                 end;
2972                 Inc(FWorkCount);
2973         finally
2974                 //Item.Free;
2975         end;
2976 end;
2977
2978 procedure TGikoForm.DownloadContent(ThreadItem: TThreadItem; ForceDownload: Boolean = False);
2979 var
2980         Item: TDownloadItem;
2981 begin
2982         Item := TDownloadItem.Create;
2983         try
2984                 Item.ThreadItem := ThreadItem;
2985                 Item.DownType := gdtThread;
2986                 Item.ForceDownload := ForceDownload;
2987                 FControlThread.AddItem(Item);
2988                 if FWorkCount = 0 then begin
2989                         try
2990                                 Animate.Active := True;
2991                         except
2992                         end;
2993                         Screen.Cursor := crAppStart;
2994                 end;
2995                 Inc(FWorkCount);
2996         finally
2997 //              Item.Free;
2998         end;
2999 end;
3000
3001 procedure TGikoForm.PlaySound(SoundEventName: string);
3002 var
3003         FileName: string;
3004 begin
3005         if not GikoSys.Setting.Mute then begin
3006                 FileName := GikoSys.Setting.FindSoundFileName(SoundEventName);
3007                 if FileExists(FileName) then begin
3008                         if not sndPlaySound(PChar(FileName), SND_ASYNC or SND_NOSTOP) then begin
3009                                 sndPlaySound(nil, SND_SYNC);
3010                                 Application.ProcessMessages;
3011                                 Sleep(10);
3012                                 sndPlaySound(PChar(FileName), SND_ASYNC);
3013                         end;
3014                 end;
3015         end;
3016 end;
3017
3018 //\97\9a\97ð\82©\82ç\8dí\8f\9c
3019 procedure TGikoForm.DeleteHistory( threadItem: TThreadItem );
3020 begin
3021     FHistoryList.DeleteHistory( threadItem, TreeView, TreeType );
3022 end;
3023
3024 procedure TGikoForm.ShowBBSTreeOld(
3025         inBBS : TBBS
3026 );
3027 var
3028         i, b            : Integer;
3029         item            : TMenuItem;
3030 begin
3031         try
3032                 FavoriteTreeView.Visible := False;
3033                 FavoriteToolBar.Hide;
3034                 TreeView.Visible := True;
3035
3036                 b := CabinetSelectPopupMenu.Items.Count - 1;
3037                 for i := 0 to b do begin
3038                         item := CabinetSelectPopupMenu.Items[ i ];
3039                         if item is TBBSMenuItem then begin
3040                                 if TBBSMenuItem( item ).Data = inBBS then begin
3041                                         item.Checked := True;
3042                                         // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
3043                                         CabinetMenu.Items[ i ].Checked := True;
3044                                         GikoSys.Setting.CabinetIndex := i;
3045                                         Continue;
3046                                 end;
3047                         end;
3048                         item.Checked := False;
3049                         // CabinetMenu ?? CabinetSelectPopupMenu ??????????????
3050                         CabinetMenu.Items[ i ].Checked := False;
3051                 end;
3052                 CabinetSelectToolButton.Caption := inBBS.Title;
3053
3054                 GikoDM.CabinetHistoryAction.Checked := False;
3055                 GikoDM.CabinetFavoriteAction.Checked := False;
3056
3057                 if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS) then begin
3058                         FTreeType := gtt2ch;
3059                         HistoryToolBar.Hide;
3060                         FActiveBBS := inBBS;
3061                         TListViewUtils.SetBoardTreeNode(inBBS, TreeView);
3062                         TreeView.Items.GetFirstNode.Expanded := True;                           //?c???[?g?b?v???????J??
3063                         //?c???[??g?b?v?????I????
3064                         if GetActiveList = nil then
3065                                 TreeView.Selected := TreeView.Items[0]
3066                         else begin
3067                                 for i := 0 to TreeView.Items.Count - 1 do begin
3068                                         if TreeView.Items[i].Data = GetActiveList then begin
3069                                                 TreeView.Selected := TreeView.Items[i];
3070                                                 Exit;
3071                                         end;
3072                                 end;
3073                                 TreeView.Selected := TreeView.Items[0]
3074                         end;
3075                 end;
3076         except
3077         end;
3078
3079 end;
3080
3081 procedure TGikoForm.ShowBBSTree(
3082         inBBS : TBBS
3083 );
3084 var
3085         i, b            : Integer;
3086         item            : TMenuItem;
3087 begin
3088
3089         try
3090                 FavoriteTreeView.Visible := False;
3091                 FavoriteToolBar.Hide;
3092                 TreeView.Visible := True;
3093
3094                 b := CabinetSelectPopupMenu.Items.Count - 1;
3095                 for i := 0 to b do begin
3096                         item := CabinetSelectPopupMenu.Items[ i ];
3097                         if item is TBBSMenuItem then begin
3098                                 if TBBSMenuItem( item ).Data = inBBS then begin
3099                                         item.Checked := True;
3100                                         // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3101                                         CabinetMenu.Items[ i ].Checked := True;
3102                                         GikoSys.Setting.CabinetIndex := i;
3103                                         Continue;
3104                                 end;
3105                         end;
3106                         item.Checked := False;
3107                         // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3108                         CabinetMenu.Items[ i ].Checked := False;
3109                 end;
3110                 CabinetSelectToolButton.Caption := inBBS.Title;
3111
3112                 GikoDM.CabinetHistoryAction.Checked := False;
3113                 GikoDM.CabinetFavoriteAction.Checked := False;
3114
3115                 if (FTreeType <> gtt2ch) or (FActiveBBS <> inBBS)
3116                         or (not (CabinetPanel.Visible)) then begin
3117                         FTreeType := gtt2ch;
3118                         HistoryToolBar.Hide;
3119                         FActiveBBS := inBBS;
3120                         TListViewUtils.SetBoardTreeNode(inBBS, TreeView);
3121                         TreeView.Items.GetFirstNode.Expanded := True;                           //\83c\83\8a\81[\83g\83b\83v\8d\80\96Ú\82¾\82¯\82ð\8aJ\82­
3122                         //\83c\83\8a\81[\82Ì\83g\83b\83v\8d\80\96Ú\82ð\91I\91ð\82·\82é
3123                         if GetActiveList = nil then begin
3124                                 try
3125                                         TreeClick( TreeView.Items[0] );
3126                                 except
3127                                 end;
3128                         end else begin
3129                                 for i := 0 to TreeView.Items.Count - 1 do begin
3130                                         if TreeView.Items[i].Data = GetActiveList then begin
3131                                                 TreeClick( TreeView.Items[i] );
3132                                                 Exit;
3133                                         end;
3134                                 end;
3135                                 TreeClick( TreeView.Items[0] );
3136                         end;
3137                 end;
3138         except
3139         end;
3140
3141 end;
3142
3143 procedure TGikoForm.ShowHistoryTree;
3144 var
3145         i, b : Integer;
3146         item : TMenuItem;
3147 begin
3148         if CabinetPanel.Visible then begin
3149                 if FTreeType = gttHistory then begin
3150                         CabinetVisible( False );
3151                         GikoDM.CabinetHistoryAction.Checked := False;
3152                 end else begin
3153                         GikoDM.CabinetHistoryAction.Checked := True;
3154                 end;
3155         end else begin
3156                 CabinetVisible( True );
3157                 GikoDM.CabinetHistoryAction.Checked := True;
3158         end;
3159
3160         // BBS...BBS, History, Favorite
3161         GikoSys.Setting.CabinetIndex := CabinetSelectPopupMenu.Items.Count - 2;
3162
3163         FavoriteTreeView.Visible := False;
3164         TreeView.Visible := True;
3165
3166         GikoDM.CabinetBBSAction.Checked := False;
3167         GikoDM.CabinetFavoriteAction.Checked := False;
3168
3169         if FTreeType <> gttHistory then begin
3170                 b := CabinetSelectPopupMenu.Items.Count - 1;
3171                 for i := 0 to b do begin
3172                         item := CabinetSelectPopupMenu.Items[ i ];
3173                         if item is TBBSMenuItem then begin
3174                                 item.Checked := False;
3175                                 // CabinetMenu \82Í CabinetSelectPopupMenu \82Æ\93¯\82\82Æ\8c\88\82ß\82¤\82¿\82µ\82¿\82á\82¤
3176                                 CabinetMenu.Items[ i ].Checked := False;
3177                         end;
3178                 end;
3179
3180                 FTreeType := gttHistory;
3181                 HistoryToolBar.Show;
3182                 FavoriteToolBar.Hide;
3183         FHistoryList.SetTreeNode( TreeView );
3184                 CabinetSelectToolButton.Caption := '\97\9a\97ð\83\8a\83X\83g';
3185         end;
3186 end;
3187
3188 procedure TGikoForm.SelectTreeNode(Item: TObject; CallEvent: Boolean);
3189 var
3190         ChangeEvent: TTVChangedEvent;
3191         ChangingEvent: TTVChangingEvent;
3192         i: Integer;
3193         bbs : TBBS;
3194 begin
3195         if Item is TCategory then
3196                 bbs := TCategory( Item ).ParenTBBS
3197         else if Item is TBoard then
3198                 bbs := TBoard( Item ).ParentCategory.ParenTBBS
3199         else
3200                 bbs := nil;
3201
3202         if (FTreeType = gtt2ch) and (FActiveBBS = bbs) then begin
3203                 if Item <> FActiveList then begin
3204                         ChangeEvent := nil;
3205                         ChangingEvent := nil;
3206
3207                         if not CallEvent then begin
3208                                 ChangeEvent := TreeView.OnChange;
3209                                 ChangingEvent := TreeView.OnChanging;
3210                         end;
3211                         try
3212                                 if not CallEvent then begin
3213                                         TreeView.OnChange := nil;
3214                                         TreeView.OnChanging := nil;
3215                                 end;
3216                                 //Application.ProcessMessages;
3217                                 for i := 0 to TreeView.Items.Count - 1 do begin
3218                                         if TreeView.Items[i].Data = Item then begin
3219                                                 TreeView.Items[i].Selected := True;
3220                                                 if CallEvent then
3221                                                         TreeClick(TreeView.Items[i]);
3222                                                 Break;
3223                                         end;
3224                                 end;
3225                                 //Application.ProcessMessages;
3226                         finally
3227                                 if not CallEvent then begin
3228                                         TreeView.OnChange := ChangeEvent;
3229                                         TreeView.OnChanging := ChangingEvent;
3230                                 end;
3231                         end;
3232                 end;
3233         end else begin
3234                 if Item <> FActiveList then begin
3235                         ActiveListColumnSave;
3236                         if (Item is TBBS) or (Item is TCategory) then begin
3237                                 ListView.Columns.Clear;
3238                                 SetActiveList( Item );
3239                         end else if Item is TBoard then begin
3240                                 if not TBoard( Item ).IsThreadDatRead then begin
3241                                         Screen.Cursor := crHourGlass;
3242                                         try
3243                                                 if not TBoard( Item ).IsThreadDatRead then
3244                                                         GikoSys.ReadSubjectFile(TBoard( Item ));
3245                                         finally
3246                                                 Screen.Cursor := crDefault;
3247                                         end;
3248                                 end;
3249                                 Sort.SetSortDate(Now());
3250                                 SetActiveList( Item );
3251                         end;
3252                 end;
3253         end;
3254
3255         if Item is TBoard then begin // not TCategory
3256                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3257                         if GikoSys.Setting.ListWidthState = glsMax then begin
3258                                 GikoDM.BrowserMinAction.Execute;
3259                                 if GikoForm.Visible then
3260                                         ListView.SetFocus;
3261                         end;
3262                 end else begin
3263                         if GikoSys.Setting.ListHeightState = glsMax then begin
3264                                 GikoDM.BrowserMinAction.Execute;
3265                                 if GikoForm.Visible then
3266                                         ListView.SetFocus;
3267                         end;
3268                 end;
3269         end;
3270 end;
3271
3272 procedure TGikoForm.ListViewMouseDown(Sender: TObject;
3273         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
3274 var
3275         listItem                : TListItem;
3276         threadItem      : TThreadItem;
3277         pos                                     : TPoint;
3278 //      t: Cardinal;
3279 begin
3280         case Button of
3281         mbMiddle:
3282                 begin
3283                         if not (GetActiveList is TBoard) then Exit;
3284                         listItem := ListView.GetItemAt( X, Y );
3285                         if listItem = nil then Exit;
3286                         if not (TObject(listItem.Data) is TThreadItem) then Exit;
3287
3288                         threadItem := TThreadItem(ListItem.Data);
3289                         InsertBrowserTab(threadItem, False);
3290                         if threadItem.IsLogFile then
3291                                 ListView.UpdateItems(listItem.Index, listItem.Index);
3292                 end;
3293         mbLeft:
3294                 begin
3295                         //\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Å
3296                         if (ssDouble in Shift) then
3297                                 ListDoubleClick(Shift)
3298                         else
3299                                 ListClick;
3300                 end;
3301         mbRight:
3302                 begin
3303                         pos.X := X;
3304                         pos.Y := Y;
3305                         Windows.ClientToScreen( ListView.Handle, pos );
3306                         ListPopupMenu.Popup( pos.X, pos.Y );
3307                 end;
3308         end;
3309
3310 end;
3311
3312 procedure TGikoForm.ListClick;
3313 var
3314         ListItem: TListItem;
3315         ThreadItem: TThreadItem;
3316 begin
3317         if ListView.SelCount <> 1 then Exit;
3318         ListItem := ListView.Selected;
3319         if ListItem = nil then Exit;
3320         if not (TObject(ListItem.Data) is TThreadItem) then Exit;
3321
3322         ThreadItem := TThreadItem(ListItem.Data);
3323         if ThreadItem.IsLogFile then begin
3324                 InsertBrowserTab(ThreadItem);
3325                 ListView.UpdateItems(ListItem.Index, ListItem.Index);
3326         end else begin
3327                 InsertBrowserTab(ThreadItem);
3328         end;
3329
3330         if GikoSys.Setting.BrowserAutoMaximize = gbmClick then begin
3331                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3332                         if GikoSys.Setting.ListWidthState = glsMin then begin
3333                                 GikoDM.BrowserMaxAndFocusAction.Execute;
3334                         end;
3335                 end else begin
3336                         if GikoSys.Setting.ListHeightState = glsMin then begin
3337                                 GikoDM.BrowserMaxAndFocusAction.Execute;
3338                         end;
3339                 end;
3340         end;
3341 end;
3342
3343 procedure TGikoForm.ListDoubleClick(Shift: TShiftState);
3344 var
3345         ThreadItem: TThreadItem;
3346         shiftDown: Boolean;
3347 begin
3348         shiftDown := (ssShift in Shift);
3349
3350         if ListView.Selected = nil then Exit;
3351
3352         if TObject(ListView.Selected.Data) is TCategory then begin
3353                 SelectTreeNode(ListView.Selected.Data, True);
3354         end else if TObject(ListView.Selected.Data) is TBoard then begin
3355                 SelectTreeNode(ListView.Selected.Data, True)
3356         end else if TObject(ListView.Selected.Data) is TThreadItem then begin
3357                 Application.ProcessMessages;
3358                 ThreadItem := TThreadItem(ListView.Selected.Data);
3359                 DownloadContent(ThreadItem, shiftDown);
3360
3361                 if GikoSys.Setting.BrowserAutoMaximize = gbmDoubleClick then begin
3362                         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3363                                 if GikoSys.Setting.ListWidthState = glsMin then begin
3364                                         GikoDM.BrowserMaxAction.Execute;
3365                                         GikoDM.SetFocusForBrowserAction.Execute;
3366                                 end;
3367                         end else begin
3368                                 if GikoSys.Setting.ListHeightState = glsMin then begin
3369                                         GikoDM.BrowserMaxAction.Execute;
3370                                         GikoDM.SetFocusForBrowserAction.Execute;
3371                                 end;
3372                         end;
3373                 end;
3374         end;
3375 end;
3376
3377 procedure TGikoForm.BrowserMovement(const AName: string);
3378 begin
3379         // Access Violation \82ª\8bN\82«\82é\8e\96\82ª\82 \82é\82Ì\82Å\8d¡\8cã\97v\83`\83F\83b\83N
3380         if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
3381                 and (FActiveContent <> nil) then begin
3382                 FActiveContent.Move(AName);
3383         end;
3384 end;
3385
3386 procedure TGikoForm.TreeViewCollapsed(Sender: TObject; Node: TTreeNode);
3387 begin
3388         if TObject(Node.Data) is TBBS then begin
3389                 TBBS(Node.Data).NodeExpand := False;
3390         end else if TObject(Node.Data) is TCategory then begin
3391                 TCategory(Node.Data).NodeExpand := False;
3392         end else if TObject(Node.Data) is TBoard then begin
3393                 TBoard(Node.Data).NodeExpand := False;
3394         end;
3395         if (TreeView.Selected <> nil) and (TreeView.Selected = Node) then begin
3396         TreeClick(TreeView.Selected);
3397         end;
3398 end;
3399
3400 procedure TGikoForm.MessageListViewResize(Sender: TObject);
3401 begin
3402 //      MessageListView.Column[0].Width := MessageListView.ClientWidth - 16;
3403 end;
3404 procedure       TGikoForm.CabinetVisible( isVisible : Boolean );
3405 begin
3406         TreeSplitter.Visible := isVisible;
3407         CabinetPanel.Visible := isVisible;
3408         GikoDM.CabinetVisibleAction.Checked := isVisible;
3409 end;
3410
3411 procedure TGikoForm.SelectListItem(List: TList);
3412 var
3413         TmpListItem: TListItem;
3414 begin
3415         List.Clear;
3416         List.Capacity := 0;
3417         TmpListItem := ListView.Selected;
3418         while TmpListItem <> nil do begin
3419                 List.Add(TmpListItem.Data);
3420                 TmpListItem := ListView.GetNextItem(TmpListItem, sdAll, [isSelected]);
3421         end;
3422
3423 end;
3424
3425 procedure TGikoForm.FormResize(Sender: TObject);
3426 begin
3427
3428         MessageListView.Column[0].Width := MessageListView.ClientWidth - 32;
3429         MainCoolBar.Width := TopPanel.Width - TopRightPanel.Width;
3430
3431         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3432                 if GikoSys.Setting.ListWidthState = glsMin then begin
3433                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
3434                         ViewPanel.Width := ThreadMainPanel.Width - 80;
3435                 end;
3436         end else begin
3437                 if GikoSys.Setting.ListHeightState = glsMin then begin
3438                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
3439                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
3440                 end;
3441         end;
3442
3443         FIsIgnoreResize := rtResizing;
3444         PostMessage( Handle, USER_RESIZED, 0, 0 );
3445
3446
3447 end;
3448
3449 procedure TGikoForm.DeleteTab(BrowserRecord: TBrowserRecord);
3450 var
3451         i: Integer;
3452 begin
3453         FTabHintIndex := -1;
3454         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3455                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]) = BrowserRecord then begin
3456             DeleteTab(i, BrowserTab.TabIndex);
3457                         Break;
3458                 end;
3459         end;
3460 end;
3461 procedure TGikoForm.DeleteTab(ThreadItem: TThreadItem);
3462 var
3463         i: Integer;
3464 begin
3465         FTabHintIndex := -1;
3466         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3467                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
3468             DeleteTab(i, BrowserTab.TabIndex);
3469                         Break;
3470                 end;
3471         end;
3472 end;
3473 procedure TGikoForm.DeleteTab(index, selectIndex: Integer);
3474 var
3475     doc: Variant;
3476     j: Integer;
3477 begin
3478     try
3479         if TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser <> nil then begin
3480             doc := TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser.Document;
3481             TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.ScrollTop := doc.Body.ScrollTop;
3482         end;
3483     except
3484         TBrowserRecord(BrowserTab.Tabs.Objects[index]).Thread.ScrollTop := 0;
3485     end;
3486     if(FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[index])) then
3487         FActiveContent := nil;
3488     if TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser <> nil then begin
3489         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[index]).Browser);
3490         if j <> -1 then
3491             FBrowsers.Move(j, BROWSER_COUNT - 1);
3492     end;
3493     BrowserTab.Tabs.BeginUpdate;
3494     try
3495         TBrowserRecord(BrowserTab.Tabs.Objects[index]).Free;
3496         if ( BrowserTab.Tabs.Count - 1 = index ) and
3497             ( BrowserTab.TabRect(index).Left
3498                 <= BrowserTab.DisplayRect.Left ) then begin
3499             BrowserTab.ScrollTabs(-1);
3500         end;
3501         BrowserTab.Tabs.Delete(index);
3502         if selectIndex > index then begin
3503             BrowserTab.TabIndex := selectIndex - 1;
3504         end else begin
3505             if BrowserTab.Tabs.Count -1 >= selectIndex then
3506                 BrowserTab.TabIndex := selectIndex
3507             else
3508                 BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
3509         end;
3510     finally
3511         BrowserTab.Tabs.EndUpdate;
3512     end;
3513     if BrowserTab.Tabs.Count = 0 then begin
3514         BrowserNullTab.Thread := nil;
3515     end;
3516     if(BrowserTab.TabIndex <> -1) and
3517         ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
3518         for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
3519             if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
3520                  = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
3521             begin
3522                 ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
3523                 break;
3524             end;
3525         end;
3526         TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
3527              :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3528         TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
3529         FBrowsers.Move(BROWSER_COUNT - 1, 0);
3530     end;
3531
3532     if( FActiveContent = nil) then
3533         BrowserTab.OnChange(nil);
3534 end;
3535 function TGikoForm.Hook(var Message: TMessage): Boolean;
3536 begin
3537         //\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Ì
3538         //\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ð
3539         Result := False;
3540         case Message.Msg of
3541         CM_APPKEYDOWN:
3542                 Result := True;         //\83V\83\87\81[\83g\83J\83b\83g\83L\81[\96³\8cø
3543         CM_APPSYSCOMMAND:
3544                 Result := True;  // \83A\83N\83Z\83\89\83\8c\81[\83^\82ð\96³\8cø\82É\82·\82é
3545         end;
3546 end;
3547
3548 procedure TGikoForm.ListPopupMenuPopup(Sender: TObject);
3549 var
3550     bBoard, bCategory : Boolean;
3551 begin
3552     bBoard := (GetActiveList is TBoard);
3553     bCategory := (GetActiveList is TCategory);
3554         ItemRoundPMenu.Visible := bBoard;
3555         ItemReservPMenu.Visible := bBoard;
3556         LPMSep01.Visible := bBoard;
3557         ListRoundPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
3558         ListReservPMenu.Visible := bCategory;// or (GetActiveList is TBoard);
3559         LPMSep02.Visible := bCategory or bBoard;
3560         KidokuPMenu.Visible := bBoard;
3561         MidokuPMenu.Visible := bBoard;
3562         UrlCopyPMenu.Visible := bCategory or bBoard;
3563         NameUrlCopyPMenu.Visible := bCategory or bBoard;
3564         AllSelectPMenu.Visible := bCategory or bBoard;
3565         LPMSep05.Visible := bCategory or bBoard;
3566         DeletePMenu.Visible := bBoard;
3567         LPMSep06.Visible := bCategory or bBoard;
3568         BoardFavoriteAddMenu.Visible := bCategory;
3569         ThreadFavoriteAddMenu.Visible := bBoard;
3570     SaveThreadFile.Visible := bBoard;
3571         AddRoundNameMenu(ItemReservPMenu);
3572         AddRoundNameMenu(ListReservPMenu);
3573 end;
3574
3575 procedure TGikoForm.TreePopupMenuPopup(Sender: TObject);
3576 begin
3577         FClickNode := TreeView.Selected;
3578         if FClickNode = nil then begin
3579                 TreeSelectThreadPupupMenu.Visible := False;
3580                 TreeSelectBoardPupupMenu.Visible := False;
3581                 TPMSep01.Visible := False;
3582                 TreeSelectURLPupupMenu.Visible := False;
3583                 TreeSelectNamePupupMenu.Visible := False;
3584                 TreeSelectNameURLPupupMenu.Visible := False;
3585                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3586                 TreeSelectLogDeleteSeparator.Visible := False;
3587                 TreeSelectLogDeletePopupMenu.Visible := False;
3588         end else if TObject(FClickNode.Data) is TBoard then begin
3589                 TreeSelectThreadPupupMenu.Visible := False;
3590                 TreeSelectBoardPupupMenu.Visible := True;
3591                 TPMSep01.Visible := True;
3592                 TreeSelectURLPupupMenu.Visible := True;
3593                 TreeSelectNamePupupMenu.Visible := True;
3594                 TreeSelectNameURLPupupMenu.Visible := True;
3595                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3596                 TreeSelectLogDeleteSeparator.Visible := False;
3597                 TreeSelectLogDeletePopupMenu.Visible := False;
3598         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
3599                 TreeSelectThreadPupupMenu.Visible := False;
3600                 TreeSelectBoardPupupMenu.Visible := True;
3601                 TPMSep01.Visible := True;
3602                 TreeSelectURLPupupMenu.Visible := True;
3603                 TreeSelectNamePupupMenu.Visible := True;
3604                 TreeSelectNameURLPupupMenu.Visible := True;
3605                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3606                 TreeSelectLogDeleteSeparator.Visible := False;
3607                 TreeSelectLogDeletePopupMenu.Visible := False;
3608         end else if (TObject(FClickNode.Data) is TThreadItem) then begin
3609                 TreeSelectThreadPupupMenu.Visible := True;
3610                 TreeSelectBoardPupupMenu.Visible := False;
3611                 TPMSep01.Visible := True;
3612                 TreeSelectURLPupupMenu.Visible := True;
3613                 TreeSelectNamePupupMenu.Visible := True;
3614                 TreeSelectNameURLPupupMenu.Visible := True;
3615                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3616                 TreeSelectLogDeleteSeparator.Visible := True;
3617                 TreeSelectLogDeletePopupMenu.Visible := True;
3618         end else if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
3619                 TreeSelectThreadPupupMenu.Visible := True;
3620                 TreeSelectBoardPupupMenu.Visible := False;
3621                 TPMSep01.Visible := True;
3622                 TreeSelectURLPupupMenu.Visible := True;
3623                 TreeSelectNamePupupMenu.Visible := True;
3624                 TreeSelectNameURLPupupMenu.Visible := True;
3625                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3626                 TreeSelectLogDeleteSeparator.Visible := True;
3627                 TreeSelectLogDeletePopupMenu.Visible := True;
3628         end else if (TObject(FClickNode.Data) is TCategory) then begin
3629                 TreeSelectThreadPupupMenu.Visible := False;
3630                 TreeSelectBoardPupupMenu.Visible := False;
3631                 TPMSep01.Visible := False;
3632                 TreeSelectURLPupupMenu.Visible := False;
3633                 TreeSelectNamePupupMenu.Visible := True;
3634                 TreeSelectNameURLPupupMenu.Visible := False;
3635                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3636                 TreeSelectLogDeleteSeparator.Visible := False;
3637                 TreeSelectLogDeletePopupMenu.Visible := False;
3638         end else if FClickNode.IsFirstNode then begin
3639                 TreeSelectThreadPupupMenu.Visible := False;
3640                 TreeSelectBoardPupupMenu.Visible := False;
3641                 TPMSep01.Visible := False;
3642                 TreeSelectURLPupupMenu.Visible := False;
3643                 TreeSelectNamePupupMenu.Visible := True;
3644                 TreeSelectNameURLPupupMenu.Visible := False;
3645                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3646                 TreeSelectLogDeleteSeparator.Visible := False;
3647                 TreeSelectLogDeletePopupMenu.Visible := False;
3648         end else begin
3649                 TreeSelectThreadPupupMenu.Visible := False;
3650                 TreeSelectBoardPupupMenu.Visible := False;
3651                 TPMSep01.Visible := False;
3652                 TreeSelectURLPupupMenu.Visible := False;
3653                 TreeSelectNamePupupMenu.Visible := False;
3654                 TreeSelectNameURLPupupMenu.Visible := False;
3655                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3656                 TreeSelectLogDeleteSeparator.Visible := False;
3657                 TreeSelectLogDeletePopupMenu.Visible := False;
3658         end;
3659 end;
3660
3661 procedure TGikoForm.BrowserNewWindow2(Sender: TObject;
3662         var ppDisp: IDispatch; var Cancel: WordBool);
3663 var
3664         Text: string;
3665         Html: string;
3666         URL: string;
3667         idx: Integer;
3668         wkIntSt: Integer;
3669         wkIntTo: Integer;
3670     BNum, BRes: string;
3671     threadItem: TThreadItem;
3672     aElement : IHTMLElement;
3673 begin
3674         Cancel := True;
3675     aElement := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement;
3676         if ( aElement <> nil) then begin
3677                 Text := aElement.Get_outerText;
3678                 Html := aElement.Get_outerHTML;
3679                 if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
3680                         or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
3681                         if GikoSys.Setting.ResAnchorJamp then begin
3682
3683                                 Text := ZenToHan(Trim(Text));
3684
3685                                 if(AnsiPos('>>', Text) = 1) then begin
3686                                         //Text := Copy(Text, 3, Length(Text) - 2);
3687                                         Delete(Text, 1, 2);
3688                                 end else begin
3689                                         //Text := Copy(Text, 2, Length(Text) - 1);
3690                                         Delete(Text, 1, 1);
3691                                 end;
3692
3693                                 if AnsiPos('-', Text) <> 0 then begin
3694                                         wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
3695                                         Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
3696                                         wkIntTo := StrToIntDef(Text, 0);
3697                                         if wkIntTo < wkIntSt then
3698                                                 wkIntSt := wkIntTo;
3699                                 end else begin
3700                                         wkIntSt := StrToIntDef(Text, 0);
3701                                 end;
3702
3703                                 if wkIntSt <> 0 then begin
3704                                         FActiveContent.IDAnchorPopup('');
3705                     MoveHisotryManager.pushItem(FActiveContent);
3706                                         BrowserMovement(IntToStr(wkIntSt));
3707                                 end;
3708
3709
3710                         end;
3711                 end else begin
3712             ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
3713
3714                         URL := GikoSys.GetHRefText(Html);
3715                         URL := GikoSys.HTMLDecode(URL);
3716             if AnsiPos('BE:', URL) = 1 then begin
3717                                 BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
3718                                 BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
3719                 threadItem := FActiveContent.Thread;
3720                 if threadItem = nil then Exit;
3721                 URL := BE_PHP_URL + BNum + '&u=d'
3722                         + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
3723             end;
3724
3725                         if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
3726                                 ( AnsiPos('ftp://', URL) = 1) then begin
3727                                 //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
3728                                 if GikoSys.Setting.LinkAddAddressBar then begin
3729                                         idx := AddressComboBox.Items.IndexOf(URL);
3730                                         if idx = -1 then begin
3731                                                 AddressComboBox.Items.Insert(0, URL);
3732                                                 if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
3733                                                         AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
3734                                         end else begin
3735                                                 AddressComboBox.Items.Delete(idx);
3736                                                 AddressComboBox.Items.Insert(0, URL);
3737                                         end;
3738                                 end;
3739                 MoveHisotryManager.pushItem(FActiveContent);
3740                                 MoveToURL( URL );
3741                         end;
3742                 end;
3743         end;
3744
3745 end;
3746
3747 procedure TGikoForm.ListSplitterMoved(Sender: TObject);
3748 begin
3749         if Mouse.Capture <> 0 then
3750                 Exit;
3751         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3752                 if (ViewPanel.Width > 1) and (ViewPanel.Width <= (ThreadMainPanel.Width - 80)) then
3753                         FBrowserSizeWidth := ViewPanel.Width;
3754         end else begin
3755                 if (ViewPanel.Height > 1) and (ViewPanel.Height <= (ThreadMainPanel.Height - BrowserCoolBar.Height)) then
3756                         FBrowserSizeHeight := ViewPanel.Height;
3757         end;
3758         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3759                 if ViewPanel.Width < 2 then begin
3760                         ViewPanel.Width := 1;
3761                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3762                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3763                         GikoSys.Setting.ListWidthState := glsMax;
3764                 end else if ViewPanel.Width > (ThreadMainPanel.Width - 80) then begin
3765                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3766                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3767                         GikoSys.Setting.ListWidthState := glsMin;
3768                 end else begin
3769                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3770                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3771                         GikoSys.Setting.ListWidthState := glsNormal;
3772                 end;
3773         end else begin
3774                 if ViewPanel.Height < 2 then begin
3775                         ViewPanel.Height := 1;
3776                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3777                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3778                         GikoSys.Setting.ListHeightState := glsMax;
3779                 end else if ViewPanel.Height > (ThreadMainPanel.Height - BrowserCoolBar.Height - 7) then begin
3780                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3781                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3782                         GikoSys.Setting.ListHeightState := glsMin;
3783                 end else begin
3784                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3785                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3786                         GikoSys.Setting.ListHeightState := glsNormal;
3787                 end;
3788         end;
3789 {       if (Mouse.Capture = 0) and (ViewPanel.Height > 1) and (not ArrangeAction.Checked) then
3790                 FBrowserSizeHeight := ViewPanel.Height
3791         else if (Mouse.Capture = 0) and (ViewPanel.Width > 1) and (ArrangeAction.Checked) then
3792                 FBrowserSizeWidth := ViewPanel.Width;}
3793 end;
3794
3795 procedure TGikoForm.BrowserTabChange(Sender: TObject);
3796 var
3797         i, j: Integer;
3798         idx: Integer;
3799 begin
3800         BrowserTab.Tabs.BeginUpdate;
3801         try
3802                 if not BrowserTab.Dragging then begin
3803                         FTabHintIndex := -1;
3804                         BrowserTab.Hint := '';
3805                         idx := BrowserTab.TabIndex;
3806                         if idx = -1 then begin
3807                                 SetContent(BrowserNullTab);
3808
3809                         end else if(BrowserTab.Tabs.Objects[idx] <> nil) and (BrowserTab.Tabs.Objects[idx] is TBrowserRecord) then begin
3810                                 if TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser <> nil then begin
3811                                         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser);
3812                                         if j <> -1 then
3813                                                 FBrowsers.Move(j ,0);
3814                                 end else begin
3815                                         if( FActiveContent <> nil ) and (FActiveContent.Browser <> nil) and
3816                                                 (FActiveContent.Browser <> BrowserNullTab.Browser) and
3817                                                 (FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
3818                                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
3819
3820                                         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3821                                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
3822                                                         ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
3823                                                         break;
3824                                                 end;
3825                                         end;
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 var
6503         p : TPoint;
6504         e: IHTMLElement;
6505         AID: string;
6506         stlist : TStringList;
6507         i, count, rc : Integer;
6508         body : String;
6509     limited : boolean;
6510 begin
6511   result := true;
6512   try
6513         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
6514                 FActiveContent.Browser.SetFocus;
6515                 try
6516                         GetCursorPos(p);
6517                         p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
6518                         p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
6519                         e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
6520                         if (Assigned(e)) then begin
6521                                 if (e.className = 'date') or (e.id = 'date') then begin
6522                                         AID := e.innerText;
6523                                         if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
6524                                                 AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
6525                         if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
6526                                 AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
6527                         end;
6528                                         end else begin
6529                                                 stlist := TStringList.Create;
6530                                                 try
6531                                                         stList.DelimitedText := AID;
6532                                                         AID := '';
6533                                                         for i := 0 to stList.Count - 1 do
6534                                                                 if Length(WideString(stList[i])) = 8 then begin
6535                                                                         if GikoSys.NotDateorTimeString(stList[i]) then begin
6536                                                                                 AID := stList[i];
6537                                                                                 break;
6538                                                                         end;
6539                                                                 end;
6540                                                 finally
6541                                                         stList.Free;
6542                                                 end;
6543                                         end;
6544                     count := GikoSys.GetSameIDResCount(AID, FActiveContent.Thread);
6545                     limited := false;
6546                     if count > 20 then begin
6547                         rc := GikoUtil.MsgBox(Handle,
6548                                 '20\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
6549                                 'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
6550                                                                 MB_YESNO or MB_ICONQUESTION);
6551                         limited := rc <> ID_YES;
6552                     end;
6553                                         body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
6554                                         FActiveContent.IDAnchorPopup(body);
6555                                 end;
6556                         end;
6557                 except
6558                 end;
6559   except
6560   end;
6561 end;
6562
6563 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
6564 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
6565 begin
6566         SelectTimer.Interval := 0;
6567         if not (ListView.Selected = nil) then
6568                 if( FActiveContent = nil) or
6569                                 (GetActiveContent <> TThreadItem(ListView.Selected.Data) ) then begin
6570                         ListClick;
6571                 end;
6572 end;
6573
6574 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
6575 procedure TGikoForm.ActiveListColumnSave;
6576 var
6577         ActivListObj    : TObject;
6578         i, id, idx              : Integer;
6579         BBSOrder                        : TGikoBBSColumnList;
6580         CategoryOrder   : TGikoCategoryColumnList;
6581         BoardOrder              : TGikoBoardColumnList;
6582 begin
6583
6584         ActivListObj := ActiveList;
6585         if ActivListObj is TBBS then begin
6586                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6587                 BBSOrder := TGikoBBSColumnList.Create;
6588                 try
6589                         for i := 0 to ListView.Columns.Count - 1 do begin
6590                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6591                                 idx := ListView.Column[ i ].Tag;
6592                                 id := Ord( GikoSys.Setting.BBSColumnOrder[ idx ] );
6593                                 BBSOrder.Add( TGikoBBSColumnID( id ) );
6594                                 // \95\9d\82Ì\95Û\91
6595                                 GikoSys.Setting.BBSColumnWidth[ id ] := ListView.Column[ i ].Width;
6596                         end;
6597                         for i := 0 to ListView.Columns.Count - 1 do
6598                                 // \8f\87\8f\98\82Ì\95Û\91
6599                                 GikoSys.Setting.BBSColumnOrder[ i ] := BBSOrder[ i ];
6600                 finally
6601                         BBSOrder.Free;
6602                 end;
6603         end else if ActivListObj is TCategory then begin
6604                 //===== \94Â\83\8a\83X\83g =====
6605                 CategoryOrder := TGikoCategoryColumnList.Create;
6606                 try
6607                         for i := 0 to ListView.Columns.Count - 1 do begin
6608                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6609                                 idx := ListView.Column[ i ].Tag;
6610                                 id := Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] );
6611                                 CategoryOrder.Add( TGikoCategoryColumnID( id ) );
6612                                 // \95\9d\82Ì\95Û\91
6613                                 GikoSys.Setting.CategoryColumnWidth[ id ] := ListView.Column[ i ].Width;
6614                         end;
6615                         for i := 0 to ListView.Columns.Count - 1 do
6616                                 // \8f\87\8f\98\82Ì\95Û\91
6617                                 GikoSys.Setting.CategoryColumnOrder[ i ] := CategoryOrder[ i ];
6618                 finally
6619                         CategoryOrder.Free;
6620                 end;
6621         end else if ActivListObj is TBoard then begin
6622                 //===== \83X\83\8c\83\8a\83X\83g =====
6623                 BoardOrder := TGikoBoardColumnList.Create;
6624                 try
6625                         for i := 0 to ListView.Columns.Count - 1 do begin
6626                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6627                                 idx := ListView.Column[ i ].Tag;
6628                                 id := Ord( GikoSys.Setting.BoardColumnOrder[ idx ] );
6629                                 BoardOrder.Add( TGikoBoardColumnID( id ) );
6630                                 // \95\9d\82Ì\95Û\91
6631                                 GikoSys.Setting.BoardColumnWidth[ id ] := ListView.Column[ i ].Width;
6632                         end;
6633                         for i := 0 to ListView.Columns.Count - 1 do
6634                                 // \8f\87\8f\98\82Ì\95Û\91
6635                                 GikoSys.Setting.BoardColumnOrder[ i ] := BoardOrder[ i ];
6636                 finally
6637                         BoardOrder.Free;
6638                 end;
6639         end;
6640
6641 end;
6642
6643 procedure TGikoForm.ListViewColumnRightClick(Sender: TObject;
6644         Column: TListColumn; Point: TPoint);
6645 var
6646         i, j    : Integer;
6647         item    : TMenuItem;
6648 begin
6649
6650         // \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82ð\83N\83\8a\83A
6651         for i := ListColumnPopupMenu.Items.Count - 1 downto 0 do
6652                 ListColumnPopupMenu.Items.Items[ i ].Free;
6653
6654         // \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¢)
6655         if TObject( FActiveList ) is TBBS then begin
6656
6657                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6658                 for i := 1 to Length( GikoBBSColumnCaption ) - 1 do begin
6659                         item := TMenuItem.Create( ListColumnPopupMenu );
6660                         item.Caption := GikoBBSColumnCaption[ i ];
6661                         item.Tag := i;
6662                         item.OnClick := ListColumnPopupMenuOnClick;
6663                         for j := GikoSys.Setting.BBSColumnOrder.Count - 1 downto 0 do begin
6664                                 if GikoSys.Setting.BBSColumnOrder[ j ] = TGikoBBSColumnID( i ) then begin
6665                                         item.Checked := True;
6666                                         Break;
6667                                 end;
6668                         end;
6669                         ListColumnPopupMenu.Items.Add( item );
6670                 end;
6671
6672         end else if TObject( FActiveList ) is TCategory then begin
6673
6674                 //===== \94Â\83\8a\83X\83g =====
6675                 for i := 1 to Length( GikoCategoryColumnCaption ) - 1 do begin
6676                         item := TMenuItem.Create( ListColumnPopupMenu );
6677                         item.Caption := GikoCategoryColumnCaption[ i ];
6678                         item.Tag := i;
6679                         item.OnClick := ListColumnPopupMenuOnClick;
6680                         for j := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 0 do begin
6681                                 if GikoSys.Setting.CategoryColumnOrder[ j ] = TGikoCategoryColumnID( i ) then begin
6682                                         item.Checked := True;
6683                                         Break;
6684                                 end;
6685                         end;
6686                         ListColumnPopupMenu.Items.Add( item );
6687                 end;
6688
6689         end else if TObject( FActiveList ) is TBoard then begin
6690
6691                 //===== \83X\83\8c\83\8a\83X\83g =====
6692                 for i := 1 to Length( GikoBoardColumnCaption ) - 1 do begin
6693                         item := TMenuItem.Create( ListColumnPopupMenu );
6694                         item.Caption := GikoBoardColumnCaption[ i ];
6695                         item.Tag := i;
6696                         item.OnClick := ListColumnPopupMenuOnClick;
6697                         for j := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 0 do begin
6698                                 if GikoSys.Setting.BoardColumnOrder[ j ] = TGikoBoardColumnID( i ) then begin
6699                                         item.Checked := True;
6700                                         Break;
6701                                 end;
6702                         end;
6703                         ListColumnPopupMenu.Items.Add( item );
6704                 end;
6705
6706         end;
6707
6708         // \83\81\83j\83\85\81[\82Ì\95\\8e¦
6709         Point := ListView.ClientToScreen( Point );
6710         if ListColumnPopupMenu.Items.Count > 0 then
6711                 ListColumnPopupMenu.Popup( Point.X, Point.Y );
6712
6713 end;
6714
6715 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
6716 procedure       TGikoForm.ListColumnPopupMenuOnClick( Sender : TObject );
6717 var
6718         i                                       : Integer;
6719         orderList       : TList;
6720         item                    : TMenuItem;
6721 begin
6722
6723         if not (Sender is TMenuItem) then
6724                 Exit;
6725
6726         ActiveListColumnSave;
6727         item := TMenuItem( Sender );
6728
6729         if TObject( FActiveList ) is TBBS then
6730                 orderList := GikoSys.Setting.BBSColumnOrder
6731         else if TObject( FActiveList ) is TCategory then
6732                 orderList := GikoSys.Setting.CategoryColumnOrder
6733         else if TObject( FActiveList ) is TBoard then
6734                 orderList := GikoSys.Setting.BoardColumnOrder
6735         else
6736                 Exit;
6737
6738         if item.Checked then begin
6739                 // \83J\83\89\83\80\82Ì\8dí\8f\9c
6740                 for i := orderList.Count - 1 downto 0 do begin
6741                         if Integer( orderList[ i ] ) = item.Tag then begin
6742                                 orderList.Delete( i );
6743                                 Break;
6744                         end;
6745                 end;
6746         end else begin
6747                 // \83J\83\89\83\80\82Ì\92Ç\89Á
6748                 orderList.Add( Pointer( item.Tag ) );
6749         end;
6750
6751         SetActiveList( FActiveList );
6752
6753 end;
6754
6755 procedure TGikoForm.OnGestureStart(Sender: TObject);
6756 begin
6757 //
6758 end;
6759
6760 procedure TGikoForm.OnGestureMove(Sender: TObject);
6761 var
6762         s: string;
6763         Action: TAction;
6764         ActStr: string;
6765         P : TPoint;
6766 begin
6767         //\83}\83E\83X\88Ê\92u\82Ì\8eæ\93¾
6768         GetCursorPos(P);
6769         //\83R\83\93\83|\81[\83l\83\93\83g\96¼\8eæ\93¾
6770         s := MouseGesture.GetGestureStr;
6771         ActStr := '';
6772         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
6773         if Action <> nil then
6774                 ActStr := '\81i' + Action.Caption + '\81j';
6775         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
6776         StatusBar.Panels[1].Text := s;
6777 end;
6778
6779 procedure TGikoForm.OnGestureEnd(Sender: TObject);
6780 var
6781         s: string;
6782         Action: TAction;
6783 begin
6784         s := MouseGesture.GetGestureStr;
6785     MouseGesture.ClearGesture;
6786         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
6787         if Action <> nil then
6788                 Action.Execute;
6789         StatusBar.Panels[1].Text := '';
6790 end;
6791
6792 procedure TGikoForm.ListViewCustomDrawItem(Sender: TCustomListView;
6793   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
6794 var
6795         ThreadItem: TThreadItem;
6796 begin
6797         DefaultDraw := true;
6798         if TObject(Item.Data) is TThreadItem then begin
6799                 ThreadItem := TThreadItem(Item.Data);
6800                 if ( FUseOddResOddColor ) and ( ThreadItem.Count <> 0 ) and ( ThreadItem.AllResCount <> ThreadItem.Count) then begin
6801                         ListView.Canvas.Brush.Color := FOddColor;
6802                         //\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
6803                         if (GikoSys.Setting.UnFocusedBold) and
6804                          (Item.Selected) and (not ListView.Focused) then begin
6805                                 ListView.Canvas.Font.Style := [fsBold];
6806                         end;
6807                 end else begin
6808                         ListView.Canvas.Brush.Color := FListViewBackGroundColor;
6809                 end;
6810
6811                 if ThreadItem.UnRead then
6812                         ListView.Canvas.Font.Style := [fsBold];
6813         end;
6814
6815 end;
6816
6817 procedure TGikoForm.FormActivate(Sender: TObject);
6818 begin
6819         if GikoSys.Setting.GestureEnabled then begin
6820                 GikoSys.Setting.Gestures.ClearGesture;
6821                 GikoSys.Setting.Gestures.LoadGesture(
6822                         GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
6823                 MouseGesture.UnHook;
6824                 MouseGesture.OnGestureStart := OnGestureStart;
6825                 MouseGesture.OnGestureMove := OnGestureMove;
6826                 MouseGesture.OnGestureEnd := OnGestureEnd;
6827                 MouseGesture.SetHook(Handle);
6828         end else begin
6829                 //MouseGesture.UnHook;
6830                 MouseGesture.OnGestureStart := nil;
6831                 MouseGesture.OnGestureMove := nil;
6832                 MouseGesture.OnGestureEnd := nil;
6833         end;
6834 end;
6835
6836 procedure TGikoForm.BrowserPanelResize(Sender: TObject);
6837 begin
6838         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
6839                 MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
6840         end;
6841
6842 end;
6843 procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
6844 var
6845         coolSet                         : TCoolSet;
6846         toolbar                         : TToolBar;
6847         band                                    : TCoolBand;
6848         affectedBand    : TCoolBand;
6849         i                                                       : Integer;
6850 begin
6851         if (FOldFormWidth = Width) and not IsIconic( Handle ) and (FIsIgnoreResize = rtNone) then begin
6852                 FIsIgnoreResize := rtResizing;
6853                 PostMessage( Handle, USER_RESIZED, 0, 0 );
6854                 band := nil;
6855                 // \95Ï\8dX\82³\82ê\82½\83N\81[\83\8b\83o\81[\82Ì\92l\82ð\95Û\91
6856                 if CoolBar = MainCoolBar then begin
6857                         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
6858                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
6859                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
6860                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
6861                                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
6862                         end;
6863                 end else if CoolBar = ListCoolBar then begin
6864                         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
6865                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
6866                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
6867                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
6868                                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
6869                         end;
6870                 end else if CoolBar = BrowserCoolBar then begin
6871                         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
6872                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
6873                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
6874                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
6875                                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
6876                         end;
6877                 end;
6878                 if not (Sender is TToolBar) or (CoolBar = nil) then
6879                         Exit;
6880                 toolbar := TToolBar( Sender );
6881                 // \95\9d\82Ì\95Ï\8dX\82³\82ê\82½\83o\83\93\83h\82ð\8c©\82Â\82¯\82é
6882                 affectedBand := nil;
6883                 for i := CoolBar.Bands.Count - 1 downto 0 do begin
6884                         if CoolBar.Bands[ i ].Control.Handle = toolbar.Handle then begin
6885                                 band    := CoolBar.Bands[ i ];
6886                                 if band.Break or (i = 0) then begin
6887                                         if i + 1 < CoolBar.Bands.Count then
6888                                                 if not CoolBar.Bands[ i + 1 ].Break then
6889                                                         affectedBand := CoolBar.Bands[ i + 1 ];
6890                                 end else begin
6891                                         if i > 0 then
6892                                                 affectedBand := CoolBar.Bands[ i - 1 ];
6893                                 end;
6894                                 Break;
6895                         end;
6896                 end;
6897                 // \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·
6898                 if CoolBar = MainCoolBar then begin
6899                         coolSet := GikoSys.Setting.MainCoolSet[ band.ID ];
6900                         coolSet.FCoolWidth := toolbar.Width + 25;
6901                         GikoSys.Setting.MainCoolSet[ band.ID ] := coolSet;
6902                         if affectedBand <> nil then begin
6903                                 coolSet := GikoSys.Setting.MainCoolSet[ affectedBand.ID ];
6904                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
6905                                 GikoSys.Setting.MainCoolSet[ affectedBand.ID ] := coolSet;
6906                         end;
6907                 end else if CoolBar = ListCoolBar then begin
6908                         coolSet := GikoSys.Setting.ListCoolSet[ band.ID ];
6909                         coolSet.FCoolWidth := toolbar.Width + 25;
6910                         GikoSys.Setting.ListCoolSet[ band.ID ] := coolSet;
6911                         if affectedBand <> nil then begin
6912                                 coolSet := GikoSys.Setting.ListCoolSet[ affectedBand.ID ];
6913                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
6914                                 GikoSys.Setting.ListCoolSet[ affectedBand.ID ] := coolSet;
6915                         end;
6916                 end else if CoolBar = BrowserCoolBar then begin
6917                         coolSet := GikoSys.Setting.BrowserCoolSet[ band.ID ];
6918                         coolSet.FCoolWidth := toolbar.Width + 25;
6919                         GikoSys.Setting.BrowserCoolSet[ band.ID ] := coolSet;
6920                         if affectedBand <> nil then begin
6921                                 coolSet := GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ];
6922                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
6923                                 GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ] := coolSet;
6924                         end;
6925                 end;
6926         end;
6927 end;
6928
6929
6930 procedure TGikoForm.MenuToolBarResize(Sender: TObject);
6931 begin
6932         CoolBarResized( Sender, MainCoolBar );
6933 end;
6934
6935 procedure TGikoForm.ListToolBarResize(Sender: TObject);
6936 begin
6937         CoolBarResized( Sender, ListCoolBar );
6938 end;
6939
6940 procedure TGikoForm.BrowserToolBarResize(Sender: TObject);
6941 begin
6942         CoolBarResized( Sender, BrowserCoolBar );
6943 end;
6944
6945 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
6946 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
6947 var
6948         ThreadItem      : TThreadItem;
6949         ReadList                : TStringList;
6950         wordCount               : TWordCount;
6951 begin
6952         ThreadItem      := GetActiveContent;
6953         ReadList                := TStringList.Create;
6954         wordCount               := TWordCount.Create;
6955         try
6956                 ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
6957 {$IFDEF SPAM_FILTER_ENABLED}
6958                 // \83X\83p\83\80\82É\90Ý\92è
6959                 ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
6960                 GikoSys.SpamCountWord( ReadList[ ATag - 1 ], wordCount );
6961                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
6962                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
6963 {$ENDIF}
6964                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
6965                 GikoSys.FAbon.AddIndividualAbon(Atag, Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
6966         finally
6967                 wordCount.Free;
6968                 ReadList.Free;
6969         end;
6970         FActiveContent.Repaint := true;
6971         if ThreadItem <> nil then
6972                 InsertBrowserTab( ThreadItem, True );
6973 end;
6974
6975 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
6976 procedure TGikoForm.IndividualAbonID(Atype : Integer);
6977 var
6978         ThreadItem : TThreadItem;
6979         i, No : Integer;
6980         body : TStringList;
6981         ReadList                : TStringList;
6982         wordCount               : TWordCount;
6983 begin
6984         No := KokoPopupMenu.Tag;
6985         if No = 0 then Exit;
6986         ThreadItem := GetActiveContent;
6987         if ThreadItem = nil then Exit;
6988         body := TStringList.Create;
6989         try
6990                 GikoSys.GetSameIDRes(No, ThreadItem, body);
6991
6992                 ReadList                := TStringList.Create;
6993                 wordCount               := TWordCount.Create;
6994                 try
6995                         ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
6996 {$IFDEF SPAM_FILTER_ENABLED}
6997                         // \83X\83p\83\80\82É\90Ý\92è
6998                         ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
6999 {$ENDIF}
7000                         for i := 0 to body.Count - 1 do begin
7001 {$IFDEF SPAM_FILTER_ENABLED}
7002                                 GikoSys.SpamCountWord( ReadList[ i ], wordCount );
7003                                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7004                                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7005 {$ENDIF}
7006                                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7007                                 GikoSys.FAbon.AddIndividualAbon(StrToInt(body[i]), Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7008                         end;
7009                 finally
7010                         wordCount.Free;
7011                         ReadList.Free;
7012                 end;
7013                 FActiveContent.Repaint := true;
7014                 if ThreadItem <> nil then
7015                         InsertBrowserTab( ThreadItem, True );
7016         finally
7017                 body.Free;
7018         end;
7019
7020 end;
7021
7022 procedure TGikoForm.KokoPopupMenuPopup(Sender: TObject);
7023 var
7024         firstElement: IHTMLElement;
7025         document: IHTMLDocument2;
7026 begin
7027         document := FActiveContent.Browser.Document as IHTMLDocument2;
7028         if Assigned(document) then
7029                 firstElement := document.all.item('idSearch', 0) as IHTMLElement;
7030                 if Assigned(firstElement) then
7031                         if firstElement.style.visibility <> 'hidden' then
7032                                 firstElement.style.visibility := 'hidden';
7033
7034 end;
7035
7036 procedure TGikoForm.RepaintAllTabsBrowser();
7037 var
7038         i : Integer;
7039         ThreadItem: TThreadItem;
7040 begin
7041         for i := BrowserTab.Tabs.Count - 1 downto 0 do
7042                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
7043
7044         ThreadItem := GetActiveContent;
7045         if ThreadItem <> nil then
7046                 InsertBrowserTab( ThreadItem, True );
7047
7048 end;
7049
7050 //ListView\82Ì\91I\91ð\8fó\91Ô\82ð\89ð\8f\9c\82·\82é
7051 procedure TGikoForm.ListViewKeyUp(Sender: TObject; var Key: Word;
7052   Shift: TShiftState);
7053 begin
7054         //\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Ì
7055         //\96³\8cø\8e\9e\8aÔ\82ÌTimer\82Ì\8f\88\97\9d
7056         //\82Æ\82è\82 \82¦\82¸\81A\83^\83C\83}\81[\82ð\92â\8e~\82·\82é\81B
7057         SelectTimer.Interval := 0;
7058         if not (GikoSys.Setting.BrowserTabVisible) then begin
7059                 if (GetActiveList is TBoard) then begin
7060                         //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
7061                         if not ((ssShift in Shift) or (ssAlt in Shift) or (ssCtrl in Shift))  and
7062                                 (( Key = VK_LEFT) or (Key = VK_RIGHT) or
7063                                                 (Key = VK_UP) or (Key = VK_DOWN)) then
7064                                         SelectTimer.Interval := GikoSys.Setting.SelectInterval;
7065                 end;
7066         end;
7067 end;
7068 // *************************************************************************
7069 //! \82¨\8bC\82É\93ü\82è\82Ì\95Ò\8fW\8aJ\8en\83C\83x\83\93\83g
7070 // *************************************************************************
7071 procedure TGikoForm.FavoriteTreeViewEditing(Sender: TObject;
7072   Node: TTreeNode; var AllowEdit: Boolean);
7073 begin
7074         //\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ\82ð\88ê\8e\9e\95Û\91\82·\82é
7075         FOrigenCaption := Node.Text;
7076 end;
7077 // *************************************************************************
7078 //! Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
7079 // *************************************************************************
7080 function TGikoForm.GetMainForm(): TComponent;
7081 begin
7082         Result := Application.MainForm;
7083 end;
7084 // *************************************************************************
7085 //! \8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
7086 // *************************************************************************
7087 function TGikoForm.GetScreenCursor(): TCursor;
7088 begin
7089         Result := Screen.Cursor;
7090 end;
7091 // *************************************************************************
7092 //! \83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
7093 // *************************************************************************
7094 procedure TGikoForm.SetScreenCursor(Cursor : TCursor);
7095 begin
7096         if (Screen.Cursor <> Cursor) then
7097                 Screen.Cursor := Cursor;
7098 end;
7099 // *************************************************************************
7100 //! \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
7101 // *************************************************************************
7102 procedure TGikoForm.CabinetCloseSpeedButtonClick(Sender: TObject);
7103 begin
7104         //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Ì
7105         //\8cÄ\82Ñ\8fo\82µ\82É\82µ\82½\81@by \82à\82\82ã
7106         if GikoDM.CabinetVisibleAction.Enabled then begin
7107                 GikoDM.CabinetVisibleAction.Execute;
7108         end;
7109 end;
7110 // *************************************************************************
7111 //! \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
7112 // *************************************************************************
7113 procedure TGikoForm.FavoriteArrangeToolButtonClick(Sender: TObject);
7114 begin
7115         if GikoDM.FavoriteArrangeAction.Enabled then begin
7116                 GikoDM.FavoriteArrangeAction.Execute;
7117         end;
7118 end;
7119 // *************************************************************************
7120 //! \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
7121 // *************************************************************************
7122 procedure TGikoForm.GikoApplicationEventsMessage(var Msg: tagMSG;
7123   var Handled: Boolean);
7124 var
7125         wmMsg: TWMKey;
7126 begin
7127         //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ß
7128         if Self.Active then begin
7129                 case Msg.message of
7130                         //\83L\81[\93ü\97Í\82·\82×\82Ä
7131                         WM_KEYFIRST..WM_KEYLAST :
7132                         begin
7133                                 //\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ç
7134                                 if (Msg.message <> WM_KEYUP)
7135                     and (Msg.message <> WM_CHAR)
7136                     and (Msg.message <> WM_SYSKEYUP) then begin
7137                                         wmMsg.Msg := Msg.message;
7138                                         wmMsg.CharCode := Word(Msg.wParam);
7139                                         wmMsg.KeyData := Msg.lParam;
7140                                         //\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\82Ì\8f\88\97\9d\82É\93]\91\97
7141                                         Self.OnShortCut(wmMsg, Handled);
7142                                 end;
7143                         end;
7144                 end;
7145         end;
7146 end;
7147 // *************************************************************************
7148 //! \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
7149 // *************************************************************************
7150 procedure TGikoForm.GikoApplicationEventsDeactivate(Sender: TObject);
7151 begin
7152         Application.ProcessMessages;
7153         if not Application.Terminated then begin
7154                 if PreviewTimer.Enabled then
7155                         PreviewTimer.Enabled := False;
7156                 //\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
7157                 if FHint <> nil then begin
7158                         FHint.ReleaseHandle;
7159                         FHint.ClearAllRes;
7160                 end;
7161                 //\83v\83\8c\83r\83\85\81[\82ð\89B\82·
7162                 if FPreviewBrowser <> nil then
7163                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
7164         end;
7165
7166 end;
7167 // *************************************************************************
7168 //! \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
7169 // *************************************************************************
7170 procedure TGikoForm.GikoApplicationEventsException(Sender: TObject;
7171   E: Exception);
7172 var
7173         s : String;
7174 begin
7175         if (Sender <> nil) then begin
7176                 s := ' [' + Sender.ClassName + ']' + #13#10;
7177         end else begin
7178                 s := ' [ Sender is nil ] ' + #13#10;
7179         end;
7180         s := s + E.Message;
7181         MsgBox(Handle, s, '\8f\88\97\9d\82³\82ê\82È\82©\82Á\82½\97á\8aO', MB_OK or MB_ICONSTOP);
7182 end;
7183 // *************************************************************************
7184 //! \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¬
7185 // *************************************************************************
7186 procedure TGikoForm.CreateControlThread();
7187 begin
7188         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
7189         FControlThread := TThreadControl.Create(True);
7190         FControlThread.MaxThreadCount := 1;
7191         FControlThread.Resume;
7192         FControlThread.OnDownloadEnd := DownloadEnd;
7193         FControlThread.OnDownloadMsg := DownloadMsg;
7194         FControlThread.OnWork := Work;
7195         FControlThread.OnWorkBegin := WorkBegin;
7196         FControlThread.OnWorkEnd := WorkEnd;
7197 end;
7198 // *************************************************************************
7199 //! \83u\83\89\83E\83U\82Ì\90\90¬
7200 // *************************************************************************
7201 procedure TGikoForm.CreateBrowsers(count: Integer);
7202 var
7203         i: Integer;
7204         newBrowser: TWebBrowser;
7205 begin
7206         BrowserNullTab := TBrowserRecord.Create;
7207         BrowserNullTab.Browser := Browser;
7208         BrowserNullTab.Browser.Navigate(BLANK_HTML);
7209         FBrowsers := TList.Create;
7210         for i := 0 to count -1 do begin
7211                 FBrowsers.Add(TWebBrowser.Create(BrowserPanel));
7212                 newBrowser := FBrowsers[FBrowsers.Count - 1];
7213                 TOleControl(newBrowser).Parent := BrowserPanel;
7214                 TOleControl(newBrowser).Align := alNone;
7215                 TOleControl(newBrowser).Left    := 0;
7216                 TOleControl(newBrowser).Top     := 0;
7217                 newBrowser.RegisterAsDropTarget := False;
7218                 newBrowser.OnDocumentComplete   := BrowserDocumentComplete;
7219                 newBrowser.OnBeforeNavigate2    := BrowserBeforeNavigate2;
7220                 newBrowser.OnEnter                              := BrowserEnter;
7221                 newBrowser.OnNewWindow2                 := BrowserNewWindow2;
7222                 newBrowser.OnStatusTextChange   := BrowserStatusTextChange;
7223                 newBrowser.Navigate(BLANK_HTML);
7224                 ShowWindow(newBrowser.Handle, SW_HIDE);
7225         end;
7226         BrowserNullTab.Browser.BringToFront;
7227         ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
7228         //\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Ì
7229         //\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Å
7230         //\82±\82±\82Å\8fI\82í\82ç\82¹\82Ä\82¨\82­
7231         while (Browser.ReadyState <> READYSTATE_COMPLETE) and
7232                 (Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
7233                 Application.ProcessMessages;
7234         end;
7235 end;
7236 // *************************************************************************
7237 //! \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é
7238 // *************************************************************************
7239 procedure TGikoForm.SetSelectComboBox();
7240 const
7241         DUMMYCOMPNAME = 'SelectComboBoxDummy';
7242 var
7243         i: Integer;
7244         ToolButton: TToolButton;
7245 begin
7246         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
7247         SelectComboBoxPanel.Visible := False;
7248         try
7249                 for i := ListToolBar.ControlCount - 1 downto 0 do
7250                 begin
7251                         if ListToolBar.Controls[ i ].Action = GikoDM.SelectItemAction then
7252                         begin
7253                                 SelectComboBoxPanel.Left := ListToolBar.Controls[ i ].Left;
7254                                 SelectComboBoxPanel.Width := GikoSys.Setting.SelectComboBoxWidth;
7255                                 SelectComboBoxPanel.Parent := ListToolBar;
7256                                 SelectComboBoxPanel.Visible := True;
7257
7258                                 SelectComboBox.Left := 0;
7259                                 SelectComboBox.Top  := 0;
7260                                 SelectComboBox.Height := SelectComboBoxPanel.ClientHeight;
7261                                 SelectComboBox.Width := SelectComboBoxPanel.Width -
7262                                                                                 SelectComboBoxSplitter.Width;
7263
7264                                 //\88ê\82Â\8c©\82¦\82È\82¢\83{\83^\83\93\82ð\93Ë\82Á\8d\9e\82Þ
7265                                 ToolButton := TToolButton(ListToolBar.FindComponent(DUMMYCOMPNAME));
7266                                 if ToolButton = nil then begin
7267                                         ToolButton := TToolButton.Create(ListToolBar);
7268                                         ToolButton.Name := DUMMYCOMPNAME;
7269                                 end;
7270                                 ToolButton.Style := tbsSeparator;
7271                                 ToolButton.Width := 0;
7272                                 ToolButton.Left  := ListToolBar.Controls[ i ].Left;
7273                                 ListToolBar.InsertControl(ToolButton);
7274                                 ToolButton.Visible := False;
7275
7276                                 // \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·
7277                                 if (i + 1) < ListToolBar.ControlCount then
7278                                         if ListToolBar.Controls[ i + 1 ] is TToolButton then
7279                                                 if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
7280                                                         ListToolBar.Controls[ i + 1 ].Visible := False;
7281
7282
7283                                 // \83X\83\8c\83b\83h\8di\8d\9e\83{\83^\83\93\82ð\89B\82·
7284                                 ListToolBar.Controls[ i ].Visible := False;
7285
7286                                 break;
7287                         end;
7288                 end;
7289         except
7290         end;
7291 end;
7292 //! \83L\83\83\83r\83l\83b\83g\82Ì\83}\83E\83X\83_\83E\83\93\83C\83x\83\93\83g
7293 procedure TGikoForm.TreeViewMouseDown(Sender: TObject;
7294   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
7295 var
7296         rect : TRect;
7297 begin
7298         case Button of
7299         mbLeft:
7300                 begin
7301                         if (TreeView.Selected <> nil) and
7302                                 (TreeView.Selected = TreeView.GetNodeAt(X, Y)) then begin
7303                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
7304                                 rect := TreeView.Selected.DisplayRect(true);
7305                                 // \83A\83C\83R\83\93\95ª\82¾\82¯\8d\82É\82¸\82ç\82·
7306                                 if ((rect.Left - TreeView.Indent <= X) and (rect.Right >= X)) and
7307                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
7308                                         // \83N\83\8a\83b\83N\82Æ\83_\83u\83\8b\83N\83\8a\83b\83N\82ð\83R\83R\82Å\94»\92è
7309                                         if ssDouble in Shift then begin
7310                                                 TreeDoubleClick( TreeView.Selected );
7311                                         end else begin
7312                                                 TreeClick(TreeView.Selected);
7313                                         end;
7314                                 end;
7315                         end;
7316                 end;
7317         end;
7318 end;
7319 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
7320 procedure TGikoForm.GetGroupIndex(ActionList: TActionList);
7321 var
7322         i: Integer;
7323 begin
7324         if ActionList <> nil then begin
7325                 SetLength(FActionListGroupIndexes, ActionList.ActionCount);
7326
7327                 for i := 0 to ActionList.ActionCount - 1 do begin
7328                         try
7329                                 FActionListGroupIndexes[i] :=
7330                                         TCustomAction(ActionList.Actions[i]).GroupIndex;
7331                                 TCustomAction(ActionList.Actions[i]).GroupIndex
7332                                         := 0;
7333                         except
7334                                 ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7335                         end;
7336                 end;
7337
7338         end;
7339 end;
7340 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
7341 procedure TGikoForm.SetGroupIndex(ActionList: TActionList);
7342 var
7343         i: Integer;
7344 begin
7345         if ActionList <> nil then begin
7346                 if Length( FActionListGroupIndexes ) = ActionList.ActionCount then begin
7347                         for i := 0 to ActionList.ActionCount - 1 do begin
7348                                 try
7349                                         TCustomAction(ActionList.Actions[i]).GroupIndex
7350                                                 := FActionListGroupIndexes[i];
7351                                 except
7352                                         ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7353                                 end;
7354                         end;
7355                 end;
7356         end;
7357 end;
7358 //! \82±\82Ì\83\8c\83X\82ÌURL\8eæ\93¾
7359 procedure TGikoForm.GetResURLMenuClick(Sender: TObject);
7360 begin
7361 ;
7362 end;
7363 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
7364 procedure TGikoForm.RefreshListView(Thread: TThreadItem);
7365 begin
7366         //Thread\82Ì\94Â\82Æ\95\\8e¦\82µ\82Ä\82¢\82é\94Â\82ª\93¯\82\82È\82ç\95`\89æ\82ð\8dX\90V\82·\82é
7367         if (FActiveList is TBoard) and (TBoard(ActiveList) = Thread.ParentBoard) then begin
7368                 ListView.Refresh;
7369         end;
7370 end;
7371
7372 procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
7373   MousePos: TPoint; var Handled: Boolean);
7374 var
7375     pos : TPoint;
7376     coolBar: TGikoCoolBar;
7377 begin
7378     Handled := False;
7379     if (Sender <> nil) and (Sender is TGikoCoolBar) then begin
7380         coolBar := TGikoCoolBar(Sender);
7381         if (coolBar = MainCoolBar) then begin
7382             FToolBarSettingSender := tssMain;
7383         end else if (coolBar = ListCoolBar) then begin
7384             FToolBarSettingSender := tssList;
7385         end else if (coolBar = BrowserCoolBar) then begin
7386             FToolBarSettingSender := tssBrowser;
7387         end else begin
7388             FToolBarSettingSender := tssNone;
7389         end;
7390         pos := coolBar.ClientToScreen( MousePos );
7391         MainCoolBarPopupMenu.Popup( pos.X, pos.Y );
7392         Handled := True;
7393     end;
7394 end;
7395
7396 procedure TGikoForm.TaskTrayIconMessage(var Msg: TMsg);
7397 begin
7398     //  \8d\83N\83\8a\83b\83N\82È\82ç\95\9c\8c³\82·\82é
7399     if  (Msg.wParam = WM_LBUTTONUP) then  begin
7400         UnStoredTaskTray;
7401     end;
7402 end;
7403 //! \83^\83X\83N\83g\83\8c\83C\82É\83A\83C\83R\83\93\93o\98^\81\95\83t\83H\81[\83\80\89B\82µ
7404 procedure TGikoForm.StoredTaskTray;
7405 begin
7406     try
7407         if (FIconData.uID = 0) then begin
7408             FIconData.cbSize  :=  SizeOf(TNotifyIconData);
7409             FIconData.uID     :=  Self.Handle;
7410             FIconData.Wnd     :=  Handle;
7411             FIconData.uFlags  :=  NIF_MESSAGE or NIF_ICON or NIF_TIP;
7412             FIconData.uCallbackMessage  :=  USER_TASKTRAY;
7413             FIconData.hIcon   :=  Application.Icon.Handle;  {\83A\83C\83R\83\93\8ew\92è}
7414             FIconData.szTip   :=  '\83M\83R\83i\83r';      {\83q\83\93\83g\95\8e\9a\97ñ}
7415             Shell_NotifyIcon(NIM_ADD, @FIconData);
7416             ShowEditors(SW_HIDE);
7417             ShowWindow(Self.Handle, SW_HIDE);
7418         end;
7419     except
7420     end;
7421 end;
7422 //! \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¦
7423 procedure TGikoForm.UnStoredTaskTray;
7424 begin
7425     try
7426         try
7427             Shell_NotifyIcon(NIM_DELETE, @FIconData);
7428             SetForegroundWindow(Application.Handle);
7429         except
7430         end;
7431     finally
7432         FIconData.uID := 0;
7433         // Action\82©\82ç\8ai\94[\82µ\82½\82Æ\82«\82ÍTag\82Ì\92l\82Í0\88È\8aO
7434         if (GikoDM.StoredTaskTrayAction.Tag = 0) then begin
7435             ShowWindow(Self.Handle, SW_RESTORE);
7436         end else begin
7437             ShowWindow(Self.Handle, SW_SHOW);
7438         end;
7439         ShowEditors(SW_SHOW);
7440         GikoDM.StoredTaskTrayAction.Tag := 0;
7441     end;
7442 end;
7443 {
7444 \brief \83\8c\83X\83G\83f\83B\83^\82Ì\95\\8e¦\94ñ\95\\8e¦
7445 \param nCmdShow Windows.ShowWindow\82É\91\97\82é\83p\83\89\83\81\81[\83^\82Æ\93¯\82
7446 }
7447 procedure TGikoForm.ShowEditors(nCmdShow: Integer);
7448 var
7449     i : Integer;
7450 begin
7451     // \83\8c\83X\83G\83f\83B\83^\82ð\92T\82·
7452     for i := 0 to Screen.CustomFormCount - 1 do begin
7453         if TObject(Screen.CustomForms[i]) is TEditorForm then
7454             ShowWindow(Screen.CustomForms[i].Handle, nCmdShow);
7455
7456     end;
7457 end;
7458
7459 initialization
7460                                 OleInitialize(nil);
7461 finalization
7462                                 OleUninitialize;
7463
7464 end.