OSDN Git Service

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