OSDN Git Service

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