OSDN Git Service

キャビネットに履歴を表示しているとログを削除しても、キャビネットに残りつづけて
[gikonavigoeson/gikonavi.git] / Giko.pas
1 unit Giko;
2
3 interface
4
5 uses
6         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7         OleCtrls,       ComCtrls, ExtCtrls, Menus, StdCtrls, MMSystem, DateUtils,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10         MSHTML,
11 {$ELSE}
12         SHDocVw_TLB,
13         MSHTML_TLB,
14 {$IFEND}
15         IdHTTP, ActiveX, ActnList, ImgList,
16         ToolWin, Buttons, IdComponent, UrlMon, Tabs, IdGlobal, StrUtils,
17         CommCtrl, Dialogs, GikoSystem, Setting, BoardGroup, ThreadControl, ItemDownload,
18         Editor, RoundData, GikoPanel, Favorite, HTMLDocumentEvent,
19         HintWindow, GikoCoolBar, GikoListView, Search, ExternalBoardManager,
20         ExternalBoardPlugInMain, StdActns, Variants, ExtActns,IdTCPConnection,
21         IdBaseComponent, IdTCPClient, AppEvnts, BrowserRecord;
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                 function GetTabURLs(AStringList: TStringList) : Boolean;
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
760                 procedure DeleteTab(ThreadItem: TThreadItem); overload;
761                 procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
762                 //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
763                 procedure BrowserMovement(const AName: string);
764                 //Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
765                 function GetMainForm(): TComponent;
766                 procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
767                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\8en
768                 procedure OnGestureStart(Sender: TObject);
769                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\92\86
770                 procedure OnGestureMove(Sender: TObject);
771                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8fI\97¹
772                 procedure OnGestureEnd(Sender: TObject);
773                 /// \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
774                 procedure ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
775                 //\83X\83N\83\8a\81[\83\93\8fã\82ÉEditorForm\82ª\82¢\82é\82©
776                 function EditorFormExists(): boolean;
777                 //\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é
778                 procedure AllEditroFormNameTextClearClear();
779                 //\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é
780                 procedure AllEditroFormMailTextClearClear();
781                 //ListView\82Å\91I\91ð\82³\82ê\82Ä\82¢\82é\83A\83C\83e\83\80\82ð\8eæ\93¾\82·\82é
782                 procedure SelectListItem(List: TList);
783                 /// \83^\83u\95Û\91
784                 function SaveTabURLs : Boolean;
785                 /// \83^\83u\93Ç\82Ý\8fo\82µ
786                 function LoadTabURLs : Boolean;
787                 //\8ew\92è\82µ\82½\83\8c\83X\82ð\83R\83s\81[\82·\82é
788                 procedure KonoresCopy(Number: Integer; ReplaceTag : Boolean);
789                 //
790                 procedure ModifySelectList;
791                 //
792                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string); overload;
793                 //
794                 procedure SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string); overload;
795                 //
796                 procedure SetSelectRoundName(Sender: TObject);
797                 //
798                 function GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
799                 //
800                 function WebBrowserClick(Sender: TObject): WordBool;
801                 //! \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é
802                 procedure SetSelectComboBox();
803
804         published
805                 property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
806         end;
807
808         TFavoriteMenuItem = class(TMenuItem)
809         private
810                 FData : Pointer;
811         public
812                 property Data: Pointer read FData write FData;
813         end;
814
815         TBBSMenuItem = class(TMenuItem)
816         private
817                 FData : Pointer;
818         public
819                 property Data: Pointer read FData write FData;
820         end;
821
822         TLinkToolButton = class(TToolButton)
823         private
824                 FData : Pointer;
825         public
826                 property Data: Pointer read FData write FData;
827         end;
828
829 var
830         GikoForm: TGikoForm;
831
832 implementation
833
834 uses
835         GikoUtil, IndividualAbon, Math, Kotehan, KeySetting,
836         YofUtils, ShellAPI, ToolBarUtil, ToolBarSetting,
837         GikoXMLDoc, RoundName, IniFiles, FavoriteAdd,
838         FavoriteArrange, AddressHistory, Preview, Gesture,
839         About, Option, Round, Splash, Sort, ListSelect, Imm,
840         NewBoard, MojuUtils, Clipbrd, GikoBayesian,Y_TextConverter,
841         HTMLCreate, ListViewUtils, GikoDataModule, GikoMessage,
842   InputAssistDataModule;
843
844 const
845         BLANK_HTML: string = 'about:blank';
846         BROWSER_COUNT           = 5;    //\83u\83\89\83E\83U\82Ì\90\94
847         //D&D臒l
848         DandD_THRESHOLD = 5;    //D&D\82Ìè\87\92l\81ipixcel)
849         //\83v\83\8c\83r\83\85\81[\83t\83@\83C\83\8b\96¼
850         HTML_FILE_NAME  = 'temp_preview.html';
851         ITEM_ICON_THREADLOG1            = 6;            //\83X\83\8c\83A\83C\83R\83\93\81i\83\8d\83O\82 \82è\81j
852         ITEM_ICON_THREADLOG2            = 7;            //\83X\83\8c\83A\83C\83R\83\93\81i\83\8d\83O\82 \82è\81j
853         //\83\81\83b\83Z\81[\83WID
854         USER_TREECLICK                                  = WM_USER + 2000;
855         USER_RESIZED            = WM_USER + 2001;
856         USER_MINIMIZED                                  = WM_USER + 2002;
857         USER_SETLINKBAR                                 = WM_USER + 2003;
858         USER_DOCUMENTCOMPLETE           = WM_USER + 2004;       ///< wParam : TWebBrowser
859 {$R *.DFM}
860
861 procedure TGikoForm.CreateParams(var Params: TCreateParams);
862 begin
863         inherited;
864         if FormStyle in [fsNormal, fsStayOnTop] then begin
865                 if BorderStyle in [bsSingle, bsSizeable] then begin
866                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
867                         Params.WndParent := 0;
868                 end;
869         end;
870 end;
871
872 procedure TGikoForm.FormCreate(Sender: TObject);
873 const
874         TVS_NOTOOLTIPS = $0080;
875 var
876         FileName: string;
877         Style: DWORD;
878         msg: string;
879         i: Integer;
880         wp: TWindowPlacement;
881 begin
882 {$IFDEF DEBUG}
883         AllocConsole;
884         Writeln('============================================================');
885         Writeln(' \83M\83R\83i\83r\83f\83o\83b\83\83R\83\93\83\\81[\83\8b');
886         Writeln('');
887         Writeln(' \82±\82Ì\89æ\96Ê\82ð\95Â\82\82È\82¢\82Å\82­\82¾\82³\82¢\81B');
888         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¢');
889         Writeln('============================================================');
890 {$ENDIF}
891 //try
892         Sort.SetSortDate(Now());
893         
894         FTreeType := gttNone;
895         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô
896         FStartUp := true;
897         Application.HookMainWindow(Hook);
898         FIsIgnoreResize := rtResizing;
899         //ActionList\82ÌGuoupIndex\82ð\95Û\91\82µ\82Ä\81A0\82É\83N\83\8a\83A\82·\82é\81B
900         //(\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¢)
901         //\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
902         GetGroupIndex(GikoDM.GikoFormActionList);
903         FSearchDialog := nil;
904         CreateBrowsers(BROWSER_COUNT);
905
906         //\83\81\83j\83\85\81[\83t\83H\83\93\83g
907         SetMenuFont;
908
909         //\8eè\82Ì\83J\81[\83\\83\8b
910         Screen.Cursors[5] := LoadCursor(HInstance, 'GIKOHAND');
911
912         //\83A\83h\83\8c\83X\97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
913         AddressHistoryDM.ReadHistory(AddressComboBox.Items, GikoSys.Setting.MaxRecordCount);
914
915         EnabledCloseButton := True;
916
917         //\83\8a\83X\83g\83X\83^\83C\83\8b
918         ListView.ViewStyle := GikoSys.Setting.ListStyle;
919
920         //\83A\83j\83\81\83p\83l\83\8b\88Ê\92u
921         AnimePanel.Top := 0;
922         AnimePanel.Left := 0;
923
924         //\8ae\8eí\89Â\8e\8b\8fó\91Ô\82È\82Ç\90Ý\92è
925
926         //\83L\83\83\83r\83l\83b\83g
927         CabinetPanel.Width := GikoSys.Setting.CabinetWidth;
928
929         //\83\81\83b\83Z\81[\83W\83o\81[
930         GikoDM.MsgBarVisibleAction.Checked := GikoSys.Setting.MessageBarVisible;
931         GikoDM.MsgBarVisibleActionExecute(nil);
932         MessagePanel.Height := GikoSys.Setting.MessegeBarHeight;
933
934         //\83X\83e\81[\83^\83X\83o\81[
935         GikoDM.StatusBarVisibleAction.Checked := GikoSys.Setting.StatusBarVisible;
936         GikoDM.StatusBarVisibleActionExecute(nil);
937
938         //\83t\83H\83\93\83g\81E\90F\90Ý\92è
939         TreeView.Items.BeginUpdate;
940         FavoriteTreeView.Items.BeginUpdate;
941         ListView.Items.BeginUpdate;
942         try
943                 TreeView.Font.Name := GikoSys.Setting.CabinetFontName;
944                 TreeView.Font.Size := GikoSys.Setting.CabinetFontSize;
945                 TreeView.Font.Color := GikoSys.Setting.CabinetFontColor;
946                 TreeView.Color := GikoSys.Setting.CabinetBackColor;
947                 FavoriteTreeView.Font.Assign(TreeView.Font);
948                 FavoriteTreeView.Color := GikoSys.Setting.CabinetBackColor;
949
950                 ListView.Font.Name := GikoSys.Setting.ListFontName;
951                 ListView.Font.Size := GikoSys.Setting.ListFontSize;
952                 ListView.Font.Color := GikoSys.Setting.ListFontColor;
953                 ListView.Font.Style := [];
954                 if GikoSys.Setting.ListFontBold then
955                         ListView.Font.Style := [fsbold];
956                 if GikoSys.Setting.ListFontItalic then
957                         ListView.Font.Style := ListView.Font.Style + [fsitalic];
958
959                 ListViewBackGroundColor := clWhite;                                                                                             // \83f\83t\83H\83\8b\83g\82É\90Ý\92è\82µ\82½\82Ì\82¿
960                 ListViewBackGroundColor := GikoSys.Setting.ListBackColor;       // \83\86\81[\83U\92è\8b`\82É\95Ï\8dX
961                 FUseOddResOddColor := GikoSys.Setting.UseOddColorOddResNum;
962                 FOddColor := GikoSys.Setting.OddColor;
963
964         finally
965                 TreeView.Items.EndUpdate;
966                 FavoriteTreeView.Items.EndUpdate;
967                 ListView.Items.EndUpdate;
968         end;
969         //ViewNoButton.Down := GikoSys.Setting.ListViewNo;
970         GikoDM.ListNumberVisibleAction.Checked := GikoSys.Setting.ListViewNo;
971
972         //\83~\83\85\81[\83g\82Ì\8fó\91Ô\82ð\90Ý\92è
973         GikoDM.MuteAction.Checked := GikoSys.Setting.Mute;
974
975         // \83\8c\83X\95\\8e¦\94Í\88Í
976         FResRangeMenuSelect := GikoSys.ResRange;
977         case GikoSys.ResRange of
978         Ord( grrAll ):
979                 begin
980                         GikoDM.AllResAction.Execute;
981                 end;
982         Ord( grrSelect ):
983                 begin
984                         SelectComboBox.Text := SelectComboBox.Items[ 1 ];
985                         GikoDM.SelectResAction.Checked := True;
986                 end;
987         else
988                 case FResRangeMenuSelect of
989                 Ord( grrKoko ): GikoDM.OnlyKokoResAction.Checked        := True;
990                 Ord( grrNew ):  GikoDM.OnlyNewResAction.Checked := True;
991                 100:                    GikoDM.OnlyAHundredResAction.Checked            := True;
992                 end;
993         end;
994
995         // \83X\83\8c\83b\83h\88ê\97\97\95\\8e¦\94Í\88Í
996         case GikoSys.Setting.ThreadRange of
997         gtrAll:
998                 begin
999                         GikoDM.AllItemAction.Checked := True;
1000                         ViewType := gvtAll;
1001                 end;
1002         gtrLog:
1003                 begin
1004                         GikoDM.LogItemAction.Checked := True;
1005                         ViewType := gvtLog;
1006                 end;
1007         gtrNew:
1008                 begin
1009                         GikoDM.NewItemAction.Checked := True;
1010                         ViewType := gvtNew;
1011                 end;
1012         gtrLive:
1013                 begin
1014                         GikoDM.LiveItemAction.Checked := True;
1015                         ViewType := gvtLive;
1016                 end;
1017         gtrArch:
1018                 begin
1019                         GikoDM.ArchiveItemAction.Checked := True;
1020                         ViewType := gvtArch;
1021                 end;
1022         end;
1023
1024
1025         //\83u\83\89\83E\83U\83^\83u\83t\83H\83\93\83g
1026         BrowserTab.Font.Name := GikoSys.Setting.BrowserTabFontName;
1027         BrowserTab.Font.Size := GikoSys.Setting.BrowserTabFontSize;
1028         BrowserTab.Font.Style := [];
1029         if GikoSys.Setting.BrowserTabFontBold then
1030                 BrowserTab.Font.Style := [fsBold];
1031         if GikoSys.Setting.BrowserTabFontItalic then
1032                 BrowserTab.Font.Style := GikoForm.BrowserTab.Font.Style + [fsItalic];
1033         BrowserTab.DoubleBuffered := True;
1034         FDragWFirst := false;
1035         SetContent(BrowserNullTab);                                                                                                     //\83u\83\89\83E\83U\82ð\8bó\94\92\95\\8e¦
1036
1037         //\83u\83\89\83E\83U\83^\83u
1038         GikoDM.BrowserTabVisibleAction.Checked := GikoSys.Setting.BrowserTabVisible;
1039
1040         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
1041                 GikoDM.BrowserTabTopAction.Checked := True;
1042         end else begin
1043                 GikoDM.BrowserTabBottomAction.Checked := True;
1044         end;
1045
1046         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
1047                 GikoDM.BrowserTabTabStyleAction.Checked := True;
1048         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
1049                 GikoDM.BrowserTabButtonStyleAction.Checked := True;
1050         end else begin
1051                 GikoDM.BrowserTabFlatStyleAction.Checked := True;
1052         end;
1053
1054         //\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\8f\89\8aú\89»
1055         ProgressBar.Parent := StatusBar;
1056         ProgressBar.Top := 2;
1057         ProgressBar.Left := 0;
1058         ProgressBar.Width := StatusBar.Panels[0].Width;
1059         ProgressBar.Height := StatusBar.Height - 2;
1060         ProgressBar.Position := 0;
1061
1062         // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\83\8d\81[\83h(ReadBoardFile, LoadHistory \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1063         InitializeBoardPlugIns;
1064
1065         // \83{\81[\83h\83t\83@\83C\83\8b\97ñ\8b\93(ReadFavorite \82æ\82è\90æ\82É\8ds\82¤\82±\82Æ)
1066         GikoSys.ListBoardFile;
1067         //\81@\98A\91±\8bN\93®\8e\9e\82É\83X\83v\83\89\83b\83V\83\85\83E\83B\83\93\83h\83E\82Ì\83\81\83\82\83\8a\82ª\95s\92è\82É
1068         try
1069         // \83X\83v\83\89\83b\83V\83\85\83E\83B\83\93\83h\83E\82Ì\83v\83\8d\83O\83\8c\83X\83o\81[\82Ì\90Ý\92è
1070                 if (SplashWindow <> nil) then begin
1071                         SplashWindow.ProgressBar.Max := Length(BBSs) * 20;
1072                 end;
1073         except
1074         end;
1075         // \82·\82×\82Ä\82ÌBBS\82ð\93Ç\82Ý\8d\9e\82ñ\82Å\82¨\82­
1076         for i := Length(BBSs) - 1 downto 0 do begin
1077                 if not BBSs[i].IsBoardFileRead then
1078                         GikoSys.ReadBoardFile(BBSs[i]);
1079
1080                 if SplashWindow <> nil then begin
1081                         SplashWindow.ProgressBar.StepBy(20);
1082                         SplashWindow.Update;
1083                 end;
1084         end;
1085
1086         //\8f\84\89ñ\83f\81[\83^\93Ç\82Ý\8d\9e\82Ý
1087         RoundList := TRoundList.Create;
1088         RoundList.LoadRoundBoardFile;
1089         RoundList.LoadRoundThreadFile;
1090
1091         //TreeView\82Ì\8e×\96\82\8fL\82¢ToolTip\82ð\94ñ\95\\8e¦
1092         Style := GetWindowLong(TreeView.Handle, GWL_STYLE);
1093         Style := Style or TVS_NOTOOLTIPS;
1094         SetWindowLong(TreeView.Handle, GWL_STYLE, Style);
1095
1096         // \83c\83\8a\81[\82ð\83\81\83C\83\93\82¾\82¯\95\\8e¦\82É\82µ\82Ä\8dÅ\91å\89»
1097         TreeView.Align := alClient;
1098         FavoriteTreeView.Align := alClient;
1099         FavoriteTreeView.Visible := False;
1100
1101         // \83\81\83j\83\85\81[\82É\92Ç\89Á
1102         SetBBSMenu;
1103
1104         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95\9c\8c³
1105         wp.length := sizeof(wp);
1106         wp.rcNormalPosition.Top := GikoSys.Setting.WindowTop;
1107         wp.rcNormalPosition.Left := GikoSys.Setting.WindowLeft;
1108         wp.rcNormalPosition.Bottom := GikoSys.Setting.WindowTop + GikoSys.Setting.WindowHeight;
1109         wp.rcNormalPosition.Right := GikoSys.Setting.WindowLeft + GikoSys.Setting.WindowWidth;
1110         wp.showCmd := SW_HIDE;
1111         SetWindowPlacement(Handle, @wp);
1112         //Self.Update;
1113
1114         if GikoSys.Setting.WindowMax then
1115                 WindowState := wsMaximized;
1116
1117         //\83M\83R\83A\83j\83\81
1118         try
1119                 FileName := GikoSys.GetAppDir + 'gikoNavi.avi';
1120                 if FileExists(FileName) then
1121                         Animate.FileName := FileName;
1122         except
1123         end;
1124
1125         //\83N\83b\83L\81[
1126         FNameCookie := '';
1127         FMailCookie := '';
1128
1129         //\83u\83\89\83E\83U\83T\83C\83Y\95Ï\8dX\82Ì\8f\89\8aú\89»
1130         FBrowserSizeHeight := GikoSys.Setting.ListHeight;
1131         FBrowserSizeWidth := GikoSys.Setting.ListWidth;
1132
1133
1134         // \83q\83X\83g\83\8a\83\8a\83X\83g(LoadHistory \82æ\82è\82à\90æ\82É\8ds\82¤\82±\82Æ)
1135         FHistoryList := TList.Create;
1136
1137         // \97\9a\97ð\93Ç\82Ý\8d\9e\82Ý
1138         LoadHistory;
1139
1140         //\82¨\8bC\82É\93ü\82è\93Ç\82Ý\8d\9e\82Ý
1141         FavoriteDM.SetFavTreeView(FavoriteTreeView);
1142         FavoriteDM.ReadFavorite;
1143
1144         GikoDM.ArrangeAction.Checked := not (GikoSys.Setting.ListOrientation = gloVertical);
1145         GikoDM.ArrangeAction.Execute;
1146
1147         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
1148                 case GikoSys.Setting.ListWidthState of
1149                         glsMax: begin
1150                                 ViewPanel.Width := 1;
1151                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1152                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1153                         end;
1154                         glsMin: begin
1155                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1156                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1157                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
1158                         end;
1159                         else begin
1160                                 ViewPanel.Width := GikoSys.Setting.ListWidth;
1161                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
1162                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
1163                         end;
1164                 end;
1165         end else begin
1166                 case GikoSys.Setting.ListHeightState of
1167                         glsMax: begin
1168                                 ViewPanel.Height := 1;
1169                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1170                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1171                         end;
1172                         glsMin: begin
1173                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1174                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1175                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
1176                         end;
1177                         else begin
1178                                 ViewPanel.Height := GikoSys.Setting.ListHeight;
1179                                 GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
1180                                 GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
1181                         end;
1182                 end;
1183         end;
1184
1185         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
1186         CreateControlThread();
1187
1188         // \8di\8d\9e\8c\9f\8dõ\97\9a\97ð
1189         SelectComboBox.Items.Assign( GikoSys.Setting.SelectTextList );
1190
1191         //\83u\83\89\83E\83U\83^\83u\90Ý\92è
1192         SetBrowserTabState;
1193
1194         BrowserBoardNameLabel.Caption := '';
1195         BrowserNameLabel.Caption := '';
1196         FWorkCount := 0;
1197
1198         FTabHintIndex := -1;
1199
1200         //\83c\81[\83\8b\83o\81[Wrapable
1201         ListToolBar.Wrapable := GikoSys.Setting.ListToolBarWrapable;
1202         BrowserToolBar.Wrapable := GikoSys.Setting.BrowserToolBarWrapable;
1203
1204         MakeDefaultINIFile();
1205         //\83c\81[\83\8b\83{\83^\83\93\93Ç\82Ý\8d\9e\82Ý
1206         ReadToolBarSetting(GikoDM.GikoFormActionList, StdToolBar);
1207         ReadToolBarSetting(GikoDM.GikoFormActionList, ListToolBar);
1208         ReadToolBarSetting(GikoDM.GikoFormActionList, BrowserToolBar);
1209         SetToolBarPopup;
1210
1211         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
1212         SetSelectComboBox();
1213
1214         //\83A\83h\83\8c\83X\83o\81[
1215         AddressComboBox.TabStop := GikoSys.Setting.AddressBarTabStop;
1216
1217         //\83\8a\83\93\83N\83o\81[
1218         SetLinkBar;
1219         //\83N\81[\83\8b\83o\81[\95\9c\8c³\82ÍFormShow\82É\88Ú\93®\82µ\82½
1220
1221         //\83{\81[\83h\83t\83@\83C\83\8b\82ª\96³\82¢\8fê\8d\87\82Í\83\81\83b\83Z\81[\83W\95\\8e¦
1222         if not FileExists(GikoSys.GetBoardFileName) then begin
1223                 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
1224                                  + '\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
1225                                  + '\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';
1226                 MsgBox(SplashWindow.Handle, msg, '\83M\83R\83i\83r', MB_OK or MB_ICONINFORMATION);
1227                 GikoDM.NewBoardAction.Execute;
1228         end;
1229
1230         //\83L\81[\90Ý\92è\93Ç\82Ý\8d\9e\82Ý
1231         GikoSys.LoadKeySetting(GikoDM.GikoFormActionList, GikoSys.GetMainKeyFileName);
1232
1233         //\8dÅ\8fI\8f\84\89ñ\8e\9e\8aÔ
1234 //      FLastRoundTime := 0;
1235
1236         //ResHint
1237         FHint := TResPopup.Create(Self);
1238
1239         ListView.OnData := TListViewUtils.ListViewData;
1240
1241         // \8dÅ\8cã\82É\91I\91ð\82³\82ê\82½\83L\83\83\83r\83l\83b\83g\82Ì\95\9c\8c³
1242         CabinetVisible( False );
1243         if GikoSys.Setting.CabinetVisible then begin
1244                 i := CabinetSelectPopupMenu.Items.Count - 1;
1245                 if GikoSys.Setting.CabinetIndex = i - 1 then
1246                         GikoDM.CabinetHistoryAction.Execute
1247                 else if GikoSys.Setting.CabinetIndex = i then
1248                         GikoDM.CabinetFavoriteAction.Execute
1249                 else begin
1250                         if GikoSys.Setting.CabinetIndex < Length( BBSs ) then
1251                                 ShowBBSTree( BBSs[ GikoSys.Setting.CabinetIndex ] );
1252                         // \8bN\93®\8e\9e\82É\95Û\91\82³\82ê\82Ä\82µ\82Ü\82¤\91Î\8dô 2
1253                         FIsIgnoreResize := rtResizing;
1254                         GikoDM.CabinetBBSAction.Execute;
1255                 end;
1256         end else begin
1257                 ShowBBSTreeOld( BBSs[ 0 ] );
1258                 PostMessage( Handle, USER_TREECLICK, 0, 0 );
1259         end;
1260
1261         //\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
1262         for i := 1 to ParamCount do     begin
1263                 MoveToURL(ParamStr(i));
1264         end;
1265
1266         GikoDM.RepaintStatusBar;
1267         StatusBarResize(Sender);
1268
1269         dummy1.Caption  := ItemReservPMenu.Caption;
1270         dummy1.Hint     := ItemReservPMenu.Hint;
1271
1272         //Samba24\82Ì\83t\83@\83C\83\8b\83`\83F\83b\83N
1273         GikoSys.SambaFileExists();
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, j, idx: Integer;
3678         doc: Variant;
3679 begin
3680         idx := BrowserTab.TabIndex;
3681         FTabHintIndex := -1;
3682         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3683                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]) = BrowserRecord then begin
3684                         try
3685                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
3686                                         doc := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser.Document;
3687                                         TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := doc.Body.ScrollTop;
3688                                 end;
3689                         except
3690                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := 0;
3691                         end;
3692                         if( FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[i]) ) then
3693                                 FActiveContent := nil;
3694                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
3695                                 j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser);
3696                                 if j <> -1 then
3697                                         FBrowsers.Move(j, BROWSER_COUNT - 1);
3698                         end;
3699                         BrowserTab.Tabs.BeginUpdate;
3700                         try
3701                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
3702                                 if ( BrowserTab.Tabs.Count - 1 = i ) and
3703                                         ( BrowserTab.TabRect(i).Left
3704                                                 <= BrowserTab.DisplayRect.Left ) then begin
3705                                         BrowserTab.ScrollTabs(-1);
3706                                 end;
3707                                 BrowserTab.Tabs.Delete(i);
3708                                 if idx > i then begin
3709                                         BrowserTab.TabIndex := idx - 1;
3710                                 end else begin
3711                                         if BrowserTab.Tabs.Count -1 >= idx then
3712                                                 BrowserTab.TabIndex := idx
3713                                         else
3714                                                 BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
3715                                 end;
3716                         finally
3717                                 BrowserTab.Tabs.EndUpdate;
3718                         end;
3719                         if BrowserTab.Tabs.Count = 0 then begin
3720                                 BrowserNullTab.Thread := nil;
3721                         end;
3722                         if(BrowserTab.TabIndex <> -1) and
3723                                 ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
3724                                 for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
3725                                         if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
3726                                                  = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
3727                                         begin
3728                                                 ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
3729                                                 break;
3730                                         end;
3731                                 end;
3732                                 TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
3733                                          :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3734                                 TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
3735                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
3736                         end;
3737                         if( FActiveContent = nil) then
3738                                 BrowserTab.OnChange(nil);
3739                         Exit;
3740                 end;
3741         end;
3742 end;
3743 procedure TGikoForm.DeleteTab(ThreadItem: TThreadItem);
3744 var
3745         i, j, idx: Integer;
3746         doc: Variant;
3747 begin
3748         idx := BrowserTab.TabIndex;
3749         FTabHintIndex := -1;
3750         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3751                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread = ThreadItem then begin
3752                         try
3753                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
3754                                         doc := TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser.Document;
3755                                         TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := doc.Body.ScrollTop;
3756
3757                                 end;
3758                         except
3759                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.ScrollTop := 0;
3760                         end;
3761                         if(FActiveContent = TBrowserRecord(BrowserTab.Tabs.Objects[i])) then
3762                                 FActiveContent := nil;
3763                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser <> nil then begin
3764                                 j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser);
3765                                 if j <> -1 then
3766                                         FBrowsers.Move(j, BROWSER_COUNT - 1);
3767                         end;
3768                         BrowserTab.Tabs.BeginUpdate;
3769                         try
3770                                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Free;
3771                                 if ( BrowserTab.Tabs.Count - 1 = i ) and
3772                                         ( BrowserTab.TabRect(i).Left
3773                                                 <= BrowserTab.DisplayRect.Left ) then begin
3774                                         BrowserTab.ScrollTabs(-1);
3775                                 end;
3776                                 BrowserTab.Tabs.Delete(i);
3777                                 if idx > i then begin
3778                                         BrowserTab.TabIndex := idx - 1;
3779                                 end else begin
3780                                         if BrowserTab.Tabs.Count -1 >= idx then
3781                                                 BrowserTab.TabIndex := idx
3782                                         else
3783                                                 BrowserTab.TabIndex := BrowserTab.Tabs.Count - 1;
3784                                 end;
3785                         finally
3786                                 BrowserTab.Tabs.EndUpdate;
3787                         end;
3788                         if(BrowserTab.TabIndex <> -1) and
3789                                 ( TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser = nil) then begin
3790                                 for j := BrowserTab.Tabs.Count - 1 downto 0 do begin
3791                                         if(TBrowserRecord(BrowserTab.Tabs.Objects[j]).Browser
3792                                                  = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) )then
3793                                         begin
3794                                                 ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[j]));
3795                                                 break;
3796                                         end;
3797                                 end;
3798                                 TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Browser
3799                                          :=  TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3800                                 TBrowserRecord(BrowserTab.Tabs.Objects[BrowserTab.TabIndex]).Repaint := true;
3801                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
3802                         end;
3803
3804                         if( FActiveContent = nil) then
3805                                 BrowserTab.OnChange(nil);
3806                         Exit;
3807                 end;
3808         end;
3809 end;
3810 function TGikoForm.Hook(var Message: TMessage): Boolean;
3811 begin
3812         //\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Ì
3813         //\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ð
3814         Result := False;
3815         case Message.Msg of
3816         CM_APPKEYDOWN:
3817                 Result := True;         //\83V\83\87\81[\83g\83J\83b\83g\83L\81[\96³\8cø
3818         CM_APPSYSCOMMAND:
3819                 Result := True;  // \83A\83N\83Z\83\89\83\8c\81[\83^\82ð\96³\8cø\82É\82·\82é
3820         end;
3821 end;
3822
3823 procedure TGikoForm.ListPopupMenuPopup(Sender: TObject);
3824 begin
3825         ItemRoundPMenu.Visible := (GetActiveList is TBoard);
3826         ItemReservPMenu.Visible := (GetActiveList is TBoard);
3827         LPMSep01.Visible := (GetActiveList is TBoard);
3828         ListRoundPMenu.Visible := (GetActiveList is TCategory);// or (GetActiveList is TBoard);
3829         ListReservPMenu.Visible := (GetActiveList is TCategory);// or (GetActiveList is TBoard);
3830         LPMSep02.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
3831         KidokuPMenu.Visible := (GetActiveList is TBoard);
3832         MidokuPMenu.Visible := (GetActiveList is TBoard);
3833         UrlCopyPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
3834         NameUrlCopyPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
3835         AllSelectPMenu.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
3836         LPMSep05.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
3837         DeletePMenu.Visible := (GetActiveList is TBoard);
3838         LPMSep06.Visible := (GetActiveList is TCategory) or (GetActiveList is TBoard);
3839         BoardFavoriteAddMenu.Visible := (GetActiveList is TCategory);
3840         ThreadFavoriteAddMenu.Visible := (GetActiveList is TBoard);
3841
3842         AddRoundNameMenu(ItemReservPMenu);
3843         AddRoundNameMenu(ListReservPMenu);
3844 end;
3845
3846 procedure TGikoForm.TreePopupMenuPopup(Sender: TObject);
3847 begin
3848         FClickNode := TreeView.Selected;
3849         if FClickNode = nil then begin
3850                 TreeSelectThreadPupupMenu.Visible := False;
3851                 TreeSelectBoardPupupMenu.Visible := False;
3852                 TPMSep01.Visible := False;
3853                 TreeSelectURLPupupMenu.Visible := False;
3854                 TreeSelectNamePupupMenu.Visible := False;
3855                 TreeSelectNameURLPupupMenu.Visible := False;
3856                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3857                 TreeSelectLogDeleteSeparator.Visible := False;
3858                 TreeSelectLogDeletePopupMenu.Visible := False;
3859         end else if TObject(FClickNode.Data) is TBoard then begin
3860                 TreeSelectThreadPupupMenu.Visible := False;
3861                 TreeSelectBoardPupupMenu.Visible := True;
3862                 TPMSep01.Visible := True;
3863                 TreeSelectURLPupupMenu.Visible := True;
3864                 TreeSelectNamePupupMenu.Visible := True;
3865                 TreeSelectNameURLPupupMenu.Visible := True;
3866                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3867                 TreeSelectLogDeleteSeparator.Visible := False;
3868                 TreeSelectLogDeletePopupMenu.Visible := False;
3869         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
3870                 TreeSelectThreadPupupMenu.Visible := False;
3871                 TreeSelectBoardPupupMenu.Visible := True;
3872                 TPMSep01.Visible := True;
3873                 TreeSelectURLPupupMenu.Visible := True;
3874                 TreeSelectNamePupupMenu.Visible := True;
3875                 TreeSelectNameURLPupupMenu.Visible := True;
3876                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3877                 TreeSelectLogDeleteSeparator.Visible := False;
3878                 TreeSelectLogDeletePopupMenu.Visible := False;
3879         end else if (TObject(FClickNode.Data) is TThreadItem) then begin
3880                 TreeSelectThreadPupupMenu.Visible := True;
3881                 TreeSelectBoardPupupMenu.Visible := False;
3882                 TPMSep01.Visible := True;
3883                 TreeSelectURLPupupMenu.Visible := True;
3884                 TreeSelectNamePupupMenu.Visible := True;
3885                 TreeSelectNameURLPupupMenu.Visible := True;
3886                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3887                 TreeSelectLogDeleteSeparator.Visible := True;
3888                 TreeSelectLogDeletePopupMenu.Visible := True;
3889         end else if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
3890                 TreeSelectThreadPupupMenu.Visible := True;
3891                 TreeSelectBoardPupupMenu.Visible := False;
3892                 TPMSep01.Visible := True;
3893                 TreeSelectURLPupupMenu.Visible := True;
3894                 TreeSelectNamePupupMenu.Visible := True;
3895                 TreeSelectNameURLPupupMenu.Visible := True;
3896                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3897                 TreeSelectLogDeleteSeparator.Visible := True;
3898                 TreeSelectLogDeletePopupMenu.Visible := True;
3899         end else if (TObject(FClickNode.Data) is TCategory) then begin
3900                 TreeSelectThreadPupupMenu.Visible := False;
3901                 TreeSelectBoardPupupMenu.Visible := False;
3902                 TPMSep01.Visible := False;
3903                 TreeSelectURLPupupMenu.Visible := False;
3904                 TreeSelectNamePupupMenu.Visible := True;
3905                 TreeSelectNameURLPupupMenu.Visible := False;
3906                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3907                 TreeSelectLogDeleteSeparator.Visible := False;
3908                 TreeSelectLogDeletePopupMenu.Visible := False;
3909         end else if FClickNode.IsFirstNode then begin
3910                 TreeSelectThreadPupupMenu.Visible := False;
3911                 TreeSelectBoardPupupMenu.Visible := False;
3912                 TPMSep01.Visible := False;
3913                 TreeSelectURLPupupMenu.Visible := False;
3914                 TreeSelectNamePupupMenu.Visible := True;
3915                 TreeSelectNameURLPupupMenu.Visible := False;
3916                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3917                 TreeSelectLogDeleteSeparator.Visible := False;
3918                 TreeSelectLogDeletePopupMenu.Visible := False;
3919         end else begin
3920                 TreeSelectThreadPupupMenu.Visible := False;
3921                 TreeSelectBoardPupupMenu.Visible := False;
3922                 TPMSep01.Visible := False;
3923                 TreeSelectURLPupupMenu.Visible := False;
3924                 TreeSelectNamePupupMenu.Visible := False;
3925                 TreeSelectNameURLPupupMenu.Visible := False;
3926                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3927                 TreeSelectLogDeleteSeparator.Visible := False;
3928                 TreeSelectLogDeletePopupMenu.Visible := False;
3929         end;
3930 end;
3931
3932 procedure TGikoForm.BrowserNewWindow2(Sender: TObject;
3933         var ppDisp: IDispatch; var Cancel: WordBool);
3934 var
3935         Text: string;
3936         Html: string;
3937         URL: string;
3938         idx: Integer;
3939         wkIntSt: Integer;
3940         wkIntTo: Integer;
3941     BNum, BRes: string;
3942     threadItem: TThreadItem;
3943 begin
3944
3945         Cancel := True;
3946         if (IHTMLDocument2(TWebBrowser(Sender).Document).activeElement <> nil) then begin
3947                 Text := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerText;
3948                 Html := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerHTML;
3949                 if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
3950                         or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
3951                         if GikoSys.Setting.ResAnchorJamp then begin
3952                                 Text := ZenToHan(Trim(Text));
3953
3954                                 if(AnsiPos('>>', Text) = 1) then begin
3955                                         //Text := Copy(Text, 3, Length(Text) - 2);
3956                                         Delete(Text, 1, 2);
3957                                 end else begin
3958                                         //Text := Copy(Text, 2, Length(Text) - 1);
3959                                         Delete(Text, 1, 1);
3960                                 end;
3961
3962                                 if AnsiPos('-', Text) <> 0 then begin
3963                                         wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
3964                                         Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
3965                                         wkIntTo := StrToIntDef(Text, 0);
3966                                         if wkIntTo < wkIntSt then
3967                                                 wkIntSt := wkIntTo;
3968                                 end else begin
3969                                         wkIntSt := StrToIntDef(Text, 0);
3970                                 end;
3971
3972                                 if wkIntSt <> 0 then begin
3973                                         FActiveContent.IDAnchorPopup('');
3974                                         BrowserMovement(IntToStr(wkIntSt));
3975                                 end;
3976
3977
3978                         end;
3979                 end else begin
3980             ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
3981
3982                         URL := GikoSys.GetHRefText(Html);
3983                         URL := GikoSys.HTMLDecode(URL);
3984             if AnsiPos('BE:', URL) = 1 then begin
3985                                 BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
3986                                 BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
3987                 threadItem := FActiveContent.Thread;
3988                 if threadItem = nil then Exit;
3989                 URL := BE_PHP_URL + BNum + '&u=d'
3990                         + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
3991             end;
3992
3993                         if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
3994                                 ( AnsiPos('ftp://', URL) = 1) then begin
3995                                 //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
3996                                 if GikoSys.Setting.LinkAddAddressBar then begin
3997                                         idx := AddressComboBox.Items.IndexOf(URL);
3998                                         if idx = -1 then begin
3999                                                 AddressComboBox.Items.Insert(0, URL);
4000                                                 if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
4001                                                         AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
4002                                         end else begin
4003                                                 AddressComboBox.Items.Delete(idx);
4004                                                 AddressComboBox.Items.Insert(0, URL);
4005                                         end;
4006                                 end;
4007                                 MoveToURL( URL );
4008                         end;
4009                 end;
4010         end;
4011
4012 end;
4013
4014 procedure TGikoForm.ListSplitterMoved(Sender: TObject);
4015 begin
4016         if Mouse.Capture <> 0 then
4017                 Exit;
4018         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
4019                 if (ViewPanel.Width > 1) and (ViewPanel.Width <= (ThreadMainPanel.Width - 80)) then
4020                         FBrowserSizeWidth := ViewPanel.Width;
4021         end else begin
4022                 if (ViewPanel.Height > 1) and (ViewPanel.Height <= (ThreadMainPanel.Height - BrowserCoolBar.Height)) then
4023                         FBrowserSizeHeight := ViewPanel.Height;
4024         end;
4025         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
4026                 if ViewPanel.Width < 2 then begin
4027                         ViewPanel.Width := 1;
4028                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
4029                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
4030                         GikoSys.Setting.ListWidthState := glsMax;
4031                 end else if ViewPanel.Width > (ThreadMainPanel.Width - 80) then begin
4032                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
4033                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
4034                         GikoSys.Setting.ListWidthState := glsMin;
4035                 end else begin
4036                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
4037                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
4038                         GikoSys.Setting.ListWidthState := glsNormal;
4039                 end;
4040         end else begin
4041                 if ViewPanel.Height < 2 then begin
4042                         ViewPanel.Height := 1;
4043                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
4044                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
4045                         GikoSys.Setting.ListHeightState := glsMax;
4046                 end else if ViewPanel.Height > (ThreadMainPanel.Height - BrowserCoolBar.Height - 7) then begin
4047                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
4048                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
4049                         GikoSys.Setting.ListHeightState := glsMin;
4050                 end else begin
4051                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
4052                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
4053                         GikoSys.Setting.ListHeightState := glsNormal;
4054                 end;
4055         end;
4056 {       if (Mouse.Capture = 0) and (ViewPanel.Height > 1) and (not ArrangeAction.Checked) then
4057                 FBrowserSizeHeight := ViewPanel.Height
4058         else if (Mouse.Capture = 0) and (ViewPanel.Width > 1) and (ArrangeAction.Checked) then
4059                 FBrowserSizeWidth := ViewPanel.Width;}
4060 end;
4061
4062 procedure TGikoForm.BrowserTabChange(Sender: TObject);
4063 var
4064         i, j: Integer;
4065         idx: Integer;
4066 begin
4067         BrowserTab.Tabs.BeginUpdate;
4068         try
4069                 if not BrowserTab.Dragging then begin
4070                         FTabHintIndex := -1;
4071                         BrowserTab.Hint := '';
4072                         idx := BrowserTab.TabIndex;
4073                         if idx = -1 then begin
4074                                 SetContent(BrowserNullTab);
4075
4076                         end else if(BrowserTab.Tabs.Objects[idx] <> nil) and (BrowserTab.Tabs.Objects[idx] is TBrowserRecord) then begin
4077                                 if TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser <> nil then begin
4078                                         j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser);
4079                                         if j <> -1 then
4080                                                 FBrowsers.Move(j ,0);
4081                                 end else begin
4082                                         if( FActiveContent <> nil ) and (FActiveContent.Browser <> nil) and
4083                                                 (FActiveContent.Browser <> BrowserNullTab.Browser) and
4084                                                 (FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
4085                                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
4086
4087                                         for i := 0 to BrowserTab.Tabs.Count - 1 do begin
4088                                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
4089                                                         ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
4090                                                         break;
4091                                                 end;
4092                                         end;
4093                                         TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
4094                                         TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Repaint := true;
4095                                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
4096                                 end;
4097                                 MoveWindow(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser.Handle, 0, 0, BrowserPanel.Width, BrowserPanel.Height, false);
4098                                 TOleControl(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser).BringToFront;
4099                                 SetContent(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
4100
4101                                 if (GikoSys.Setting.URLDisplay) and (GetActiveContent <> nil) then
4102                                         AddressComboBox.Text := GetActiveContent.URL;
4103
4104                                 if ((TreeView.Visible) and (TreeView.Focused)) or ((FavoriteTreeView.Visible) and (FavoriteTreeView.Focused)) or
4105                                         (ListView.Focused) or (SelectComboBox.Focused) or (AddressComboBox.Focused)
4106                                 then
4107                                 else
4108                                         GikoDM.SetFocusForBrowserAction.Execute;
4109                         end;
4110                 end;
4111         finally
4112                 BrowserTab.Tabs.EndUpdate;
4113         end;
4114 end;
4115
4116
4117 procedure TGikoForm.BrowserTabMouseDown(Sender: TObject;
4118         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
4119 var
4120         p: TPoint;
4121         p2: TPoint;
4122         idx: Integer;
4123 begin
4124         if Button = mbMiddle then begin
4125                 // \83}\83E\83X\92\86\83{\83^\83\93
4126                 GetCursorPos(p);
4127                 p2 := p;
4128                 p := BrowserTab.ScreenToClient(p);
4129                 idx := BrowserTab.IndexOfTabAt(p.X, p.Y);
4130                 if idx <> -1 then
4131                         DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
4132         end else if Button = mbLeft then begin
4133                 FDragWFirst := true;
4134                 FMouseDownPos.X := X;
4135                 FMouseDownPos.Y := Y;
4136         end;
4137
4138 end;
4139
4140 procedure TGikoForm.SetBrowserTabState;
4141 var
4142         CoolBand: TCoolBand;
4143 begin
4144         BrowserBottomPanel.AutoSize := False;
4145         if GikoSys.Setting.BrowserTabVisible then begin
4146                 BrowserTab.Hide;
4147                 BrowserTab.Tabs.BeginUpdate;
4148                 try
4149                         if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
4150                                 BrowserTab.Style := tsTabs;
4151                                 if GikoSys.Setting.BrowserTabPosition = gtpTop then
4152                                         BrowserTab.TabPosition := tpTop
4153                                 else
4154                                         BrowserTab.TabPosition := tpBottom;
4155                         end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
4156                                 BrowserTab.TabPosition := tpTop;
4157                                 BrowserTab.Style := tsButtons;
4158                         end else begin
4159                                 BrowserTab.TabPosition := tpTop;
4160                                 BrowserTab.Style := tsFlatButtons
4161                         end;
4162
4163                         if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
4164                                 BrowserTab.Parent := BrowserTabToolBar;
4165                                 BrowserBottomPanel.Hide;
4166                                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4167                                 if CoolBand <> nil then
4168                                         CoolBand.Visible := True;
4169                         end else begin
4170                                 BrowserTab.Parent := BrowserBottomPanel;
4171                                 BrowserTab.Top := 0;
4172                                 BrowserTab.Left := 0;
4173                                 BrowserBottomPanel.Show;
4174                                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4175                                 if CoolBand <> nil then
4176                                         CoolBand.Visible := False;
4177                         end;
4178                 finally
4179                         BrowserTab.Tabs.EndUpdate;
4180                         BrowserTab.Show;
4181                 end;
4182         end else begin
4183                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4184                 if CoolBand <> nil then
4185                         CoolBand.Visible := False;
4186                 BrowserBottomPanel.Visible := False;
4187                 GikoDM.AllTabCloseAction.Execute;
4188         end;
4189 end;
4190
4191 procedure TGikoForm.BrowserTabDragOver(Sender, Source: TObject; X,
4192         Y: Integer; State: TDragState; var Accept: Boolean);
4193 var
4194         idx: Integer;
4195 begin
4196         idx := BrowserTab.IndexOfTabAt(X, Y);
4197         Accept := (Source = BrowserTab) and (BrowserTab.TabIndex <> idx);
4198 end;
4199
4200 procedure TGikoForm.BrowserTabDragDrop(Sender, Source: TObject; X,
4201         Y: Integer);
4202 var
4203         idx: Integer;
4204 begin
4205         idx := BrowserTab.IndexOfTabAt(X, Y);
4206         if idx <> -1 then
4207                 BrowserTab.Tabs.Move(BrowserTab.TabIndex, idx);
4208 end;
4209
4210 procedure TGikoForm.BrowserTabMouseMove(Sender: TObject;
4211         Shift: TShiftState; X, Y: Integer);
4212 var
4213         TabIdx: Integer;
4214         ThreadItem: TThreadItem;
4215 begin
4216
4217         TabIdx := BrowserTab.IndexOfTabAt(x, y);
4218
4219         if ( ssLeft in Shift ) and ( BrowserTab.Style = tsTabs ) then begin
4220                 if FDragWFirst = false then begin
4221                         FDragWFirst := true;
4222                 end else begin
4223                         BrowserTab.EndDrag(false);
4224                         BrowserTab.BeginDrag(false, DandD_THRESHOLD);
4225                         FDragWFirst := false;
4226                 end;
4227         end else begin
4228                 BrowserTab.EndDrag(false);
4229                 FDragWFirst := false;
4230         end;
4231         
4232         if (FTabHintIndex <> TabIdx) and (TabIdx <> -1) then begin
4233                 Application.CancelHint;
4234                 ThreadItem := TBrowserRecord(BrowserTab.Tabs.Objects[TabIdx]).Thread;
4235                 if ThreadItem.Title <> BrowserTab.Tabs[TabIdx] then begin
4236                         BrowserTab.Hint := ThreadItem.Title;
4237                         Application.ShowHint := True;
4238                 end else begin
4239                         BrowserTab.Hint := '';
4240                         Application.ShowHint := True;
4241                 end;
4242                 FTabHintIndex := TabIdx;
4243         end;
4244
4245 end;
4246
4247 procedure TGikoForm.BrowserDocumentComplete(Sender: TObject;
4248         const pDisp: IDispatch; var URL: OleVariant);
4249 var
4250         FDispHtmlDocument: DispHTMLDocument;
4251         BrowserRecord :TBrowserRecord;
4252         i :Integer;
4253         doc                                     : Variant;
4254         threadItem      : TThreadItem;
4255 begin
4256         if TObject(Sender) is TWebBrowser then begin
4257                 BrowserRecord := nil;
4258                 if TWebBrowser(Sender) <> Browser then begin
4259                         for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
4260                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(Sender) then begin
4261                                                 BrowserRecord := TBrowserRecord(BrowserTab.Tabs.Objects[i]);
4262                                                 break;
4263                                 end;
4264                         end;
4265                         if BrowserRecord <> nil then begin
4266                                 if BrowserRecord.Event <> nil then
4267                                         BrowserRecord.Event.Free;
4268                                 FDispHtmlDocument := Idispatch(OleVariant(BrowserRecord.Browser.ControlInterface).Document) as DispHTMLDocument;
4269                                 BrowserRecord.Event := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4270                                 BrowserRecord.Event.OnContextMenu := OnDocumentContextMenu;
4271                                 BrowserRecord.Event.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4272                         end;
4273                 end else begin
4274                         if GetActiveContent <> nil then begin
4275                                 FDispHtmlDocument := Idispatch(OleVariant(Browser.ControlInterface).Document) as DispHTMLDocument;
4276                                 if FEvent <> nil then
4277                                         FEvent.Free;
4278                                 FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4279                                 FEvent.OnContextMenu := OnDocumentContextMenu;
4280                                 FEvent.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4281                         end else begin
4282                                 if FEvent <> nil then begin
4283                                         FEvent.Free;
4284                                         FEvent := nil;
4285                                 end;
4286                         end;
4287
4288                 end;
4289
4290                 if (BrowserRecord <> nil) and
4291                          Assigned( BrowserRecord.Thread ) then begin
4292                         threadItem := BrowserRecord.Thread;
4293
4294                         if (threadItem.JumpAddress > 0) then begin
4295                                 if threadItem.UnRead then begin
4296                                         threadItem.UnRead := False;
4297                                         TreeView.Refresh;
4298                                         RefreshListView(threadItem);
4299                                 end;
4300                                 // \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®
4301                                 //if (StrToIntDef(BrowserRecord.Movement, 0) <= BrowserRecord.Thread.Count) then begin
4302                                 if (threadItem.JumpAddress <= BrowserRecord.Thread.Count) then begin
4303                                         BrowserRecord.Move(IntToStr(threadItem.JumpAddress));
4304                                         threadItem.JumpAddress := 0;
4305                                 end else begin
4306                                         BrowserRecord.Move(IntToStr(BrowserRecord.Thread.Count));
4307                                 end;
4308
4309                         end else if threadItem.UnRead then begin
4310                                 threadItem.UnRead := False;
4311                                 TreeView.Refresh;
4312                                 BrowserRecord.Move('new');
4313                                 RefreshListView(threadItem);
4314                         end else if threadItem.ScrollTop <> 0 then begin
4315                                 try
4316                                         doc := Idispatch( OleVariant( BrowserRecord.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4317                                         doc.Body.ScrollTop := threadItem.ScrollTop;
4318                                 except
4319                                         on E: Exception do
4320                                                 MsgBox(Handle, E.Message, 'SetContent[ScrollTop<-]', 0);
4321                                 end;
4322                         end;
4323                 end;
4324         end;
4325         LockWindowUpdate(0);
4326 end;
4327
4328 procedure TGikoForm.RoundNamePopupMenuPopup(Sender: TObject);
4329 begin
4330         AddRoundNameMenu(RoundNamePopupMenu.Items);
4331 end;
4332
4333 procedure TGikoForm.AddRoundNameMenu(MenuItem: TMenuItem);
4334 var
4335         i: Integer;
4336         Item: TMenuItem;
4337 begin
4338         MenuItem.Clear;
4339         Item := TMenuItem.Create(Self);
4340         Item.Caption := '\90V\82µ\82¢\96¼\91O\82Å\8f\84\89ñ\97\\96ñ(&N)...';
4341         Item.OnClick := GikoDM.SelectNewRoundNameExecute;
4342         MenuItem.Add(Item);
4343         Item := TMenuItem.Create(Self);
4344         Item.Caption := '\8f\84\89ñ\83\8a\83X\83g\82©\82ç\8dí\8f\9c(&D)';
4345         Item.OnClick := GikoDM.SelectDeleteRoundExecute;
4346         MenuItem.Add(Item);
4347         Item := TMenuItem.Create(Self);
4348         Item.Caption := '-';
4349         MenuItem.Add(Item);
4350         for i := 0 to RoundList.RoundNameList.Count - 1 do begin
4351                 Item := TMenuItem.Create(Self);
4352                 Item.Caption := RoundList.RoundNameList[i];
4353                 Item.OnClick := SetSelectRoundName;
4354                 MenuItem.Add(Item);
4355         end;
4356 end;
4357
4358 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string);
4359 var
4360         threadItem : TThreadItem;
4361 begin
4362         if ParentName <> 'dummy1' then begin
4363                 SetSelectItemRound(RoundFlag, RoundName);
4364         end else begin
4365                 threadItem := GetActiveContent;
4366                 if threadItem <> nil then begin
4367                         threadItem.RoundName := RoundName;
4368                         if RoundFlag then
4369                                 RoundList.RoundNameList.Add(RoundName);
4370                         threadItem.Round := RoundFlag;
4371                 end;
4372         end;
4373 end;
4374
4375 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string);
4376 var
4377         i{, idx}: Integer;
4378         List: TList;
4379 begin
4380         List := TList.Create;
4381         try
4382                 SelectListItem(List);
4383                 for i := 0 to List.Count - 1 do begin
4384                         if TObject(List[i]) is TBoard then begin
4385                                 TBoard(List[i]).RoundName := RoundName;
4386                                 if RoundFlag then
4387                                         RoundList.RoundNameList.Add(RoundName);
4388                                 TBoard(List[i]).Round := RoundFlag;
4389                         end else if TObject(List[i]) is TThreadItem then begin
4390                                 if TThreadItem(List[i]).IsLogFile then begin
4391                                         TThreadItem(List[i]).RoundName := RoundName;
4392                                         if RoundFlag then
4393                                                 RoundList.RoundNameList.Add(RoundName);
4394                                         TThreadItem(List[i]).Round := RoundFlag;
4395                                 end;
4396                         end;
4397                 end;
4398         finally
4399                 List.Free;
4400         end;
4401 end;
4402
4403 procedure TGikoForm.SetSelectRoundName(Sender: TObject);
4404 var
4405         MenuItem: TMenuItem;
4406 begin
4407         if Sender is TMenuItem then begin
4408                 MenuItem := TMenuItem(Sender);
4409                 SetSelectItemRound(True, StripHotKey(MenuItem.Caption), TMenuItem(Sender).Parent.Name);
4410                 ListView.Refresh;
4411         end;
4412 end;
4413
4414 function TGikoForm.GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
4415 var
4416         i: Integer;
4417 begin
4418         Result := nil;
4419         if CoolBar = nil then
4420                 Exit;
4421         for i := 0 to CoolBar.Bands.Count - 1 do begin
4422                 if CoolBar.Bands[i].Control = Control then begin
4423                         Result := CoolBar.Bands[i];
4424                         Exit;
4425                 end;
4426         end;
4427 end;
4428
4429 procedure TGikoForm.BrowserTabToolBarResize(Sender: TObject);
4430 begin
4431         if BrowserTab.Parent = BrowserTabToolBar then
4432                 BrowserTab.Width := BrowserTabToolBar.Width;
4433 end;
4434
4435 procedure TGikoForm.WMSettingChange(var Message: TWMWinIniChange);
4436 begin
4437         SetMenuFont;
4438 end;
4439
4440 procedure TGikoForm.SetMenuFont;
4441 begin
4442 //      GikoSys.MenuFont(MenuToolBar.Font);
4443 //      MenuToolBar.Buttons[0].AutoSize := False;
4444 //      MenuToolBar.Buttons[0].AutoSize := True;
4445 //      MenuToolBar.Font.Color := clMenuText;
4446         GikoSys.MenuFont(MainCoolBar.Font);
4447         MenuToolBar.Buttons[0].AutoSize := False;
4448         MenuToolBar.Buttons[0].AutoSize := True;
4449         MainCoolBar.AutoSize := False;
4450         MainCoolBar.AutoSize := True;
4451
4452         GikoSys.MenuFont(ListCoolBar.Font);
4453         GikoSys.MenuFont(BrowserCoolBar.Font);
4454 //      MenuToolBar.Font.Color := clMenuText;
4455 end;
4456
4457 procedure TGikoForm.FavoriteMenuClick(Sender: TObject);
4458 var
4459         NewMenu: TMenuItem;
4460 begin
4461         if FavoriteDM.Modified then begin
4462                 FavoriteMenu.Clear;
4463
4464                 //\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á
4465                 NewMenu := TMenuItem.Create(MainMenu);
4466                 NewMenu.Action := GikoDM.FavoriteAddAction;
4467                 FavoriteMenu.Add(NewMenu);
4468                 //\82¨\8bC\82É\93ü\82è\82Ì\90®\97\9d
4469                 NewMenu := TMenuItem.Create(FavoriteMenu);
4470                 NewMenu.Action := GikoDM.FavoriteArrangeAction;
4471                 FavoriteMenu.Add(NewMenu);
4472                 //\83Z\83p\83\8c\81[\83^
4473                 FavoriteMenu.InsertNewLineAfter(NewMenu);
4474                 CreateFavMenu(FavoriteDM.TreeView.Items.GetFirstNode, FavoriteMenu);
4475                 FavoriteDM.Modified := false;
4476         end;
4477 end;
4478
4479 procedure TGikoForm.CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
4480 var
4481         i: Integer;
4482         NewMenu: array of TMenuItem;
4483 begin
4484         SetLength(NewMenu, Node.Count);
4485         Node := Node.getFirstChild;
4486         i := 0;
4487         while ( Node <> nil ) do begin
4488                 NewMenu[i] := TFavoriteMenuItem.Create(nil);
4489                 NewMenu[i].AutoHotkeys := maAutomatic;
4490                 NewMenu[i].Caption := CustomStringReplace(Node.Text, '&', '&&');
4491                 TFavoriteMenuItem(NewMenu[i]).Data := Node.Data;
4492
4493                 if TObject(Node.Data) is TFavoriteFolder then begin
4494                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
4495                         CreateFavMenu(Node, NewMenu[i]);
4496                 end else if TObject(Node.Data) is TFavoriteBoardItem then begin
4497                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
4498                         NewMenu[i].OnClick := FavoriteClick;
4499                 end else if TObject(Node.Data) is TFavoriteThreadItem then begin
4500                         NewMenu[i].ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
4501                         NewMenu[i].OnClick := FavoriteClick;
4502                 end;
4503         Inc(i);
4504                 Node := Node.getNextSibling;
4505         end;
4506         MenuItem.Add(NewMenu);
4507 end;
4508
4509 procedure TGikoForm.ShowFavoriteAddDialog( Item : TObject );
4510 var
4511         Dlg                     : TFavoriteAddDialog;
4512         ItemURL : string;
4513         Data            : Pointer;
4514         Node            : TTreeNode;
4515 begin
4516
4517         if Item is TFavoriteBoardItem then
4518                 Item := TFavoriteBoardItem( Item ).Item
4519         else if Item is TFavoriteThreadItem then
4520                 Item := TFavoriteThreadItem( Item ).Item;
4521
4522         Node := FavoriteTreeView.Items.GetFirstNode;
4523         if Item is TBoard then begin
4524                 ItemURL := TBoard( Item ).URL;
4525                 while Node <> nil do begin
4526                         Data := Node.Data;
4527                         if TObject( Data ) is TFavoriteBoardItem then begin
4528                                 if ItemURL = TFavoriteBoardItem( Data ).URL then begin
4529                                         if Application.MessageBox( '\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', '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á', MB_YESNO ) = IDNO then
4530                                                 Exit;
4531                                         Break;
4532                                 end;
4533                         end;
4534                         Node := Node.GetNext;
4535                 end;
4536                 Dlg := TFavoriteAddDialog.Create(Self);
4537                 try
4538                         Dlg.SetBoard( TBoard( Item ) );
4539                         Dlg.ShowModal;
4540                 finally
4541                         Dlg.Release;
4542                 end;
4543         end else if Item is TThreadItem then begin
4544                 ItemURL := TThreadItem( Item ).URL;
4545                 while Node <> nil do begin
4546                         Data := Node.Data;
4547                         if TObject( Data ) is TFavoriteThreadItem then begin
4548                                 if ItemURL = TFavoriteThreadItem( Data ).URL then begin
4549                                         if Application.MessageBox( '\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', '\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á', MB_YESNO ) = IDNO then
4550                                                 Exit;
4551                                         Break;
4552                                 end;
4553                         end;
4554                         Node := Node.GetNext;
4555                 end;
4556                 Dlg := TFavoriteAddDialog.Create(Self);
4557                 try
4558                         Dlg.SetThreadItem( TThreadItem( Item ) );
4559                         Dlg.ShowModal;
4560                 finally
4561                         Dlg.Release;
4562                 end;
4563         end;
4564
4565         SetLinkBar;
4566 end;
4567
4568 procedure TGikoForm.FavoriteClick(Sender: TObject);
4569 begin
4570         FavoriteClick( Sender, True );
4571 end;
4572
4573 procedure TGikoForm.FavoriteClick(Sender: TObject; ActiveTab: Boolean);
4574 var
4575         Board: TBoard;
4576         ThreadItem: TThreadItem;
4577         FavBoard: TFavoriteBoardItem;
4578         FavThread: TFavoriteThreadItem;
4579         Item: TObject;
4580 begin
4581 //      Item := nil;
4582         if Sender is TFavoriteMenuItem then
4583                 Item := TFavoriteMenuItem(Sender).Data
4584         else if Sender is TLinkToolButton then
4585                 Item := TLinkToolButton(Sender).Data
4586         else if Sender is TTreeNode then
4587                 Item := TTreeNode( Sender ).Data
4588         else
4589                 Exit;
4590
4591         if TObject(Item) is TFavoriteBoardItem then begin
4592                 FavBoard := TFavoriteBoardItem(Item);
4593                 Board := FavBoard.Item;
4594                 if Board <> nil then begin
4595                         if (FTreeType = gtt2ch) and (FActiveBBS <> Board.ParentCategory.ParenTBBS) then
4596                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4597                         SelectTreeNode(Board, True);
4598                 end;
4599         end else if TObject(Item) is TFavoriteThreadItem then begin
4600                 FavThread := TFavoriteThreadItem(Item);
4601                 ThreadItem := FavThread.Item;
4602                 if ThreadItem = nil then
4603                         Exit;
4604
4605                 InsertBrowserTab(ThreadItem, ActiveTab);
4606
4607                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
4608                         if GikoSys.Setting.ListWidthState = glsMin then begin
4609                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4610                         end;
4611                 end else begin
4612                         if GikoSys.Setting.ListHeightState = glsMin then begin
4613                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4614                         end;
4615                 end;
4616         end;
4617 end;
4618
4619 procedure TGikoForm.BBSMenuItemOnClick(
4620         Sender  : TObject
4621 );
4622 begin
4623
4624         if Sender is TBBSMenuItem then
4625                 ShowBBSTree( TBBSMenuItem( Sender ).Data );
4626
4627 end;
4628
4629 procedure TGikoForm.MainCoolBarResize(Sender: TObject);
4630 begin
4631         TopPanel.Height := Max(MainCoolBar.Height, AnimePanel.Height);
4632
4633 end;
4634 //! \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é)
4635 procedure TGikoForm.OpenThreadItem(Thread: TThreadItem; URL: String);
4636 var
4637         stRes, edRes : Int64;
4638         browserRec : TBrowserRecord;
4639         threadNumber : String;
4640         doc : Variant;
4641 begin
4642         stRes := 0;
4643         edRes := 0;
4644         Thread.JumpAddress := 0;
4645         // \83^\83u\82ð\90\90¬
4646         browserRec := InsertBrowserTab(Thread);
4647         if (browserRec <> nil) then begin
4648                 // JUMP\82·\82×\82«\83\8c\83X\94Ô\8d\86\82ª\82 \82é\82©\83`\83F\83b\83N\82·\82é
4649                 threadNumber := ChangeFileExt(Thread.FileName, '');
4650                 GikoSys.GetPopupResNumber( URL, stRes, edRes );
4651                 // \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
4652                 if (StrToInt64(threadNumber) = stRes) then begin
4653                         if not (AnsiEndsText(threadNumber + '/' + threadNumber, URL))
4654                                 and (Pos('&st=' + threadNumber , URL) = 0) then begin
4655                                 stRes := 0;
4656                         end;
4657                 end;
4658                 if ( stRes > 0 ) then begin
4659                         Thread.JumpAddress := stRes;
4660                 end;
4661                 // \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é
4662                 if (not Thread.IsLogFile) or (stRes > Thread.Count) then begin
4663                         DownloadContent(Thread);
4664                 end else if (not browserRec.Repaint) and (stRes > 0) then begin
4665                         browserRec.Move(IntToStr(stRes));
4666                         Thread.JumpAddress := 0;
4667                         try
4668                                 doc := Idispatch( OleVariant( browserRec.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4669                                 Thread.ScrollTop := doc.Body.ScrollTop;
4670                         except
4671                         end;
4672                 end;
4673         end;
4674 end;
4675
4676 procedure TGikoForm.MoveToURL(const inURL: string);
4677 var
4678         protocol, host, path, document, port, bookmark : string;
4679         URL, protocol2, host2, path2, document2, port2, bookmark2 : string;
4680         tmp1, tmp2: string;
4681         BBSID, BBSKey: string;
4682         {tmpBoard,} Board: TBoard;
4683         ThreadItem: TThreadItem;
4684         i, bi                                   : Integer;
4685         boardURL                        : string;
4686         tmpThread                       : TThreadItem;
4687         shiftDown                       : Boolean;
4688         ctrlDown                        : Boolean;
4689 begin
4690
4691         GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
4692         GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey );
4693
4694
4695         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
4696         ctrlDown        := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
4697         if shiftDown then begin
4698                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4699                 Exit;
4700         end else if ctrlDown then begin
4701                 GikoSys.OpenBrowser(inURL, gbtIE);
4702                 Exit;
4703         end;
4704
4705         //===== \83v\83\89\83O\83C\83\93
4706         try
4707                 //\8dì\8bÆ\92\86//
4708                 bi := Length(BoardGroups) - 1;
4709                 for i := 1 to bi do begin
4710                         if (BoardGroups[i].BoardPlugIn <> nil) and (Assigned(Pointer(BoardGroups[i].BoardPlugIn.Module))) then begin
4711                                 case BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) of
4712                                 atThread:
4713                                         begin
4714                                                 boardURL        := BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL );
4715                                                 Board           := BBSsFindBoardFromURL( boardURL );
4716
4717
4718                                                 if Board = nil then begin
4719                                                         //break;
4720                                                         // \81¦\8dì\82Á\82Ä\82à\92Ç\89Á\82·\82é\82Æ\82±\82ë\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82­\95Û\97¯
4721                                                         //GikoSys.OpenBrowser(inURL, gbtUserApp);
4722                                                         //Exit;
4723                                                         {
4724                                                         Board := GikoSys.GetUnknownBoard( tmpThread.BoardPlugIn, boardURL );
4725                                                         if (FTreeType = gtt2ch) and (FActiveBBS = BBSs[ 1 ]) then
4726                                                                 ShowBBSTree( BBSs[ 1 ] );
4727                                                         }
4728                                                 end else begin
4729                                                         tmpThread               := TThreadItem.Create( BoardGroups[i].BoardPlugIn, Board, inURL );
4730                                                         if not Board.IsThreadDatRead then begin
4731                                                                 GikoSys.ReadSubjectFile( Board );
4732                                                                 tmpThread.Free;
4733                                                                 Exit;
4734                                                         end;
4735                                                         ThreadItem := Board.FindThreadFromFileName( tmpThread.FileName );
4736                                                         if ThreadItem = nil then begin
4737                                                                 //tmpThread\82ð\82±\82Á\82¿\82Í\8aJ\95ú\82µ\82Ä\82Í\82¢\82¯\82È\82¢
4738                                                                 ThreadItem := tmpThread;
4739                                                                 Board.Insert( 0, ThreadItem );
4740                                                                 if ActiveList is TBoard then begin
4741                                                                         if TBoard(ActiveList) = Board then
4742                                                                                 ListView.Items.Count := ListView.Items.Count + 1;
4743                                                                 end;
4744                                                         end else begin
4745                                                                 tmpThread.Free;
4746                                                         end;
4747                                                         OpenThreadItem(ThreadItem, inURL);
4748                                                         Exit;
4749                                                 end;
4750                                         end;
4751
4752                                 atBoard:
4753                                         begin
4754                                                 Board := BBSsFindBoardFromURL(
4755                                                                         BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL )
4756                                                                         );
4757                                                 if Board <> nil then begin
4758                                                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4759                                                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4760                                                         SelectTreeNode( Board, True );
4761                                                         Exit;
4762                                                 end;
4763                                         end;
4764                                 end;
4765                         end;
4766                 end;
4767         except
4768                 // 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¢
4769         end;
4770
4771
4772         if (Length( Trim(BBSKey) ) > 0) and (Length( Trim(BBSID) ) > 0) then begin
4773                 boardURL := GikoSys.Get2chThreadURL2BoardURL( inURL );
4774                 Board := BBSsFindBoardFromURL( boardURL );
4775                 if Board = nil then begin
4776                          // \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­
4777                          GikoSys.OpenBrowser(inURL, gbtUserApp);
4778                          Exit;
4779                 end else begin
4780                         // \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é
4781                         URL :=  Board.URL;
4782                         GikoSys.ParseURI(URL , protocol2, host2, path2, document2, port2, bookmark2 );
4783                         tmp1 := Copy(host, AnsiPos('.', host) + 1, Length(host));
4784                         tmp2 := Copy(host2, AnsiPos('.', host2) + 1, Length(host2));
4785                         if ( not GikoSys.Is2chHost(tmp1)) and (tmp1 <> tmp2) then begin
4786                                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4787                                 Exit;
4788                         end;
4789                 end;
4790
4791                 if not Board.IsThreadDatRead then
4792                         GikoSys.ReadSubjectFile(Board);
4793                 URL := GikoSys.Get2chBrowsableThreadURL( inURL );
4794                 ThreadItem := Board.FindThreadFromURL( URL );
4795                 //\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)
4796                 if ThreadItem = nil then begin
4797                         ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
4798                 end;
4799                 try
4800                         // \83X\83\8c\83b\83h\83A\83C\83e\83\80\82ª\82È\82¢\82È\82ç\90\90¬\82·\82é\81B
4801                         if ThreadItem = nil then begin
4802                                 ThreadItem := TThreadItem.Create( nil, Board, URL );
4803                                 ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
4804                                 Board.Insert(0, ThreadItem);
4805                                 if ActiveList is TBoard then begin
4806                                         if TBoard(ActiveList) = Board then
4807                                                 ListView.Items.Count := ListView.Items.Count + 1;
4808                                 end;
4809                         end;
4810                         // \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é
4811                         if (not ThreadItem.IsLogFile) then begin
4812                                 if AnsiPos(Host, Board.URL) = 0 then
4813                                         ThreadItem.DownloadHost := Host
4814                                 else
4815                                         ThreadItem.DownloadHost := '';
4816                         end;
4817                         OpenThreadItem(ThreadItem, inURL);
4818                 except
4819                 end;
4820         end else begin
4821                 Board := BBSsFindBoardFromURL( inURL );
4822                 if Board = nil then begin
4823                         GikoSys.OpenBrowser(inURL, gbtAuto);
4824                 end else begin
4825                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4826                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4827                         SelectTreeNode( Board, True );
4828                 end;
4829         end;
4830 end;
4831
4832 procedure TGikoForm.AddressToolBarResize(Sender: TObject);
4833 begin
4834         AddressComboBox.Width := AddressToolBar.Width - MoveToToolButton.Width - 10;
4835         CoolBarResized( Sender, MainCoolBar );
4836 end;
4837
4838 procedure TGikoForm.AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
4839         Shift: TShiftState);
4840 begin
4841         if Key = VK_RETURN then
4842                 GikoDM.MoveToAction.Execute;
4843 end;
4844
4845 procedure TGikoForm.BrowserEnter(Sender: TObject);
4846 begin
4847         Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
4848 end;
4849
4850 procedure TGikoForm.WMCopyData(var Message: TWMCopyData);
4851 var
4852         CDS:PCopyDataStruct;
4853         PC:PChar;
4854         sURL: string;
4855 begin
4856         CDS := Message.CopyDataStruct;
4857         GetMem(PC, CDS^.cbData);
4858         try
4859                 lstrcpy(PC,CDS^.lpData);
4860                 SetString(sURL, PC,lstrlen(PC));
4861                 MoveToURL(sURL);
4862         finally
4863                 FreeMem(PC);
4864         end;
4865         Message.Result := 1;
4866 end;
4867
4868 procedure TGikoForm.WndProc(var Message: TMessage);
4869 var
4870         senderBrowser   : TWebBrowser;
4871         url                                             : OleVariant;
4872 begin
4873         try
4874                 case Message.Msg of
4875                 CM_DIALOGCHAR:
4876                         if not (ssAlt in KeyDataToShiftState(TWMChar(Message).KeyData)) then
4877                                 Exit;
4878                 WM_SYSCOMMAND:
4879                         if Message.WParam = SC_MINIMIZE then
4880                                 OnMinimize;
4881                 USER_TREECLICK:
4882                         TreeClick( TreeView.Selected );
4883                 USER_RESIZED:
4884                         OnResized;
4885                 USER_MINIMIZED:
4886                         OnMinimized;
4887                 USER_SETLINKBAR:
4888                         SetLinkBar;
4889                 USER_DOCUMENTCOMPLETE:
4890                         if (Message.WParam <> 0) and
4891                                  (TObject(Message.WParam) is TWebBrowser) then begin
4892                                 senderBrowser := TWebBrowser( Message.WParam );
4893                                 BrowserDocumentComplete( senderBrowser, senderBrowser.Parent, url );
4894                         end;
4895                 end;
4896
4897                 inherited;
4898         except
4899         end;
4900 end;
4901
4902 procedure TGikoForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
4903 var
4904         handle: THandle;
4905 begin
4906         Handled := False;
4907         //\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Í
4908         //\83V\83\87\81[\83g\83J\83b\83g\82È\82Ç\82ð\96³\8cø\82É\82·\82é
4909         if ((FavoriteTreeView.Visible) and (FavoriteTreeView.IsEditing)) then begin
4910                 if Msg.CharCode in [VK_BACK] then begin
4911                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4912                         if Msg.KeyData > 0 then begin
4913                                 handle := GetFocus;
4914                                 if handle <> 0 then
4915                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4916                                 Handled := True;
4917                         end;
4918                 end else
4919                 //\82¨\8bC\82É\93ü\82è\82ÍESC\82Å\92E\8fo\82µ\82½\82¢\82Ì\82Å\81A\82»\82ê\82à\91\97\82é
4920                 if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_ESCAPE] then begin
4921                         handle := GetFocus;
4922                         if handle <> 0 then
4923                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4924                         Handled := True;
4925                 end;
4926         end     else if (AddressComboBox.Focused) or (SelectComboBox.Focused) then begin
4927                 if Msg.CharCode in [VK_BACK] then begin
4928                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4929                         if Msg.KeyData > 0 then begin
4930                                 handle := GetFocus;
4931                                 if handle <> 0 then
4932                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4933                                 Handled := True;
4934                         end;
4935                 end else if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT] then begin
4936                         handle := GetFocus;
4937                         if handle <> 0 then
4938                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4939                         Handled := True;
4940                 end;
4941         end else begin
4942                 Handled := GikoDM.GikoFormActionList.IsShortCut(Msg);
4943         end;
4944 end;
4945
4946 procedure TGikoForm.PreviewTimerTimer(Sender: TObject);
4947 var
4948         p: TPoint;
4949         ARect: TRect;
4950         sl: TStringList;
4951         html: string;
4952         HtmlFileName: string;
4953
4954         NavURL: OleVariant;
4955         Flags: OleVariant;
4956         TargetFrameName: OleVariant;
4957         PostData: OleVariant;
4958         Headers: OleVariant;
4959         WindowHeight: Integer;
4960         WindowWidth: Integer;
4961
4962 //      Style: Longint;
4963         Referer: string;
4964         Protocol, Host, Path, Document, Port, Bookmark: string;
4965 begin
4966         PreviewTimer.Enabled := False;
4967
4968         GetCursorpos(p);
4969
4970         case GikoSys.Setting.PreviewSize of
4971                 gpsXSmall: begin
4972                         WindowWidth := 128;
4973                         WindowHeight := 96;
4974                 end;
4975                 gpsSmall: begin
4976                         WindowWidth := 256;
4977                         WindowHeight := 192;
4978                 end;
4979                 gpsLarge: begin
4980                         WindowWidth := 512;
4981                         WindowHeight := 384;
4982                 end;
4983                 gpsXLarge: begin
4984                         WindowWidth := 640;
4985                         WindowHeight := 480;
4986                 end;
4987                 else begin      //gpsMedium
4988                         WindowWidth := 384;
4989                         WindowHeight := 288;
4990                 end;
4991         end;
4992
4993         ARect := Rect(0, 0, WindowWidth, WindowHeight);
4994
4995         case GikoSys.Setting.PopupPosition of
4996                 gppRightTop:            OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -     15);
4997                 gppRight:                       OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
4998                 gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
4999                 gppTop:                                 OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -  15);
5000                 gppCenter:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
5001                 gppBottom:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
5002                 gppLeftTop:                     OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -  15);
5003                 gppLeft:                                OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
5004                 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Ó
5005         end;
5006
5007         html := '<html><head>'#13#10
5008                                 + '<SCRIPT>'#13#10
5009                                 + 'function init() {'#13#10
5010                                 + '     if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
5011                                 + '     } else {'#13#10
5012                                 + '             var dh, ih;'#13#10
5013                                 + '             dh = document.body.clientWidth / document.body.clientHeight;'#13#10
5014                                 + '             ih = Image1.width / Image1.height;'#13#10
5015                                 + '             if (document.body.clientWidth < document.body.clientHeight) {'#13#10
5016                                 + '                     if (ih > dh)'#13#10
5017                                 + '                             Image1.width = document.body.clientWidth;'#13#10
5018                                 + '                     else'#13#10
5019                                 + '                             Image1.height = document.body.clientHeight;'#13#10
5020                                 + '             } else {'#13#10
5021                                 + '                     if (ih < dh)'#13#10
5022                                 + '                             Image1.height = document.body.clientHeight;'#13#10
5023                                 + '                     else'#13#10
5024                                 + '                             Image1.width = document.body.clientWidth;'#13#10
5025                                 + '             }'#13#10
5026                                 + '     }'#13#10
5027                                 + '     Message.style.display = "none";'#13#10
5028                                 + '}'#13#10
5029                                 + '</SCRIPT>'#13#10
5030                                 + '</head>'#13#10
5031                                 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
5032                                 + '<div align="center" id="Message">\83v\83\8c\83r\83\85\81[\8dì\90¬\92\86</div>'#13#10
5033                                 + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
5034                                 + '</body></html>';
5035         sl := TStringList.Create;
5036         try
5037                 try
5038                         HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
5039                         sl.Text := AnsiReplaceStr(html, '%ImageURL%', FPreviewURL);
5040                         sl.SaveToFile(HtmlFileName);
5041                 finally
5042                         sl.Free;
5043                 end;
5044         except
5045         end;
5046
5047         NavURL := HtmlFileName;
5048         Flags := 0;
5049         TargetFrameName := '';
5050         PostData := '';
5051
5052         GikoSys.ParseURI(FPreviewURL, Protocol, Host, Path, Document, Port, Bookmark);
5053         Referer := Protocol + '://' + Host;
5054         if Port <> '' then
5055                 Referer := Referer + ':' + Port;
5056         Referer := Referer + Path;
5057         Headers := 'Referer: ' + Referer;
5058         FPreviewBrowser.Navigate(NavURL, Flags, TargetFrameName, PostData, Headers);
5059         if ARect.Top + WindowHeight > Screen.DesktopHeight then
5060                 ARect.Top := Screen.DesktopHeight - WindowHeight;
5061         if ARect.Left + WindowWidth > Screen.DesktopWidth then
5062                 ARect.Left := Screen.DesktopWidth - WindowWidth;
5063         if ARect.Left < Screen.DesktopLeft then ARect.Left := Screen.DesktopLeft;
5064         if ARect.Bottom < Screen.DesktopTop then ARect.Bottom := Screen.DesktopTop;
5065
5066         SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST, ARect.Left, ARect.Top, WindowWidth, WindowHeight, SWP_NOACTIVATE or SWP_HIDEWINDOW);
5067         ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);
5068         FPreviewBrowserRect := ARect;
5069 //      Style := GetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE);
5070 //      SetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE, Style xor WS_EX_APPWINDOW);
5071
5072 end;
5073
5074 procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
5075 var
5076         Pos : TPoint;
5077 begin
5078
5079         if PreviewTimer.Enabled then
5080                 PreviewTimer.Enabled := False;
5081         if (FHint <> nil) and (IsWindowVisible(FHint.Handle)) then begin
5082                 FHint.ReleaseHandle;
5083                 FHint.ClearAllRes;
5084         end;
5085
5086         if (FPreviewBrowser <> nil)
5087                 and (IsWindowVisible(FPreviewBrowser.Handle)) then begin
5088         //\82±\82±\82Å\8fÁ\82³\82ê\82é\82Ì\82ª\96â\91è
5089         //\82½\82Ô\82ñ\82±\82ê\82Å\95\\8e¦\94Í\88Í\94»\92è\82Å\82«\82Ä\82¢\82é\82Í\82¸
5090                 Pos := Mouse.CursorPos;
5091                 Pos.X := Pos.X + Left;
5092                 Pos.Y := Pos.Y + Top;
5093                 if (FPreviewBrowserRect.Left > Pos.X) or
5094                         (FPreviewBrowserRect.Right < Pos.X) or
5095                         (FPreviewBrowserRect.Top > Pos.Y) or
5096                         (FPreviewBrowserRect.Bottom < Pos.Y) then begin
5097                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
5098                 end;
5099         end;
5100
5101         Message.Result := 1;
5102         inherited;
5103 end;
5104 procedure TGikoForm.MessageHideButtonClick(Sender: TObject);
5105 begin
5106         GikoDM.MsgBarCloseAction.Execute;
5107 end;
5108
5109 function TGikoForm.OnDocumentContextMenu(Sender: TObject): WordBool;
5110 var
5111         Doc: IHtmlDocument2;
5112         Range: IHTMLTxtRange;
5113         s: string;
5114         Num: Integer;
5115         ThreadItem: TThreadItem;
5116 begin
5117         Result := False;
5118         FactiveContent.IDAnchorPopup('');
5119         Doc := FactiveContent.Browser.Document as IHtmlDocument2;
5120         if Assigned(Doc) then begin
5121                 Range := Doc.selection.createRange as IHTMLTxtRange;
5122                 s := CustomStringReplace(Range.text, '\81@', ' ');//\91S\8ap\8bó\94\92\82ð\94¼\8ap\8bó\94\92\82É
5123                 s := ZenToHan(Trim(s));
5124                 if GikoSys.IsNumeric(s) then begin
5125
5126                         ThreadItem := GetActiveContent;
5127                         if ThreadItem <> nil then begin
5128                                 Num := StrToInt64(s);
5129                                 FHint.PopupType := gptThread;
5130                                 HTMLCreater.SetResPopupText(FHint, ThreadItem, Num, Num, False, False);
5131                                 if FHint.ResCount <> 0 then
5132                                         ShowTextPopup;
5133                                 Result := False;
5134                         end else
5135                                 Result := True;
5136                 end else begin
5137                         Result := True;
5138                 end;
5139         end;
5140 end;
5141
5142 procedure TGikoForm.ShowTextPopup;
5143 var
5144         p: TPoint;
5145         ARect: TRect;
5146 begin
5147 //      if Trim(s) = '' then
5148 //              Exit;
5149         try
5150                 FHint.Font.Name := GikoSys.Setting.HintFontName;
5151                 FHint.Font.Size := GikoSys.Setting.HintFontSize;
5152                 FHint.Font.Color := GikoSys.Setting.HintFontColor;
5153                 FHint.Color := GikoSys.Setting.HintBackColor;
5154                 FHint.HeaderBold := GikoSys.Setting.ResPopupHeaderBold;
5155                 GetCursorpos(p);
5156                 if FHint.PopupType = gptRaw then
5157                         ARect := FHint.CalcHintRect(Screen.Width, FHint.Caption, nil)
5158                 else
5159                         ARect := FHint.CalcHintRect(Screen.Width, '', nil);
5160                 case GikoSys.Setting.PopupPosition of
5161                         gppRightTop:            OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -     15);
5162                         gppRight:                       OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
5163                         gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
5164                         gppTop:                                 OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -  15);
5165                         gppCenter:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
5166                         gppBottom:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
5167                         gppLeftTop:                     OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -  15);
5168                         gppLeft:                                OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
5169                         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Ó
5170                 end;
5171                 //FHint.ActivateHint(ARect, s);
5172                 if FHint.PopupType = gptRaw then
5173                         FHint.ActivateHint(ARect, FHint.Caption)
5174                 else
5175                         FHint.ActivateHint(ARect, '');
5176         except
5177                 FHint.ReleaseHandle;
5178                 FHint.ClearAllRes;
5179         end;
5180 end;
5181
5182 procedure TGikoForm.HistoryAllClearToolButtonClick(Sender: TObject);
5183 const
5184         DEL_MSG = '\91S\97\9a\97ð\82ð\8dí\8f\9c\82µ\82Ü\82·\81B\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
5185         DEL_TITLE = '\8dí\8f\9c\8am\94F';
5186 begin
5187         if FTreeType = gttHistory then begin
5188                 if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then
5189                         if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then
5190                                 Exit;
5191                 ClearHistory;
5192                 FHistoryList.Clear;
5193                 TreeView.Items.Clear;
5194         end;
5195 end;
5196
5197 procedure TGikoForm.SetLinkBar;
5198 var
5199         i: Integer;
5200         j: Integer;
5201         ToolButton: TLinkToolButton;
5202         MenuItem: TMenuItem;
5203         oldIgnoreResize : TResizeType;
5204 begin
5205         oldIgnoreResize := FIsIgnoreResize;
5206         FIsIgnoreResize := rtResizing;
5207         MainCoolBar.Bands.BeginUpdate;
5208         try
5209                 LinkBarPopupMenu.Items.Clear;
5210                 for i := LinkToolBar.ButtonCount - 1 downto 0 do
5211                         //LinkToolBar.RemoveControl(LinkToolBar.Buttons[i]);
5212                         LinkToolBar.Buttons[i].Free;
5213                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5214                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5215                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5216                                         ToolButton := TLinkToolButton.Create(LinkToolBar);
5217 //                    ToolButton.Parent := LinkToolBar;
5218                                         if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteFolder then begin
5219                                                 MenuItem := TMenuItem.Create(Self);
5220                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], MenuItem);
5221                                                 LinkBarPopupMenu.Items.Add(MenuItem);
5222                                                 ToolButton.MenuItem := MenuItem;
5223                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
5224                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteBoardItem then begin
5225                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
5226                                                 ToolButton.OnClick := FavoriteClick;
5227                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteThreadItem then begin
5228                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
5229                                                 ToolButton.OnClick := FavoriteClick;
5230                                         end;
5231                                         ToolButton.Caption := FavoriteTreeView.Items[i].Item[j].Text;
5232                                         ToolButton.Left := 10000;
5233                                         ToolButton.Data := FavoriteTreeView.Items[i].Item[j].Data;
5234                                         ToolButton.AutoSize := True;
5235                                         ToolButton.OnDragDrop := LinkToolButtonDragDrop;
5236                                         ToolButton.OnDragOver := FavoriteDragOver;
5237                                         ToolButton.OnMouseDown := LinkToolButtonOnMouseDown;
5238                                         ToolButton.OnMouseMove := LinkToolButtonOnMouseMove;
5239                                         ToolButton.OnMouseUp := LinkToolButtonOnMouseUp;
5240                                         ToolButton.OnStartDrag := LinkToolButtonStartDrag;
5241                                         //ToolButton.DragMode := dmAutomatic;
5242                                         ToolButton.DragMode := dmManual;
5243                                         ToolButton.PopupMenu := FavoriteTreePopupMenu;
5244
5245                                         LinkToolBar.InsertControl(ToolButton);
5246                                 end;
5247                                 break;
5248                         end;
5249                 end;
5250 {               if LinkToolBar.ButtonCount = 0 then begin
5251                         ToolButton := TLinkToolButton.Create(LinkToolBar);
5252                         ToolButton.Style := tbsButton;
5253                         ToolButton.ImageIndex := -1;
5254                         ToolButton.Caption := '';
5255                         LinkToolBar.InsertControl(ToolButton);
5256                 end;}
5257         finally
5258                 MainCoolBar.Bands.EndUpdate;
5259                 LoadCoolBarSettings;
5260                 FIsIgnoreResize := oldIgnoreResize;
5261         end;
5262 end;
5263
5264 procedure TGikoForm.FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5265 var
5266         Node: TTreeNode;
5267         bound: TRect;
5268         height: Integer;
5269         Change: Boolean;
5270 begin
5271
5272         if Sender = FavoriteTreeView then begin
5273                 Node := FavoriteTreeView.GetNodeAt(X, Y);
5274
5275                 if Node = nil then
5276                         Exit;
5277
5278                 bound := Node.DisplayRect( False );
5279                 height := bound.Bottom - bound.Top;
5280                 if (bound.Top + height / 2) <= Y then
5281                         Node := FavoriteTreeView.GetNodeAt(X, Y + height);
5282
5283                 if Node = nil then
5284                         Exit;
5285
5286                 if Node.IsFirstNode then
5287                         Exit;
5288
5289                 Change := True;
5290
5291                 if FDropSpaceNode <> nil then
5292                         if FDropSpaceNode.AbsoluteIndex = Node.AbsoluteIndex then
5293                                 Change := False;
5294
5295                 if Change then begin
5296                         if FDropSpaceNode <> nil then
5297                                 FDropSpaceNode.Free;
5298
5299                         FDropSpaceNode := FavoriteDM.TreeView.Items.AddChildObjectFirst(Node.Parent, '', nil );
5300                         FDropSpaceNode.MoveTo( Node, naInsert );
5301                         FDropSpaceNode.ImageIndex := -1;
5302                         FDropSpaceNode.SelectedIndex := -1;
5303                 end;
5304         end;
5305
5306         if Source = FavoriteTreeView then begin
5307                 if FavoriteTreeView.Selected = FavoriteTreeView.Items.GetFirstNode then begin
5308                         Accept := False;
5309                         Exit;
5310                 end;
5311                 Accept := True;
5312         end else if Source = BrowserTab then
5313                 Accept := True
5314         else if Source = ListView then
5315                 Accept := True
5316         else if Source is TLinkToolButton then
5317                 Accept := True
5318         else if Source = TreeView then
5319                 Accept := True
5320         else
5321                 Accept := False;
5322 end;
5323
5324 procedure TGikoForm.FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5325 begin
5326
5327         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
5328
5329 end;
5330 procedure TGikoForm.LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
5331 begin
5332          //     FDragging := true;
5333 end;
5334
5335 procedure TGikoForm.LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
5336 var
5337         SenderNode: TTreeNode;
5338         LinkToolButton: TLinkToolButton;
5339 begin
5340
5341         LinkToolButton := TLinkToolButton( Sender );
5342         SenderNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
5343         SenderNode.Selected := False;
5344         FavoriteDragDrop( SenderNode, Source );
5345
5346         SetLinkBar;
5347
5348 end;
5349
5350 procedure TGikoForm.LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5351 var
5352         favButton                       : TLinkToolButton;
5353         favThreadItem   : TFavoriteThreadItem;
5354 begin
5355
5356         case Button of
5357         mbMiddle:
5358                 begin
5359                         if Sender is TLinkToolButton then begin
5360                                 favButton := TLinkToolButton( Sender );
5361                                 if TObject( favButton.Data ) is TFavoriteThreadItem then begin
5362                                         favThreadItem := TFavoriteThreadItem( favButton.Data );
5363                                         if favThreadItem.Item <> nil then
5364                                                 InsertBrowserTab( favThreadItem.Item, False );
5365                                 end;
5366                         end;
5367                 end;
5368         end;
5369
5370 end;
5371
5372 procedure TGikoForm.LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
5373 var
5374         Now : Cardinal;
5375 begin
5376         TToolButton( Sender ).DragMode := dmManual;
5377         if ssLeft in Shift then begin
5378 //              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)
5379                 if FDragTime = 0 then begin
5380                         FDragTime := GetTickCount();
5381                 end else begin
5382                         Now := GetTickCount();
5383                         if (Now - FDragTime) > 500 then begin
5384                                 if FDragButton <> TToolButton( Sender ) then begin
5385                                         try
5386                                                 FDragButton := TToolButton( Sender );
5387                                                 TToolButton(Sender).BeginDrag(false ,5);
5388                                                 FDragTime := 0;
5389                                         except
5390                                                 {$IF Defined(debug)}
5391                                                 ShowMessage('Error');
5392                                                 {$IFEND}
5393                                         end;
5394                                 end;
5395                         end;
5396                 end;
5397         end else begin
5398                 FDragTime := 0;
5399         end;
5400 end;
5401
5402 procedure TGikoForm.LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5403 begin
5404         FDragTime := 0;
5405 end;
5406
5407 function TGikoForm.GetWidthAllToolButton(ToolBar: TToolBar): Integer;
5408 var
5409         i: Integer;
5410 begin
5411         Result := 0;
5412         for i := 0 to ToolBar.ButtonCount - 1 do
5413                 if ToolBar.Buttons[i].Visible then
5414                         Result := Result + ToolBar.Buttons[i].Width;
5415 end;
5416
5417 procedure TGikoForm.MainCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5418 var
5419         Control : TWinControl;
5420         i, idx  : Integer;
5421 begin
5422         Control := FindControl(BandInfo^.hwndChild);
5423         if Control = nil then
5424                 Exit;
5425         idx := 0;
5426         for i := MainCoolBar.Bands.Count - 1 downto 0 do begin
5427                 if MainCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5428                         idx := MainCoolBar.Bands[ i ].ID;
5429                         Break;
5430                 end;
5431         end;
5432         Canvas.Font.Handle := GetStockObject( DEFAULT_GUI_FONT );
5433         if (Control = MenuToolBar) or (Control = StdToolBar) then begin
5434                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5435                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5436                 BandInfo^.cxMinChild    := 0;
5437                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth;
5438                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5439         end else if Control = LinkToolBar then begin
5440                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5441                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5442                 BandInfo^.cxMinChild    := 0;
5443                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83\8a\83\93\83N' );
5444                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5445         end else begin // AddressToolBar
5446                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5447                 BandInfo^.cxMinChild    := 0;
5448                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83A\83h\83\8c\83X' );
5449         end;
5450 end;
5451
5452 procedure TGikoForm.MainCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5453 var
5454         i : Integer;
5455         Idx: Integer;
5456         p: TPoint;
5457 begin
5458         ChevronPopupMenu.Items.Clear;
5459         Idx := 0;
5460         for i := 0 to MainCoolBar.Bands.Count - 1 do begin
5461                 if MainCoolBar.Bands[ i ].Visible then begin
5462                         if Idx = Int64(RebarChevron^.uBand) then begin
5463                                 Idx := i;
5464                                 break;
5465                         end;
5466                         Inc( Idx );
5467                 end;
5468         end;
5469         if (Idx >= 0) and (MainCoolBar.Bands.Count > Idx) then begin
5470                 if MainCoolBar.Bands[Idx].Control = MenuToolbar then begin
5471                         MenuBarChevronMenu;
5472                 end else if MainCoolBar.Bands[Idx].Control = StdToolbar then begin
5473                         ToolBarChevronMenu(StdToolBar);
5474                 end else if MainCoolBar.Bands[Idx].Control = LinkToolbar then begin
5475                         LinkBarChevronMenu;
5476                 end else
5477                         Exit;
5478                 p := MainCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5479                 ChevronPopupMenu.Popup(p.x, p.y);
5480         end;
5481 end;
5482
5483 procedure TGikoForm.MenuBarChevronMenu;
5484         procedure SetSubMenu(MenuItem: TMenuItem; PopupItem: TMenuItem);
5485         var
5486                 i: Integer;
5487                 Item: TMenuItem;
5488         begin
5489                 MenuItem.Click;
5490                 for i := 0 to MenuItem.Count - 1 do begin
5491 //                      Item := nil;
5492                         if MenuItem[i] is TFavoriteMenuItem then begin
5493                                 Item := TFavoriteMenuItem.Create(Self);
5494                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(MenuItem[i]).Data;
5495                         end else
5496                                 Item := TMenuItem.Create(Self);
5497                         Item.Caption := MenuItem[i].Caption;
5498                         Item.Action := MenuItem[i].Action;
5499                         Item.ImageIndex := MenuItem[i].ImageIndex;
5500                         Item.OnClick := MenuItem[i].OnClick;
5501                         PopupItem.Add(Item);
5502                         if MenuItem[i].Count > 0 then
5503                                 SetSubMenu(MenuItem[i], Item);
5504                 end;
5505         end;
5506 var
5507         i: Integer;
5508         w: Integer;
5509         bw: Integer;
5510         Item: TMenuItem;
5511 begin
5512         ChevronPopupMenu.Items.Clear;
5513         ChevronPopupMenu.Images := MainMenu.Images;
5514         bw := GetWidthAllToolButton(MenuToolBar);
5515         if MenuToolBar.Width < bw then begin
5516                 w := 0;
5517                 for i := 0 to MenuToolBar.ButtonCount - 1 do begin
5518                         w := w + MenuToolBar.Buttons[i].Width;
5519                         if MenuToolBar.Width <= w then begin
5520                                 Item := TMenuItem.Create(Self);
5521                                 Item.Caption := MenuToolBar.Buttons[i].MenuItem.Caption;
5522                                 //Item.Action := MenuToolBar.Buttons[i].MenuItem.Action;
5523                                 ChevronPopupMenu.Items.Add(Item);
5524                                 SetSubMenu(MenuToolbar.Buttons[i].MenuItem, Item);
5525                         end;
5526                 end;
5527         end;
5528 end;
5529
5530 procedure TGikoForm.ToolBarChevronMenu(ToolBar: TToolBar);
5531         procedure SetSubMenu(PopupMenu: TPopupMenu; PopupItem: TMenuItem);
5532         var
5533                 i: Integer;
5534                 Item: TMenuItem;
5535         begin
5536                 if Assigned(PopupMenu.OnPopup) then
5537                         PopupMenu.OnPopup(nil);
5538                 for i := 0 to PopupMenu.Items.Count - 1 do begin
5539 //                      Item := nil;
5540                         if PopupMenu.Items[i] is TFavoriteMenuItem then begin
5541                                 Item := TFavoriteMenuItem.Create(Self);
5542                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(PopupMenu.Items[i]).Data;
5543                         end else
5544                         Item := TMenuItem.Create(Self);
5545                         Item.Caption := PopupMenu.Items[i].Caption;
5546                         Item.Action := PopupMenu.Items[i].Action;
5547                         Item.ImageIndex := PopupMenu.Items[i].ImageIndex;
5548                         Item.OnClick := PopupMenu.Items[i].OnClick;
5549                         PopupItem.Add(Item);
5550                 end;
5551         end;
5552 var
5553         i: Integer;
5554         w: Integer;
5555         bw: Integer;
5556         Item: TMenuItem;
5557 begin
5558         ChevronPopupMenu.Items.Clear;
5559         ChevronPopupMenu.Images := ToolBar.HotImages;
5560         bw := GetWidthAllToolButton(ToolBar);
5561         if ToolBar.Width < bw then begin
5562                 w := 0;
5563                 for i := 0 to ToolBar.ButtonCount - 1 do begin
5564                         if ToolBar.Buttons[i].Visible then
5565                                 w := w + ToolBar.Buttons[i].Width;
5566                         if ToolBar.Width <= w then begin
5567                                 if ToolBar.Buttons[i].Tag = 0 then begin
5568                                         Item := TMenuItem.Create(Self);
5569                                         if ToolBar.Buttons[i].Style = tbsSeparator then
5570                                                 Item.Caption := '-'
5571                                         else begin
5572                                                 //\83X\83\8c\8di\8d\9e\82ÝComBox\82ÌTPanel\82ð\94r\8f\9c\82·\82é
5573                                                 if TObject(ToolBar.Buttons[i]) is TPanel then begin
5574                                                         Continue;
5575                                                 end else begin
5576                                                         Item.Caption := ToolBar.Buttons[i].Caption;
5577                                                         Item.Action := ToolBar.Buttons[i].Action;
5578                                                 end;
5579                                                 //Item.Visible := True;
5580                                         end;
5581                                         ChevronPopupMenu.Items.Add(Item);
5582                                         if ToolBar.Buttons[i].DropdownMenu <> nil then begin
5583                                                 Item.Action := nil;
5584                                                 Item.OnClick := nil;
5585                                                 SetSubMenu(ToolBar.Buttons[i].DropdownMenu, Item);
5586                                         end;
5587                                 end;
5588                         end;
5589                 end;
5590         end;
5591 end;
5592
5593 procedure TGikoForm.LinkBarChevronMenu;
5594 var
5595         i: Integer;
5596         j: Integer;
5597         w: Integer;
5598         Item: TFavoriteMenuItem;
5599         bw: Integer;
5600         Button: TLinkToolButton;
5601 begin
5602         ChevronPopupMenu.Items.Clear;
5603         ChevronPopupMenu.Images := LinkToolBar.Images;
5604         bw := GetWidthAllToolButton(LinkToolBar);
5605         if LinkToolBar.Width < bw then begin
5606                 w := 0;
5607                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5608                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5609                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5610                                         w := w + LinkToolBar.Buttons[j].Width;
5611                                         if LinkToolBar.Width <= w then begin
5612                                                 if LinkToolBar.Buttons[j] is TLinkToolButton then begin
5613                                                         Button := TLinkToolButton(LinkToolBar.Buttons[j]);
5614                                                         Item := TFavoriteMenuItem.Create(Self);
5615                                                         if TObject(Button.Data) is TFavoriteFolder then begin
5616                                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], Item);
5617                                                         end else if TObject(Button.Data) is TFavoriteBoardItem then begin
5618                                                                 Item.OnClick := FavoriteClick;
5619                                                         end else if TObject(Button.Data) is TFavoriteThreadItem then begin
5620                                                                 Item.OnClick := FavoriteClick;
5621                                                         end;
5622                                                         Item.Data := Button.Data;
5623                                                         Item.Caption := LinkToolBar.Buttons[j].Caption;
5624                                                         Item.ImageIndex := LinkToolBar.Buttons[j].ImageIndex;
5625                                                         ChevronPopupMenu.Items.Add(Item);
5626                                                 end;
5627                                         end;
5628                                 end;
5629                                 break;
5630                         end;
5631                 end;
5632         end;
5633 end;
5634
5635 {!
5636 \brief  \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
5637 \param  bar             \83o\83\93\83h\82ª\8f\8a\91®\82·\82é CoolBar
5638 \param  band    \8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é\83o\83\93\83h
5639
5640 \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É
5641 \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
5642 }
5643 procedure TGikoForm.ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
5644 var
5645         bandInfo        : tagREBARBANDINFOA;
5646         pBandInfo       : PReBarBandInfoA;
5647         lResult         : Integer;
5648         h                                       : HWND;
5649         i, idx          : Integer;
5650 begin
5651
5652         h                                                                               := band.Handle;
5653         pBandInfo := @bandInfo;
5654         ZeroMemory( pBandInfo, sizeof( bandInfo ) );
5655         bandInfo.cbSize                 := sizeof( bandInfo );
5656         bandInfo.hwndChild      := h;
5657         bandInfo.cyMinChild     := bar.Height;
5658         bar.OnBandInfo( nil, pBandInfo );
5659         // band \82Ì\83C\83\93\83f\83b\83N\83X\82ð\92T\82·
5660         idx := 0;
5661         for i := bar.Bands.Count - 1 downto 0 do begin
5662                 if bar.Bands[ i ].Control.Handle = h then begin
5663                         idx := i;
5664                         Break;
5665                 end;
5666         end;
5667         // \90Ý\92è
5668         lResult := SendMessage( bar.Handle, RB_SETBANDINFO, idx, Integer( pBandInfo ) );
5669
5670 end;
5671
5672 procedure TGikoForm.ListCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5673 var
5674         Control: TWinControl;
5675         i, idx  : Integer;
5676 begin
5677         Control := FindControl(BandInfo^.hwndChild);
5678         if Control = nil then
5679                 Exit;
5680         idx := 0;
5681         for i := ListCoolBar.Bands.Count - 1 downto 0 do begin
5682                 if ListCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5683                         idx := ListCoolBar.Bands[ i ].ID;
5684                         Break;
5685                 end;
5686         end;
5687         if Control = ListToolBar then begin
5688                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5689                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5690                 BandInfo^.cxMinChild    := 0;
5691                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5692                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5693         end else begin
5694                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5695                 BandInfo^.cxMinChild    := 0;
5696                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5697         end;
5698 end;
5699
5700 procedure TGikoForm.ListCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5701 var
5702         Idx: Integer;
5703         p: TPoint;
5704 begin
5705         ChevronPopupMenu.Items.Clear;
5706         Idx := RebarChevron^.uBand;
5707         if (Idx >= 0) and (ListCoolBar.Bands.Count > Idx) then begin
5708                 if ListCoolBar.Bands[Idx].Control = ListToolBar then begin
5709                         ToolBarChevronMenu(ListToolBar);
5710                 end else
5711                         Exit;
5712                 p := ListCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5713                 ChevronPopupMenu.Popup(p.x, p.y);
5714         end;
5715 end;
5716
5717 procedure TGikoForm.BrowserCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5718 var
5719         Control: TWinControl;
5720         i, idx  : Integer;
5721 begin
5722         Control := FindControl(BandInfo^.hwndChild);
5723         if Control = nil then
5724                 Exit;
5725         idx := 0;
5726         for i := BrowserCoolBar.Bands.Count - 1 downto 0 do begin
5727                 if BrowserCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5728                         idx := BrowserCoolBar.Bands[ i ].ID;
5729                         Break;
5730                 end;
5731         end;
5732         if Control = BrowserToolBar then begin
5733                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5734                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5735                 BandInfo^.cxMinChild    := 0;
5736                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5737                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5738         end else begin
5739                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5740                 BandInfo^.cxMinChild    := 0;
5741                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5742         end;
5743 end;
5744
5745 procedure TGikoForm.BrowserCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5746 var
5747         Idx: Integer;
5748         p: TPoint;
5749 begin
5750         ChevronPopupMenu.Items.Clear;
5751         Idx := RebarChevron^.uBand;
5752         if (Idx >= 0) and (BrowserCoolBar.Bands.Count > Idx) then begin
5753                 if BrowserCoolBar.Bands[Idx].Control = BrowserToolBar then
5754                         ToolBarChevronMenu(BrowserToolBar)
5755                 else
5756                         Exit;
5757                 p := BrowserCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5758                 ChevronPopupMenu.Popup(p.x, p.y);
5759         end;
5760 end;
5761
5762 procedure TGikoForm.ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
5763 begin
5764         if Column^.iImage = -1 then begin
5765                 Column^.mask := Column^.mask or LVCF_FMT;
5766         end else begin
5767                 Column^.mask := Column^.mask or LVCF_FMT or LVCF_IMAGE;
5768                 Column^.fmt := Column^.fmt or LVCFMT_IMAGE or LVCFMT_BITMAP_ON_RIGHT;
5769         end;
5770 end;
5771
5772 function TGikoForm.FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
5773 var
5774         i : Integer;
5775 begin
5776         Result := nil;
5777         for i := bar.ButtonCount - 1 downto 0 do begin
5778                 if bar.Buttons[ i ].Action = action then begin
5779                         Result := bar.Buttons[ i ];
5780                         Break;
5781                 end;
5782         end;
5783 end;
5784
5785 procedure TGikoForm.SetToolBarPopup;
5786 var
5787         i                                                                       : Integer;
5788         aIEButton                                       : TToolButton;
5789         aCabinetBBSButton       : TToolButton;
5790         aResRangeButton         : TToolButton;
5791         aThreadRangeButton:     TToolButton;
5792 begin
5793         for i := 0 to StdToolBar.ButtonCount - 1 do begin
5794         end;
5795         for i := 0 to ListToolBar.ButtonCount - 1 do begin
5796                 if ListToolBar.Buttons[i].Action = GikoDM.IconStyle then
5797                         ListToolBar.Buttons[i].DropdownMenu := ListIconPopupMenu;
5798                 if ListToolBar.Buttons[i].Action = GikoDM.SelectReservAction then
5799                         ListToolBar.Buttons[i].DropdownMenu := RoundNamePopupMenu;
5800         end;
5801         aIEButton                                       := FindToolBarButton( BrowserToolBar, GikoDM.IEAction );
5802         if aIEButton <> nil then
5803                 aIEButton.DropdownMenu                                  := BrowserPopupMenu;
5804         aCabinetBBSButton       := FindToolBarButton( StdToolBar, GikoDM.CabinetBBSAction );
5805         if aCabinetBBSButton <> nil then
5806                 aCabinetBBSButton.DropdownMenu  := BBSSelectPopupMenu;
5807         aResRangeButton         := FindToolBarButton( BrowserToolBar, GikoDM.ResRangeAction );
5808         if aResRangeButton <> nil then
5809                 aResRangeButton.DropdownMenu            := ResRangePopupMenu;
5810         aThreadRangeButton:= FindToolBarButton( ListToolBar, GikoDM.ThreadRangeAction );
5811         if aThreadRangeButton <> nil then
5812                 aThreadRangeButton.DropdownMenu := ThreadRangePopupMenu;
5813 end;
5814
5815 procedure TGikoForm.FormMouseWheel(Sender: TObject; Shift: TShiftState;
5816         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
5817 var
5818         Wnd: THandle;
5819         delta: Integer;
5820 //      browserPos : TPoint;
5821 const
5822         ICON_SIZE = 16;
5823 begin
5824         Wnd := WindowFromPoint(Mouse.CursorPos);
5825         Handled := True;
5826         if WheelDelta > 0 then
5827                 Delta := -1
5828         else
5829                 Delta := 1;
5830
5831         if (Wnd = BrowserTab.Handle) or
5832                  (Wnd = BrowserTab.Parent.Handle) then begin
5833                 BrowserTab.ScrollTabs(Delta);
5834         end else begin
5835                 if FIsHandledWheel then begin
5836                         FIsHandledWheel := False;
5837                         Handled := False;
5838                 end else begin
5839                         FIsHandledWheel := True;
5840                         if (Wnd = TreeView.Handle) or  (Wnd = FavoriteTreeView.Handle)
5841                         or (Wnd = ListView.Handle) or (Wnd = MessageListView.Handle)
5842                         then
5843                                 SendMessage( Wnd, WM_MOUSEWHEEL, WheelDelta shl 16, (Mouse.CursorPos.X shl 16) or Mouse.CursorPos.Y )
5844                         else
5845                                 Handled := False;
5846
5847                 end;
5848         end;
5849 end;
5850
5851 procedure TGikoForm.SetSelectWord( const text : string );
5852 begin
5853         // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
5854         ClearThreadRengeAction;
5855
5856         if Length( text ) = 0 then
5857         begin
5858                 GikoDM.AllItemAction.Checked := True;
5859                 SetListViewType( gvtAll )
5860         end else begin
5861                 SetListViewType( gvtUser, text, false );
5862         end;
5863 end;
5864
5865 procedure TGikoForm.SelectComboBoxChange(Sender: TObject);
5866 begin
5867
5868         SetSelectWord( SelectComboBox.Text );
5869
5870 end;
5871
5872 procedure TGikoForm.SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
5873         Shift: TShiftState);
5874 var
5875   IMC: HIMC;
5876   Len: integer;
5877   Str: string;
5878   tmp: string;
5879 begin
5880
5881         if Key = VK_Return then
5882         begin
5883                 ModifySelectList;
5884         end else if Key = 229 then begin
5885                 if GikoSys.Setting.UseUndecided then begin
5886                         IMC := ImmGetContext(SelectComboBox.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
5887                         Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5888                         SetLength(Str, Len + 1); //Buffer\82Ì\83\81\83\82\83\8a\82ð\90Ý\92è
5889                         ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5890                         ImmReleaseContext(SelectComboBox.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
5891                         SetLength(Str, Len);
5892                         if SelectComboBox.SelLength > 0 then begin //\91I\91ð\92\86\82Ì\95\8e\9a\97ñ\82ª\82 \82é\82©
5893                                 tmp := Copy(SelectComboBox.Text, 1, SelectComboBox.SelStart);
5894                                 Str := tmp + Str + Copy(SelectComboBox.Text, SelectComboBox.SelStart + SelectComboBox.SelLength + 1, Length(SelectComboBox.Text));
5895                         end else
5896                                 Str := SelectComboBox.Text + Str;
5897
5898                         if (Length(Str) > 0) then begin
5899                                 SetSelectWord(Str);
5900                         end;
5901                 end;
5902         end else if Length( SelectComboBox.Text ) = 0 then
5903         begin
5904                 {* SelectComboBox.Text\82ª\8bó\82Å\82à\81A\93ü\97Í\93r\92\86\82ÅEsc\82µ\82½\82Æ\82©
5905                  * \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
5906                  * \81i\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢\81j
5907                  *}
5908         end else begin
5909         // \83X\83\8c\88ê\97\97\82Ì\94Í\88Í\8ew\92è\82ð\89ð\8f\9c
5910                 ClearThreadRengeAction;
5911         end;
5912
5913 end;
5914 //! \83X\83\8c\83b\83h\88ê\97\97\82Ì\95\\8e¦\94Í\88Í\90Ý\92è\83`\83F\83b\83N\83N\83\8a\83A
5915 procedure TGikoForm.ClearThreadRengeAction;
5916 begin
5917         // \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é
5918         if GikoDM.AllItemAction.Checked then
5919                 GikoDM.AllItemAction.Checked := False;
5920         if GikoDM.LogItemAction.Checked then
5921                 GikoDM.LogItemAction.Checked := False;
5922         if GikoDM.NewItemAction.Checked then
5923                 GikoDM.NewItemaction.Checked := False;
5924         if GikoDM.LiveItemAction.Checked then
5925                 GikoDM.LiveItemAction.Checked := False;
5926         if GikoDM.ArchiveItemAction.Checked then
5927                 GikoDM.ArchiveItemAction.Checked := False;
5928
5929 end;
5930
5931 procedure TGikoForm.SelectComboBoxExit(Sender: TObject);
5932 begin
5933
5934         ModifySelectList;
5935
5936         if Length( SelectComboBox.Text ) = 0 then
5937         begin
5938                 SelectComboBox.Text := GikoDataModule.SELECTCOMBOBOX_NAME;
5939                 SelectComboBox.Color := GikoDataModule.SELECTCOMBOBOX_COLOR;
5940         end;
5941
5942 end;
5943
5944 // \8di\82è\8d\9e\82Ý\8c\9f\8dõ\82Ì\97\9a\97ð\8dX\90V
5945 procedure TGikoForm.ModifySelectList;
5946 var
5947         idx : Integer;
5948         oldText : string;
5949 begin
5950
5951         try
5952                 if not SelectComboBoxPanel.Visible then
5953                         exit;
5954
5955                 if Length( SelectComboBox.Text ) > 0 then
5956                 begin
5957                         oldText := SelectComboBox.Text;
5958                         idx := GikoSys.Setting.SelectTextList.IndexOf( oldText );
5959                         if idx <> -1 then
5960                                 GikoSys.Setting.SelectTextList.Delete( idx );
5961                         idx := SelectComboBox.Items.IndexOf( oldText );
5962                         if idx <> -1 then
5963                                 SelectComboBox.Items.Delete( idx );
5964                         GikoSys.Setting.SelectTextList.Insert( 0, oldText );
5965                         SelectComboBox.Items.Insert( 0, oldText );
5966                         SelectComboBox.Text := oldText;
5967                 end;
5968         except
5969         end;
5970
5971 end;
5972
5973
5974 procedure TGikoForm.SelectComboBoxSplitterMouseMove(Sender: TObject;
5975         Shift: TShiftState; X, Y: Integer);
5976 var
5977         pos                             : TPoint;
5978         w                                       : Integer;
5979 begin
5980         If (SelectComboBoxPanel.Visible) and (IsDraggingSelectComboBox) Then begin
5981                 pos.X := X;
5982                 pos.Y := Y;
5983                 pos := SelectComboBoxSplitter.ClientToScreen( pos );
5984                 //w := SelectComboBox.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5985                 w := SelectComboBoxPanel.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5986
5987                 If w <= 50 Then Begin
5988                         // \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­
5989                         // \81u\8e~\82Ü\82Á\82½(50pixel)\88Ê\92u\81v\82É\82È\82é\82æ\82¤\82É
5990                         pos.X := pos.X + (50 - w);
5991
5992                         // \8f¬\82³\82­\82È\82è\82·\82¬\82È\82¢\82æ\82¤\82É
5993                         w := 50;
5994                 End;
5995
5996                 // \83`\83\89\82Â\82«\8cy\8c¸\82Ì\88×
5997                 //If SelectComboBox.Width <> w Then Begin
5998                 If SelectComboBoxPanel.Width <> w Then Begin
5999                         SelectComboBoxPanel.Width := w;
6000                         SelectComboBox.Width := SelectComboBoxPanel.Width - SelectComboBoxSplitter.Width;
6001                         GikoSys.Setting.SelectComboBoxWidth := w;
6002                         DraggingSelectComboBoxPosition := pos;
6003
6004                         // \83V\83F\83u\83\8d\83\93\88Ê\92u\82ª\95Ï\82í\82é\82Ì\82Å BandInfo \82Ì\8dÄ\90Ý\92è
6005                         ResetBandInfo( ListCoolBar, ListToolBar );
6006                 End;
6007         End;
6008
6009 end;
6010
6011 procedure TGikoForm.SelectComboBoxSplitterMouseDown(Sender: TObject;
6012         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6013 var
6014         pos : TPoint;
6015 begin
6016         IsDraggingSelectComboBox := True;
6017         pos.X := X;
6018         pos.Y := Y;
6019         DraggingSelectComboBoxPosition := SelectComboBoxSplitter.ClientToScreen( pos );
6020
6021 end;
6022
6023 procedure TGikoForm.SelectComboBoxSplitterMouseUp(Sender: TObject;
6024         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6025 begin
6026         IsDraggingSelectComboBox := False;
6027
6028 end;
6029
6030 procedure TGikoForm.StatusBarResize(Sender: TObject);
6031 begin
6032         StatusBar.Panels[1].Width := StatusBar.Width -
6033                                         StatusBar.Panels[0].Width -
6034                                         StatusBar.Panels[THREADSIZE_PANEL].Width -
6035                                         StatusBar.Panels[NGWORDNAME_PANEL].Width;
6036 end;
6037 procedure TGikoForm.SelectComboBoxEnter(Sender: TObject);
6038 begin
6039
6040         if (Length( SelectComboBox.Text ) = 0) or
6041                 (SelectComboBox.Text = GikoDataModule.SELECTCOMBOBOX_NAME) then
6042         begin
6043                 SelectComboBox.Text := '';
6044                 SelectComboBox.Color := clWindow;
6045         end;
6046
6047 end;
6048
6049 procedure TGikoForm.FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
6050 begin
6051
6052         if (SenderNode = nil) or (SourceNode = nil) or (SenderNode = SourceNode) then
6053                 Exit;
6054
6055         if TObject(SenderNode.Data) is TFavoriteFolder then
6056                 SourceNode.MoveTo(SenderNode, naAddChild)
6057         else
6058                 SourceNode.MoveTo(SenderNode, naInsert);
6059
6060 end;
6061
6062 procedure TGikoForm.FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
6063 var
6064         Node: TTreeNode;
6065         FavNode: TTreeNode;
6066         FavoBoardItem: TFavoriteBoardItem;
6067         FavoThreadItem: TFavoriteThreadItem;
6068         Board: TBoard;
6069         ThreadItem: TThreadItem;
6070 begin
6071
6072         if (SenderNode = nil) or (Source = nil) then
6073                 Exit;
6074
6075         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
6076                 FavNode := SenderNode.Parent
6077         else
6078                 FavNode := SenderNode;
6079
6080         Node := nil;
6081
6082         if Source is TBoard then begin
6083                 Board := TBoard( Source );
6084                 FavoBoardItem                           := TFavoriteBoardItem.CreateWithItem( Board );
6085                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, FavoBoardItem);
6086                 Node.ImageIndex := 15;
6087                 Node.SelectedIndex := 15;
6088         end else if Source is TFavoriteBoardItem then begin
6089                 FavoBoardItem := TFavoriteBoardItem( Source );
6090                 Board := FavoBoardItem.Item;
6091                 if Board <> nil then
6092                         if not Board.IsThreadDatRead then
6093                                 GikoSys.ReadSubjectFile(Board);
6094                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, Source);
6095                 Node.ImageIndex := 15;
6096                 Node.SelectedIndex := 15;
6097         end else if Source is TThreadItem then begin
6098                 ThreadItem := TThreadItem( Source );
6099                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
6100                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
6101                 Node.ImageIndex := 16;
6102                 Node.SelectedIndex := 16;
6103         end else if Source is TBrowserRecord then begin
6104                 ThreadItem := TBrowserRecord( Source ).Thread;
6105                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
6106                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
6107                 Node.ImageIndex := 16;
6108                 Node.SelectedIndex := 16;
6109         end else if Source is TFavoriteThreadItem then begin
6110                 FavoThreadItem := TFavoriteThreadItem( Source );
6111                 ThreadItem := FavoThreadItem.Item;
6112                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, Source);
6113                 Node.ImageIndex := 16;
6114                 Node.SelectedIndex := 16;
6115         end;
6116
6117         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
6118                 if Node <> nil then
6119                         FavoriteMoveTo( SenderNode, Node );
6120
6121 end;
6122
6123 procedure TGikoForm.FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
6124 var
6125         idx: Integer;
6126         SourceNode: TTreeNode;
6127         LinkToolButton: TLinkToolButton;
6128 begin
6129
6130         if SenderNode = nil then
6131                 Exit;
6132
6133         if not (TObject( SenderNode.Data ) is TFavoriteFolder) then
6134                 if FDropSpaceNode <> nil then
6135                         SenderNode := FDropSpaceNode;
6136
6137         if Source = FavoriteTreeView then begin
6138                 SourceNode := FavoriteTreeView.Selected;
6139                 FavoriteMoveTo( SenderNode, SourceNode );
6140         end else if Source is TLinkToolButton then begin
6141                 LinkToolButton := TLinkToolButton( Source );
6142                 SourceNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
6143                 FavoriteMoveTo( SenderNode, SourceNode );
6144         end else if Source = BrowserTab then begin
6145                 idx := BrowserTab.TabIndex;
6146                 FavoriteAddTo( SenderNode, BrowserTab.Tabs.Objects[idx] );
6147         end else if Source = ListView then begin
6148                 FavoriteAddTo( SenderNode, ListView.Selected.Data );
6149         end else if Source = TreeView then begin
6150                 FavoriteAddTo( SenderNode, TreeView.Selected.Data );
6151         end;
6152 end;
6153
6154 procedure TGikoForm.FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
6155         Y: Integer);
6156 var
6157         SenderNode: TTreeNode;
6158 begin
6159
6160         SenderNode := FavoriteTreeView.GetNodeAt(X, Y);
6161         if SenderNode <> nil then begin
6162                 FavoriteDragDrop( SenderNode, Source );
6163         end;
6164
6165         //\8bó\94\92\8d\80\96Ú\82ª\82¢\82½\82ç\8dí\8f\9c\82·\82é
6166         if FDropSpaceNode <> nil then begin
6167                 try
6168                         FDropSpaceNode.Delete;
6169                 finally
6170                         FDropSpaceNode := nil;
6171                 end;
6172         end;
6173         //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
6174         FavoriteDM.Modified := true;
6175
6176         SetLinkBar;
6177
6178 end;
6179
6180 procedure TGikoForm.FavoriteTreeViewEdited(Sender: TObject;
6181         Node: TTreeNode; var S: String);
6182 begin
6183         //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
6184         FavoriteDM.Modified := true;
6185
6186         FavoriteTreeView.ReadOnly := True;
6187         SetLinkBar;
6188
6189 end;
6190
6191 procedure TGikoForm.FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
6192         Shift: TShiftState);
6193 begin
6194         if not TTreeView(Sender).IsEditing then begin
6195                 Case Key of
6196                 VK_F2:
6197                         begin
6198                                 FClickNode := FavoriteTreeView.Selected;
6199                                 GikoDM.FavoriteTreeViewRenameActionExecute( Sender );
6200                         end;
6201                 VK_DELETE:
6202                         begin
6203                                 FClickNode := FavoriteTreeView.Selected;
6204                                 GikoDM.FavoriteTreeViewDeleteActionExecute( Sender );
6205                         end;
6206                 VK_RETURN:
6207                         begin
6208                         FavoriteClick( FavoriteTreeView.Selected );
6209                         FavoriteTreeView.Selected.Expanded := not FavoriteTreeView.Selected.Expanded;
6210                         end;
6211                 VK_SPACE:
6212                         begin
6213                         FClickNode := FavoriteTreeView.Selected;
6214                         GikoDM.FavoriteTreeViewReloadActionExecute( Sender );
6215                         end;
6216                 end;
6217         end else begin
6218                 //\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·
6219                 if Key = VK_ESCAPE then begin
6220                         if (TTreeView(Sender).Selected <> nil) then begin
6221                                 TTreeView(Sender).Selected.Text := FOrigenCaption;
6222                         end;
6223                         TTreeView(Sender).Selected.Focused := False;
6224                 end;
6225         end;
6226
6227 end;
6228
6229 procedure TGikoForm.FavoriteTreePopupMenuPopup(Sender: TObject);
6230 var
6231         i: Integer;
6232         LinkToolButton: TLinkToolButton;
6233 begin
6234
6235         if FavoriteTreePopupMenu.PopupComponent = FavoriteTreeView then begin
6236         
6237                 FClickNode := FavoriteTreeView.Selected;
6238
6239         end else if FavoriteTreePopupMenu.PopupComponent is TLinkToolButton then begin
6240
6241                 LinkToolButton := TLinkToolButton( FavoriteTreePopupMenu.PopupComponent );
6242                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6243                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6244                                 FClickNode := FavoriteTreeView.Items[i];
6245                                 Break;
6246                         end;
6247                 end;
6248                 for i := 0 to FClickNode.Count - 1 do begin
6249                         if FClickNode.Item[i].Data = LinkToolButton.Data then begin
6250                                 FClickNode := FClickNode.Item[i];
6251                                 Break;
6252                         end;
6253                 end;
6254
6255         end;
6256
6257         if FClickNode = nil then begin
6258                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6259                 FavoriteTreeDeletePopupMenu.Visible := False;
6260                 FavoriteTreeRenamePopupMenu.Visible := False;
6261                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6262                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6263                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6264                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6265                 FavoriteTreeReloadPopupMenu.Visible := False;
6266                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6267                 FavoriteTreeItemNameCopyPopupMenu.Visible := False;
6268         end else if FClickNode.IsFirstNode then begin
6269                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6270                 FavoriteTreeDeletePopupMenu.Visible := False;
6271                 FavoriteTreeRenamePopupMenu.Visible := False;
6272                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6273                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6274                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6275                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6276                 FavoriteTreeReloadPopupMenu.Visible := False;
6277                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6278                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6279         end else if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
6280                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6281                 FavoriteTreeDeletePopupMenu.Visible := True;
6282                 FavoriteTreeRenamePopupMenu.Visible := False;
6283                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6284                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6285                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6286                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6287                 FavoriteTreeReloadPopupMenu.Visible := False;
6288                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6289                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6290         end else if TObject(FClickNode.Data) is TFavoriteFolder then begin
6291                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6292                 FavoriteTreeDeletePopupMenu.Visible := True;
6293                 FavoriteTreeRenamePopupMenu.Visible := True;
6294                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6295                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6296                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6297                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6298                 FavoriteTreeReloadPopupMenu.Visible := False;
6299                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6300                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6301         end else if TObject(FClickNode.Data) is TFavoriteThreadItem then begin
6302                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6303                 FavoriteTreeDeletePopupMenu.Visible := True;
6304                 FavoriteTreeRenamePopupMenu.Visible := True;
6305                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6306                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6307                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6308                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6309                 FavoriteTreeReloadPopupMenu.Visible := True;
6310                 FavoriteTreeLogDeletePopupMenu.Visible := True;
6311                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6312         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
6313                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6314                 FavoriteTreeDeletePopupMenu.Visible := True;
6315                 FavoriteTreeRenamePopupMenu.Visible := True;
6316                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6317                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6318                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6319                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6320                 FavoriteTreeReloadPopupMenu.Visible := True;
6321                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6322                 FavoriteTreeItemNameCopyPopupMenu.Visible := True;
6323         end else begin
6324                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6325                 FavoriteTreeDeletePopupMenu.Visible := False;
6326                 FavoriteTreeRenamePopupMenu.Visible := False;
6327                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6328                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6329                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6330                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6331                 FavoriteTreeReloadPopupMenu.Visible := False;
6332                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6333                 FavoriteTreeItemNameCopyPopupMenu.Visible := False;
6334         end;
6335
6336 end;
6337
6338 procedure TGikoForm.FavoriteBrowseFolder( node: TTreeNode );
6339 var
6340         i: Integer;
6341 begin
6342
6343         if not (TObject(node.Data) is TFavoriteFolder) then
6344                 exit;
6345
6346         for i := 0 to node.Count - 1 do
6347         begin
6348                 if TObject(node.Item[i].Data) is TFavoriteFolder then
6349                         FavoriteBrowseFolder( node.Item[i] )
6350                 else if TObject(node.Item[i].Data) is TFavoriteThreadItem then
6351                         FavoriteClick( node.Item[i], False );
6352         end;
6353
6354 end;
6355 function TGikoForm.TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
6356 var
6357         Found: TTreeNode;
6358         i: Integer;
6359 begin
6360
6361         for i := 0 to Node.Count - 1 do begin
6362                 if Node.Item[i].Data = FindPointer then begin
6363                         Result := Node.Item[i];
6364                         Exit;
6365                 end else if Node.Item[i].Count > 0 then begin
6366                         Found := TreeNodeDataFind( Node.Item[i], FindPointer );
6367                         if Found <> nil then begin
6368                                 Result := Found;
6369                                 Exit;
6370                         end;
6371                 end;
6372         end;
6373
6374         Result := nil;
6375
6376 end;
6377
6378 procedure TGikoForm.LinkToolBarDragDrop(Sender, Source: TObject; X,
6379         Y: Integer);
6380 var
6381         i: Integer;
6382         SenderNode: TTreeNode;
6383 begin
6384
6385         SenderNode := nil;
6386         for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6387                 if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6388                         SenderNode := FavoriteTreeView.Items[i];
6389                         Break;
6390                 end;
6391         end;
6392         SenderNode.Selected := False;
6393         
6394         FavoriteDragDrop( SenderNode, Source );
6395
6396         SetLinkBar;
6397 end;
6398
6399 procedure TGikoForm.BrowserTabMouseUp(Sender: TObject;
6400         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6401 begin
6402         if FDragWFirst <> true then begin
6403                 FDragWFirst := false;
6404 {
6405         end else if (abs( X - FMouseDownPos.X ) < Mouse.DragThreshold)
6406         and (abs( Y - FMouseDownPos.Y ) < Mouse.DragThreshold) then begin
6407 (*}
6408         end else begin
6409 //*)
6410                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6411                         if GikoSys.Setting.ListWidthState = glsMin then begin
6412                                 GikoDM.BrowserMaxAndFocusAction.Execute;
6413                         end;
6414                 end else begin
6415                         if GikoSys.Setting.ListHeightState = glsMin then begin
6416                                 GikoDM.BrowserMaxAndFocusAction.Execute;
6417                         end;
6418                 end;
6419         end;
6420 end;
6421
6422 procedure TGikoForm.LinkToolBarDragOver(Sender, Source: TObject; X,
6423         Y: Integer; State: TDragState; var Accept: Boolean);
6424 begin
6425
6426         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
6427
6428 end;
6429
6430 procedure TGikoForm.FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
6431         Y: Integer);
6432 begin
6433
6434         if FDropSpaceNode <> nil then begin
6435                 try
6436                         FDropSpaceNode.Delete;
6437                 finally
6438                         FDropSpaceNode := nil;
6439                 end;
6440                 //\8dX\90V\82µ\82½\82±\82Æ\82ð\8b³\82¦\82é
6441                 FavoriteDM.Modified := true;
6442                 SetLinkBar;
6443         end;
6444
6445 end;
6446
6447 procedure TGikoForm.ListCoolBarContextPopup(Sender: TObject;
6448         MousePos: TPoint; var Handled: Boolean);
6449 begin
6450
6451         FToolBarSettingSender := tssList;
6452         MousePos := ListCoolBar.ClientToScreen( MousePos );
6453         MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
6454
6455 end;
6456
6457 procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
6458         MousePos: TPoint; var Handled: Boolean);
6459 begin
6460
6461         FToolBarSettingSender := tssMain;
6462         MousePos := MainCoolBar.ClientToScreen( MousePos );
6463         MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
6464
6465 end;
6466
6467 procedure TGikoForm.BrowserCoolBarContextPopup(Sender: TObject;
6468         MousePos: TPoint; var Handled: Boolean);
6469 begin
6470
6471         FToolBarSettingSender := tssBrowser;
6472         MousePos := BrowserCoolBar.ClientToScreen( MousePos );
6473         MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
6474
6475 end;
6476 procedure TGikoForm.SetListViewBackGroundColor(value: TColor);
6477 begin
6478         if FListViewBackGroundColor <> value then begin
6479                 FListViewBackGroundColor := value;
6480                 ListView.Color := FListViewBackGroundColor;
6481         end;
6482 end;
6483 procedure TGikoForm.FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
6484 var
6485         threadItem      : TThreadItem;
6486         boardItem               : TBoard;
6487 begin
6488
6489         if FClickNode = nil then Exit;
6490
6491         if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
6492
6493                 threadItem := TFavoriteThreadItem( FClickNode.Data ).Item;
6494                 if threadItem = nil then
6495                         Exit;
6496                 GikoSys.OpenBrowser( threadItem.ParentBoard.URL, gbtAuto );
6497
6498         end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin
6499
6500                 boardItem := TFavoriteBoardItem( FClickNode.Data ).Item;
6501                 if boardItem = nil then
6502                         Exit;
6503                 GikoSys.OpenBrowser( boardItem.URL, gbtAuto );
6504
6505         end;
6506
6507 end;
6508
6509 procedure TGikoForm.BrowserTabContextPopup(Sender: TObject;
6510         MousePos: TPoint; var Handled: Boolean);
6511 var
6512         idx : Integer;
6513 begin
6514                 idx := BrowserTab.IndexOfTabAt(MousePos.X, MousePos.Y);
6515                 if BrowserTab.TabIndex <> idx then begin
6516                 BrowserTab.TabIndex := idx;
6517                         BrowserTab.OnChange(nil);
6518                 end;
6519 end;
6520
6521 procedure TGikoForm.KonoresCopy(Number: Integer; ReplaceTag : Boolean);
6522 var
6523         ThreadItem: TThreadItem;
6524         tmp: string;
6525         FileName: string;
6526         Res: TResRec;
6527         Header: string;
6528         Body: string;
6529         boardPlugIn : TBoardPlugIn;
6530 begin
6531         if Number = 0 then Exit;
6532         ThreadItem := GetActiveContent;
6533
6534         if ThreadItem <> nil then begin
6535                 //if ThreadItem.IsBoardPlugInAvailable then begin
6536         if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6537                         //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
6538                         //boardPlugIn           := ThreadItem.BoardPlugIn;
6539             boardPlugIn         := ThreadItem.ParentBoard.BoardPlugIn;
6540
6541                         // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
6542                         // \95\8e\9a\83R\81[\83h\82Í\83v\83\89\83O\83C\83\93\82É\94C\82¹\82é
6543                         //\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
6544                         tmp := boardPlugIn.GetDat( DWORD( threadItem ), Number );
6545                 end else begin
6546       FileName := ThreadItem.FilePath;
6547       tmp := GikoSys.ReadThreadFile(FileName, Number);
6548                 end;
6549                 if tmp <> '' then begin
6550                         THTMLCreate.DivideStrLine(tmp, @Res);
6551
6552                         Header := IntToStr(Number) + ' \81F' + Res.FName + ' \81F' + Res.FDateTime + #13#10;
6553                         if ReplaceTag then begin
6554                                 Header := CustomStringReplace(Header, '</b>', '',true);
6555                                 Header := CustomStringReplace(Header, '<b>', '',true);
6556                                 Header := CustomStringReplace(Header, '<br>', '',true);
6557                                 Header := DeleteFontTag(Header);
6558                         end;
6559                         //if ThreadItem.IsBoardPlugInAvailable then begin
6560             if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6561                                 Body := CustomStringReplace(Res.FBody, '<br>', #13#10,true);
6562                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6563                         end else begin
6564                                 Body := CustomStringReplace(Res.FBody, ' <br> ', #13#10,true);
6565                                 Body := CustomStringReplace(Body, ' <br>', #13#10,true);
6566                                 Body := CustomStringReplace(Body, '<br> ', #13#10,true);
6567                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6568
6569                         end;
6570                         Body := CustomStringReplace(Body, '</a>', '',true);
6571
6572                         Body := HTMLCreater.DeleteLink(Body);
6573                         if ReplaceTag then begin
6574                                 Body := CustomStringReplace(Body, '&lt;', '<');
6575                                 Body := CustomStringReplace(Body, '&gt;', '>');
6576                                 Body := CustomStringReplace(Body, '&quot;', '"');
6577                                 Body := CustomStringReplace(Body, '&amp;', '&');
6578                                 //Body := CustomStringReplace(Body, '&nbsp;', ' ');
6579                         end;
6580
6581                         Header := Header + Body;
6582
6583                         Clipboard.SetTextBuf( PChar(Header) );
6584                 end;
6585         end;
6586 end;
6587
6588
6589 procedure TGikoForm.BrowserTabPopupMenuPopup(Sender: TObject);
6590 begin
6591         AddRoundNameMenu(dummy1);
6592 end;
6593
6594 procedure TGikoForm.FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
6595 begin
6596         FavoriteDM.URLReplace(oldURLs, newURLs);
6597 end;
6598
6599 procedure TGikoForm.RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
6600 begin
6601         RoundList.URLReplace(oldURLs, newURLs);
6602 end;
6603
6604 procedure TGikoForm.TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
6605 const
6606         Filename = 'tab.sav';
6607         bFilename = '~tab.sav';
6608 var
6609         i, j: Integer;
6610         tempString: string;
6611         tmpURL: string;
6612         oldHost: string;
6613         oldBoardName: string;
6614         newHost: string;
6615         newBoardName: string;
6616         TabList: TStringList;
6617 begin
6618
6619         if oldURLs.Count <> newURLs.Count then begin
6620                 Exit;
6621         end;
6622         if FileExists(GikoSys.GetAppDir + 'tab.sav') then begin
6623                 TabList := TStringList.Create;
6624                 try
6625                         TabList.LoadFromFile(GikoSys.GetAppDir + Filename);
6626
6627                         //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
6628                         //\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
6629                         for i := 0 to oldURLs.Count - 1 do begin
6630                                         tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
6631                                         oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6632                                         oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6633                                         tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
6634                                         newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6635                                         newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6636
6637                                         for j := 0 to TabList.Count - 1 do begin
6638                                                         tempString := TabList[j];
6639                                                         if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
6640                                                                 tempString := StringReplace(tempString, oldHost, newHost,[]);
6641                                                                 TabList[j] := tempString;
6642                                                         end;
6643                                         end;
6644                         end;
6645                         //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
6646
6647                         if FileExists( GikoSys.GetAppDir + Filename) then begin
6648                                 if FileExists( GikoSys.GetAppDir + bFilename) then
6649                                         DeleteFile(GikoSys.GetAppDir + bFilename);
6650
6651                                 //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
6652                                 RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
6653                         end;
6654
6655                         TabList.SaveToFile(GikoSys.GetAppDir + Filename);
6656                 finally
6657                         TabList.Free;
6658                 end;
6659         end;
6660
6661 end;
6662
6663 /// \8dÅ\8f¬\89»\82³\82ê\82é
6664 procedure TGikoForm.OnMinimize;
6665 begin
6666         if FActiveContent <> nil then begin
6667                 FIsMinimize := mtMinimizing;
6668                 FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
6669         end;
6670 end;
6671
6672 /// \8dÅ\8f¬\89»\82³\82ê\82½ (OnResized \82©\82ç\8cÄ\82Î\82ê\82é)
6673 procedure TGikoForm.OnMinimized;
6674 begin
6675         FIsMinimize := mtMinimized;
6676 end;
6677
6678
6679 procedure TGikoForm.BrowserTabResize(Sender: TObject);
6680 begin
6681         CoolBarResized( Sender, BrowserCoolBar );
6682 end;
6683
6684 // *************************************************************************
6685 // ExternalBoardPlugInMain
6686 // \83v\83\89\83O\83C\83\93\83\81\83j\83\85\81[\82Ì\8d\80\96Ú\82ª\8eÀ\8ds\82³\82ê\82½
6687 // *************************************************************************
6688 procedure TGikoForm.OnPlugInMenuItem( Sender : TObject );
6689 var
6690         item                            : TMenuItem;
6691         boardPlugIn     : TBoardPlugIn;
6692 begin
6693
6694         if not (Sender is TMenuItem) then
6695                 Exit;
6696
6697         item := TMenuItem( Sender );
6698         if not Assigned( Pointer( item.Tag ) ) then
6699                 Exit;
6700
6701         // \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·
6702         boardPlugIn := TBoardPlugIn( item.Tag );
6703         boardPlugIn.PlugInMenu( item.Handle );
6704
6705 end;
6706 // TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
6707 procedure TGikoForm.TreeClick( Node : TTreeNode );
6708 begin
6709
6710         if Node = nil then
6711                 Exit;
6712
6713         if FTreeType = gttHistory then begin
6714                 if Node <> nil then
6715                         if TObject( Node.Data ) is TFavoriteThreadItem then
6716                                 if GetActiveContent <> TFavoriteThreadItem( Node.Data ).Item then
6717                                         FavoriteClick( Node );
6718                 Exit;
6719         end;
6720     //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\82Ì\82Æ\93¯\82\82È\82ç\8dÄ\95`\89æ\82µ\82È\82¢
6721         if ActiveList = Node.Data then
6722                 Exit;
6723
6724         ActiveListColumnSave;
6725
6726         if TObject(Node.Data) is TBBS then begin
6727                 SetActiveList(Node.data);
6728         end else if TObject(Node.Data) is TCategory then begin
6729                 SetActiveList(Node.data);
6730         end else if TObject(Node.Data) is TBoard then begin
6731                 if not TBoard(Node.Data).IsThreadDatRead then begin
6732                         Screen.Cursor := crHourGlass;
6733                         try
6734                 if not TBoard(Node.Data).IsThreadDatRead then
6735                                         GikoSys.ReadSubjectFile(Node.Data);
6736                         finally
6737                                 Screen.Cursor := crDefault;
6738                         end;
6739                 end;
6740                 Sort.SetSortDate(Now());
6741                 SetActiveList(Node.data);
6742         end;
6743
6744         if TObject( Node.Data ) is TBoard then begin // not TCategory
6745                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6746                         if GikoSys.Setting.ListWidthState = glsMax then begin
6747                                 GikoDM.BrowserMinAction.Execute;
6748                                 if GikoForm.Visible then
6749                                         ListView.SetFocus;
6750                         end;
6751                 end else begin
6752                         if GikoSys.Setting.ListHeightState = glsMax then begin
6753                                 GikoDM.BrowserMinAction.Execute;
6754                                 if GikoForm.Visible then
6755                                         ListView.SetFocus;
6756                         end;
6757                 end;
6758         end;
6759
6760 end;
6761
6762 // TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
6763 procedure TGikoForm.TreeDoubleClick( Node : TTreeNode );
6764 var
6765         Board                           : TBoard;
6766         ThreadItem      : TThreadItem;
6767         shiftDown       : Boolean;
6768 begin
6769
6770         if Node = nil then Exit;
6771
6772         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
6773
6774         if FTreeType = gtt2ch then begin
6775                 if not (TObject(Node.Data) is TBoard) then Exit;
6776                 Board := TBoard(Node.Data);
6777                 DownloadList(Board, shiftDown);
6778         end else if FTreeType = gttHistory then begin
6779                 if not (TObject(Node.Data) is TFavoriteThreadItem) then Exit;
6780                 ThreadItem := TFavoriteThreadItem(Node.Data).Item;
6781                 DownloadContent(ThreadItem, shiftDown);
6782         end;
6783
6784 end;
6785 // *************************************************************************
6786 //! \83c\83\8a\81[\83r\83\85\81[\82ÌKeyDown\83C\83x\83\93\83g
6787 // *************************************************************************
6788 procedure TGikoForm.TreeViewKeyDown(Sender: TObject; var Key: Word;
6789         Shift: TShiftState);
6790 begin
6791         if Key = VK_BACK then begin
6792 //              UpFolderButtonClick(Sender);
6793         end else if Key = VK_SPACE then begin
6794                 TreeDoubleClick( TreeView.Selected );
6795         end else if Key = VK_RETURN then begin
6796                 TreeClick( TreeView.Selected );
6797                 TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
6798         end;
6799 end;
6800 //! \82¨\8bC\82É\93ü\82è\82ÌMouseDown\83C\83x\83\93\83g
6801 procedure TGikoForm.FavoriteTreeViewMouseDown(Sender: TObject;
6802         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6803 var
6804         favItem                         : TTreeNode;
6805         favThreadItem   : TFavoriteThreadItem;
6806         rect: TRect;
6807 begin
6808         case Button of
6809         mbLeft:
6810                 begin
6811                         if not (ssAlt in Shift) and (FavoriteTreeView.Selected <> nil) and 
6812                                 (FavoriteTreeView.Selected = FavoriteTreeView.GetNodeAt(X, Y)) then begin
6813                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
6814                                 rect := FavoriteTreeView.Selected.DisplayRect(true);
6815                                 // \83A\83C\83R\83\93\95ª\8d\82É\82¸\82ç\82·
6816                                 if ((rect.Left - FavoriteTreeView.Indent <= X) and (rect.Right >= X)) and
6817                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
6818                                         if ssDouble in Shift then begin
6819                                                 FClickNode := FavoriteTreeView.Selected;
6820                                                 GikoDM.FavoriteTreeViewReloadActionExecute(Sender);
6821                                                 FClickNode := nil;
6822                                         end else begin
6823                                                 FavoriteClick(
6824                                                         TObject(FavoriteTreeView.Selected));
6825                                         end;
6826                                 end;
6827                         end;
6828                 end;
6829         mbMiddle:
6830                 begin
6831                         favItem := FavoriteTreeView.GetNodeAt( X, Y );
6832                         if favItem = nil then Exit;
6833
6834                         if TObject( favItem.Data ) is TFavoriteThreadItem then begin
6835                                 favThreadItem := TFavoriteThreadItem( favItem.Data );
6836                                 if favThreadItem.Item <> nil then
6837                                         InsertBrowserTab( favThreadItem.Item, False );
6838                         end;
6839                 end;
6840         end;
6841
6842 end;
6843
6844 procedure TGikoForm.MessagePanelResize(Sender: TObject);
6845 begin
6846
6847         if FIsIgnoreResize <> rtNone then
6848                 Exit;
6849
6850         if GikoSys.Setting.ListOrientation = gloVertical then begin
6851                 if GikoSys.Setting.ListHeightState = glsMin then begin
6852                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
6853                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
6854                 end;
6855         end;
6856
6857 end;
6858
6859 procedure TGikoForm.OnResized;
6860 var
6861         doc                                             : Variant;
6862 begin
6863
6864         FOldFormWidth := Width;
6865         FIsIgnoreResize := rtNone;
6866
6867         case FIsMinimize of
6868         mtMinimizing:
6869                 begin
6870                         // \8dÅ\8f¬\89»\92\86\82Å\82 \82é
6871                         PostMessage( Handle, USER_MINIMIZED, 0, 0 );
6872                 end;
6873
6874         mtMinimized:
6875                 begin
6876                         // \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)
6877                         if FActiveContent <> nil then begin
6878                                 doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
6879                                 doc.Body.ScrollTop := FActiveContent.Thread.ScrollTop;
6880                         end;
6881                         FIsMinimize := mtNone;
6882                 end;
6883         end;
6884
6885 end;
6886 // *************************************************************************
6887 //! \82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83}\83E\83X\83A\83b\83v\83C\83x\83\93\83g
6888 // *************************************************************************
6889 function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
6890 var
6891         p : TPoint;
6892         e: IHTMLElement;
6893         AID: string;
6894         stlist : TStringList;
6895         i, count, rc : Integer;
6896         body : String;
6897     limited : boolean;
6898 begin
6899   result := true;
6900   try
6901         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
6902                 FActiveContent.Browser.SetFocus;
6903                 try
6904                         GetCursorPos(p);
6905                         p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
6906                         p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
6907                         e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
6908                         if (Assigned(e)) then begin
6909                                 if (e.className = 'date') or (e.id = 'date') then begin
6910                                         AID := e.innerText;
6911                                         if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
6912                                                 AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
6913                         if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
6914                                 AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
6915                         end;
6916                                         end else begin
6917                                                 stlist := TStringList.Create;
6918                                                 try
6919                                                         stList.DelimitedText := AID;
6920                                                         AID := '';
6921                                                         for i := 0 to stList.Count - 1 do
6922                                                                 if Length(WideString(stList[i])) = 8 then begin
6923                                                                         if GikoSys.NotDateorTimeString(stList[i]) then begin
6924                                                                                 AID := stList[i];
6925                                                                                 break;
6926                                                                         end;
6927                                                                 end;
6928                                                 finally
6929                                                         stList.Free;
6930                                                 end;
6931                                         end;
6932                     count := GikoSys.GetSameIDResCount(AID, FActiveContent.Thread);
6933                     limited := false;
6934                     if count > 20 then begin
6935                         rc := GikoUtil.MsgBox(Handle,
6936                                 '20\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
6937                                 'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
6938                                                                 MB_YESNO or MB_ICONQUESTION);
6939                         limited := rc <> ID_YES;
6940                     end;
6941                                         body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
6942                                         FActiveContent.IDAnchorPopup(body);
6943                                 end;
6944                         end;
6945                 except
6946                 end;
6947   except
6948   end;
6949 end;
6950
6951 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
6952 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
6953 begin
6954         SelectTimer.Interval := 0;
6955         if not (ListView.Selected = nil) then
6956                 if( FActiveContent = nil) or
6957                                 (GetActiveContent <> TThreadItem(ListView.Selected.Data) ) then begin
6958                         ListClick;
6959                 end;
6960 end;
6961
6962 function TGikoForm.GetTabURLs(AStringList: TStringList) : Boolean;
6963 var
6964   rec : TBrowserRecord;
6965   i, bound : Integer;
6966 begin
6967         bound := BrowserTab.Tabs.Count -1;
6968         if bound = -1 then begin
6969                 Result := False;
6970                 Exit; //for\82É\94ò\82Î\82È\82¢\82Å\91\80\8dì\82ð\94²\82¯\82é
6971         end;
6972
6973         for i := 0 to bound do begin
6974                 try
6975                         rec := TBrowserRecord( BrowserTab.Tabs.Objects[ i ] );
6976                         if( rec <> nil) and (rec.Thread <> nil) then
6977                                 AStringList.Add( rec.Thread.URL );
6978                 except
6979                 end;
6980         end;
6981         Result := True;
6982 end;
6983
6984 function TGikoForm.SaveTabURLs : Boolean;
6985 const
6986         Filename = 'tab.sav';
6987         bFilename = '~tab.sav';
6988 var
6989         SaveStringList: TStringList;
6990 begin
6991         Result := false;
6992
6993         SaveStringList := TStringList.Create;
6994         try
6995                 if GetTabURLs(SaveStringList) then begin
6996                         try
6997                                 if FileExists( GikoSys.GetAppDir + Filename) then begin
6998                                         if FileExists( GikoSys.GetAppDir + bFilename) then
6999                                                 DeleteFile(GikoSys.GetAppDir + bFilename);
7000
7001                                         //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
7002                                         RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
7003                                 end;
7004                         except
7005                         end;
7006                         SaveStringList.SaveToFile(GikoSys.GetAppDir + Filename);
7007                         Result := true;
7008                 end;
7009         finally
7010                 SaveStringList.Free;
7011         end;
7012 end;
7013
7014 function TGikoForm.LoadTabURLs : Boolean;
7015 const
7016         TABFILE = 'tab.sav';
7017 var
7018         i, bound    : Integer;
7019         item        : TThreadItem;
7020         URLs                            : TStringList;
7021         GikoTab                 : TGikoTabAppend;
7022         fileName                : string;
7023 begin
7024
7025         fileName := ExtractFilePath(Application.ExeName) + TABFILE;
7026         URLs := TStringList.Create();
7027         GikoTab := GikoSys.Setting.BrowserTabAppend;
7028         try
7029                 try
7030                         Result := True;
7031                         if FileExists(fileName) then begin
7032                                 URLs.LoadFromFile(fileName);
7033                                 bound    := URLs.Count - 1;
7034                                 if bound > -1 then begin
7035                                         GikoSys.Setting.BrowserTabAppend := gtpLast;//TGikoTabAppend(1);
7036                                         for i := 0 to bound do begin
7037                                                 item := BBSsFindThreadFromURL( URLs[ i ] );
7038                                                 if item <> nil then
7039                                                         InsertBrowserTab( item, false );
7040                                         end;
7041                                         //\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Ñ
7042                                         if BrowserTab.Tabs.Count > 0 then begin
7043                         BrowserTab.OnChange(nil);
7044                                         end;
7045                                 end else
7046                                         Result := False;
7047                         end else
7048                                 Result := False;
7049                 except
7050                         on EFOpenError do begin
7051                                 ShowMessage('\83^\83u\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ');
7052                         end;
7053                 end;
7054         finally
7055                 GikoSys.Setting.BrowserTabAppend := GikoTab;
7056                 URLs.Free;
7057         end;
7058
7059 end;
7060
7061
7062 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
7063 procedure TGikoForm.ActiveListColumnSave;
7064 var
7065         ActivListObj    : TObject;
7066         i, id, idx              : Integer;
7067         BBSOrder                        : TGikoBBSColumnList;
7068         CategoryOrder   : TGikoCategoryColumnList;
7069         BoardOrder              : TGikoBoardColumnList;
7070 begin
7071
7072         ActivListObj := ActiveList;
7073         if ActivListObj is TBBS then begin
7074                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
7075                 BBSOrder := TGikoBBSColumnList.Create;
7076                 try
7077                         for i := 0 to ListView.Columns.Count - 1 do begin
7078                                 // \8f\87\8f\98\82Ì\8eæ\93¾
7079                                 idx := ListView.Column[ i ].Tag;
7080                                 id := Ord( GikoSys.Setting.BBSColumnOrder[ idx ] );
7081                                 BBSOrder.Add( TGikoBBSColumnID( id ) );
7082                                 // \95\9d\82Ì\95Û\91
7083                                 GikoSys.Setting.BBSColumnWidth[ id ] := ListView.Column[ i ].Width;
7084                         end;
7085                         for i := 0 to ListView.Columns.Count - 1 do
7086                                 // \8f\87\8f\98\82Ì\95Û\91
7087                                 GikoSys.Setting.BBSColumnOrder[ i ] := BBSOrder[ i ];
7088                 finally
7089                         BBSOrder.Free;
7090                 end;
7091         end else if ActivListObj is TCategory then begin
7092                 //===== \94Â\83\8a\83X\83g =====
7093                 CategoryOrder := TGikoCategoryColumnList.Create;
7094                 try
7095                         for i := 0 to ListView.Columns.Count - 1 do begin
7096                                 // \8f\87\8f\98\82Ì\8eæ\93¾
7097                                 idx := ListView.Column[ i ].Tag;
7098                                 id := Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] );
7099                                 CategoryOrder.Add( TGikoCategoryColumnID( id ) );
7100                                 // \95\9d\82Ì\95Û\91
7101                                 GikoSys.Setting.CategoryColumnWidth[ id ] := ListView.Column[ i ].Width;
7102                         end;
7103                         for i := 0 to ListView.Columns.Count - 1 do
7104                                 // \8f\87\8f\98\82Ì\95Û\91
7105                                 GikoSys.Setting.CategoryColumnOrder[ i ] := CategoryOrder[ i ];
7106                 finally
7107                         CategoryOrder.Free;
7108                 end;
7109         end else if ActivListObj is TBoard then begin
7110                 //===== \83X\83\8c\83\8a\83X\83g =====
7111                 BoardOrder := TGikoBoardColumnList.Create;
7112                 try
7113                         for i := 0 to ListView.Columns.Count - 1 do begin
7114                                 // \8f\87\8f\98\82Ì\8eæ\93¾
7115                                 idx := ListView.Column[ i ].Tag;
7116                                 id := Ord( GikoSys.Setting.BoardColumnOrder[ idx ] );
7117                                 BoardOrder.Add( TGikoBoardColumnID( id ) );
7118                                 // \95\9d\82Ì\95Û\91
7119                                 GikoSys.Setting.BoardColumnWidth[ id ] := ListView.Column[ i ].Width;
7120                         end;
7121                         for i := 0 to ListView.Columns.Count - 1 do
7122                                 // \8f\87\8f\98\82Ì\95Û\91
7123                                 GikoSys.Setting.BoardColumnOrder[ i ] := BoardOrder[ i ];
7124                 finally
7125                         BoardOrder.Free;
7126                 end;
7127         end;
7128
7129 end;
7130
7131 procedure TGikoForm.ListViewColumnRightClick(Sender: TObject;
7132         Column: TListColumn; Point: TPoint);
7133 var
7134         i, j    : Integer;
7135         item    : TMenuItem;
7136 begin
7137
7138         // \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82ð\83N\83\8a\83A
7139         for i := ListColumnPopupMenu.Items.Count - 1 downto 0 do
7140                 ListColumnPopupMenu.Items.Items[ i ].Free;
7141
7142         // \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¢)
7143         if TObject( FActiveList ) is TBBS then begin
7144
7145                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
7146                 for i := 1 to Length( GikoBBSColumnCaption ) - 1 do begin
7147                         item := TMenuItem.Create( ListColumnPopupMenu );
7148                         item.Caption := GikoBBSColumnCaption[ i ];
7149                         item.Tag := i;
7150                         item.OnClick := ListColumnPopupMenuOnClick;
7151                         for j := GikoSys.Setting.BBSColumnOrder.Count - 1 downto 0 do begin
7152                                 if GikoSys.Setting.BBSColumnOrder[ j ] = TGikoBBSColumnID( i ) then begin
7153                                         item.Checked := True;
7154                                         Break;
7155                                 end;
7156                         end;
7157                         ListColumnPopupMenu.Items.Add( item );
7158                 end;
7159
7160         end else if TObject( FActiveList ) is TCategory then begin
7161
7162                 //===== \94Â\83\8a\83X\83g =====
7163                 for i := 1 to Length( GikoCategoryColumnCaption ) - 1 do begin
7164                         item := TMenuItem.Create( ListColumnPopupMenu );
7165                         item.Caption := GikoCategoryColumnCaption[ i ];
7166                         item.Tag := i;
7167                         item.OnClick := ListColumnPopupMenuOnClick;
7168                         for j := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 0 do begin
7169                                 if GikoSys.Setting.CategoryColumnOrder[ j ] = TGikoCategoryColumnID( i ) then begin
7170                                         item.Checked := True;
7171                                         Break;
7172                                 end;
7173                         end;
7174                         ListColumnPopupMenu.Items.Add( item );
7175                 end;
7176
7177         end else if TObject( FActiveList ) is TBoard then begin
7178
7179                 //===== \83X\83\8c\83\8a\83X\83g =====
7180                 for i := 1 to Length( GikoBoardColumnCaption ) - 1 do begin
7181                         item := TMenuItem.Create( ListColumnPopupMenu );
7182                         item.Caption := GikoBoardColumnCaption[ i ];
7183                         item.Tag := i;
7184                         item.OnClick := ListColumnPopupMenuOnClick;
7185                         for j := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 0 do begin
7186                                 if GikoSys.Setting.BoardColumnOrder[ j ] = TGikoBoardColumnID( i ) then begin
7187                                         item.Checked := True;
7188                                         Break;
7189                                 end;
7190                         end;
7191                         ListColumnPopupMenu.Items.Add( item );
7192                 end;
7193
7194         end;
7195
7196         // \83\81\83j\83\85\81[\82Ì\95\\8e¦
7197         Point := ListView.ClientToScreen( Point );
7198         if ListColumnPopupMenu.Items.Count > 0 then
7199                 ListColumnPopupMenu.Popup( Point.X, Point.Y );
7200
7201 end;
7202
7203 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
7204 procedure       TGikoForm.ListColumnPopupMenuOnClick( Sender : TObject );
7205 var
7206         i                                       : Integer;
7207         orderList       : TList;
7208         item                    : TMenuItem;
7209 begin
7210
7211         if not (Sender is TMenuItem) then
7212                 Exit;
7213
7214         ActiveListColumnSave;
7215         item := TMenuItem( Sender );
7216
7217         if TObject( FActiveList ) is TBBS then
7218                 orderList := GikoSys.Setting.BBSColumnOrder
7219         else if TObject( FActiveList ) is TCategory then
7220                 orderList := GikoSys.Setting.CategoryColumnOrder
7221         else if TObject( FActiveList ) is TBoard then
7222                 orderList := GikoSys.Setting.BoardColumnOrder
7223         else
7224                 Exit;
7225
7226         if item.Checked then begin
7227                 // \83J\83\89\83\80\82Ì\8dí\8f\9c
7228                 for i := orderList.Count - 1 downto 0 do begin
7229                         if Integer( orderList[ i ] ) = item.Tag then begin
7230                                 orderList.Delete( i );
7231                                 Break;
7232                         end;
7233                 end;
7234         end else begin
7235                 // \83J\83\89\83\80\82Ì\92Ç\89Á
7236                 orderList.Add( Pointer( item.Tag ) );
7237         end;
7238
7239         SetActiveList( FActiveList );
7240
7241 end;
7242
7243 procedure TGikoForm.OnGestureStart(Sender: TObject);
7244 begin
7245 //
7246 end;
7247
7248 procedure TGikoForm.OnGestureMove(Sender: TObject);
7249 var
7250         s: string;
7251         Action: TAction;
7252         ActStr: string;
7253         P : TPoint;
7254 begin
7255         //\83}\83E\83X\88Ê\92u\82Ì\8eæ\93¾
7256         GetCursorPos(P);
7257         //\83R\83\93\83|\81[\83l\83\93\83g\96¼\8eæ\93¾
7258         s := MouseGesture.GetGestureStr;
7259         ActStr := '';
7260         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
7261         if Action <> nil then
7262                 ActStr := '\81i' + Action.Caption + '\81j';
7263         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
7264         StatusBar.Panels[1].Text := s;
7265 end;
7266
7267 procedure TGikoForm.OnGestureEnd(Sender: TObject);
7268 var
7269         s: string;
7270         Action: TAction;
7271 begin
7272         s := MouseGesture.GetGestureStr;
7273         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
7274         if Action <> nil then
7275                 Action.Execute;
7276         StatusBar.Panels[1].Text := '';
7277 end;
7278
7279 procedure TGikoForm.ListViewCustomDrawItem(Sender: TCustomListView;
7280   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
7281 var
7282         ThreadItem: TThreadItem;
7283 begin
7284         DefaultDraw := true;
7285         if TObject(Item.Data) is TThreadItem then begin
7286                 ThreadItem := TThreadItem(Item.Data);
7287                 if ( FUseOddResOddColor ) and ( ThreadItem.Count <> 0 ) and ( ThreadItem.AllResCount <> ThreadItem.Count) then begin
7288                         ListView.Canvas.Brush.Color := FOddColor;
7289                         //\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
7290                         if (GikoSys.Setting.UnFocusedBold) and
7291                          (Item.Selected) and (not ListView.Focused) then begin
7292                                 ListView.Canvas.Font.Style := [fsBold];
7293                         end;
7294                 end else begin
7295                         ListView.Canvas.Brush.Color := FListViewBackGroundColor;
7296                 end;
7297
7298                 if ThreadItem.UnRead then
7299                         ListView.Canvas.Font.Style := [fsBold];
7300         end;
7301
7302 end;
7303
7304 procedure TGikoForm.FormActivate(Sender: TObject);
7305 begin
7306         if GikoSys.Setting.GestureEnabled then begin
7307                 GikoSys.Setting.Gestures.ClearGesture;
7308                 GikoSys.Setting.Gestures.LoadGesture(
7309                         GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
7310                 MouseGesture.UnHook;
7311                 MouseGesture.OnGestureStart := OnGestureStart;
7312                 MouseGesture.OnGestureMove := OnGestureMove;
7313                 MouseGesture.OnGestureEnd := OnGestureEnd;
7314                 MouseGesture.SetHook(Handle);
7315         end else begin
7316                 //MouseGesture.UnHook;
7317                 MouseGesture.OnGestureStart := nil;
7318                 MouseGesture.OnGestureMove := nil;
7319                 MouseGesture.OnGestureEnd := nil;
7320         end;
7321 end;
7322
7323 procedure TGikoForm.BrowserPanelResize(Sender: TObject);
7324 begin
7325         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
7326                 MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
7327         end;
7328
7329 end;
7330 procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
7331 var
7332         coolSet                         : TCoolSet;
7333         toolbar                         : TToolBar;
7334         band                                    : TCoolBand;
7335         affectedBand    : TCoolBand;
7336         i                                                       : Integer;
7337 begin
7338         if (FOldFormWidth = Width) and not IsIconic( Handle ) and (FIsIgnoreResize = rtNone) then begin
7339                 FIsIgnoreResize := rtResizing;
7340                 PostMessage( Handle, USER_RESIZED, 0, 0 );
7341                 band := nil;
7342                 // \95Ï\8dX\82³\82ê\82½\83N\81[\83\8b\83o\81[\82Ì\92l\82ð\95Û\91
7343                 if CoolBar = MainCoolBar then begin
7344                         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
7345                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7346                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7347                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7348                                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
7349                         end;
7350                 end else if CoolBar = ListCoolBar then begin
7351                         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
7352                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7353                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7354                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7355                                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
7356                         end;
7357                 end else if CoolBar = BrowserCoolBar then begin
7358                         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
7359                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7360                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7361                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7362                                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
7363                         end;
7364                 end;
7365                 if not (Sender is TToolBar) or (CoolBar = nil) then
7366                         Exit;
7367                 toolbar := TToolBar( Sender );
7368                 // \95\9d\82Ì\95Ï\8dX\82³\82ê\82½\83o\83\93\83h\82ð\8c©\82Â\82¯\82é
7369                 affectedBand := nil;
7370                 for i := CoolBar.Bands.Count - 1 downto 0 do begin
7371                         if CoolBar.Bands[ i ].Control.Handle = toolbar.Handle then begin
7372                                 band    := CoolBar.Bands[ i ];
7373                                 if band.Break or (i = 0) then begin
7374                                         if i + 1 < CoolBar.Bands.Count then
7375                                                 if not CoolBar.Bands[ i + 1 ].Break then
7376                                                         affectedBand := CoolBar.Bands[ i + 1 ];
7377                                 end else begin
7378                                         if i > 0 then
7379                                                 affectedBand := CoolBar.Bands[ i - 1 ];
7380                                 end;
7381                                 Break;
7382                         end;
7383                 end;
7384                 // \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·
7385                 if CoolBar = MainCoolBar then begin
7386                         coolSet := GikoSys.Setting.MainCoolSet[ band.ID ];
7387                         coolSet.FCoolWidth := toolbar.Width + 25;
7388                         GikoSys.Setting.MainCoolSet[ band.ID ] := coolSet;
7389                         if affectedBand <> nil then begin
7390                                 coolSet := GikoSys.Setting.MainCoolSet[ affectedBand.ID ];
7391                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7392                                 GikoSys.Setting.MainCoolSet[ affectedBand.ID ] := coolSet;
7393                         end;
7394                 end else if CoolBar = ListCoolBar then begin
7395                         coolSet := GikoSys.Setting.ListCoolSet[ band.ID ];
7396                         coolSet.FCoolWidth := toolbar.Width + 25;
7397                         GikoSys.Setting.ListCoolSet[ band.ID ] := coolSet;
7398                         if affectedBand <> nil then begin
7399                                 coolSet := GikoSys.Setting.ListCoolSet[ affectedBand.ID ];
7400                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7401                                 GikoSys.Setting.ListCoolSet[ affectedBand.ID ] := coolSet;
7402                         end;
7403                 end else if CoolBar = BrowserCoolBar then begin
7404                         coolSet := GikoSys.Setting.BrowserCoolSet[ band.ID ];
7405                         coolSet.FCoolWidth := toolbar.Width + 25;
7406                         GikoSys.Setting.BrowserCoolSet[ band.ID ] := coolSet;
7407                         if affectedBand <> nil then begin
7408                                 coolSet := GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ];
7409                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7410                                 GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ] := coolSet;
7411                         end;
7412                 end;
7413         end;
7414 end;
7415
7416
7417 procedure TGikoForm.MenuToolBarResize(Sender: TObject);
7418 begin
7419         CoolBarResized( Sender, MainCoolBar );
7420 end;
7421
7422 procedure TGikoForm.ListToolBarResize(Sender: TObject);
7423 begin
7424         CoolBarResized( Sender, ListCoolBar );
7425 end;
7426
7427 procedure TGikoForm.BrowserToolBarResize(Sender: TObject);
7428 begin
7429         CoolBarResized( Sender, BrowserCoolBar );
7430 end;
7431
7432 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
7433 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
7434 var
7435         ThreadItem      : TThreadItem;
7436         ReadList                : TStringList;
7437         wordCount               : TWordCount;
7438 begin
7439         ThreadItem      := GetActiveContent;
7440         ReadList                := TStringList.Create;
7441         wordCount               := TWordCount.Create;
7442         try
7443                 ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7444 {$IFDEF SPAM_FILTER_ENABLED}
7445                 // \83X\83p\83\80\82É\90Ý\92è
7446                 ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7447                 GikoSys.SpamCountWord( ReadList[ ATag - 1 ], wordCount );
7448                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7449                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7450 {$ENDIF}
7451                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7452                 GikoSys.FAbon.AddIndividualAbon(Atag, Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7453         finally
7454                 wordCount.Free;
7455                 ReadList.Free;
7456         end;
7457         FActiveContent.Repaint := true;
7458         if ThreadItem <> nil then
7459                 InsertBrowserTab( ThreadItem, True );
7460 end;
7461
7462 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
7463 procedure TGikoForm.IndividualAbonID(Atype : Integer);
7464 var
7465         ThreadItem : TThreadItem;
7466         i, No : Integer;
7467         body : TStringList;
7468         ReadList                : TStringList;
7469         wordCount               : TWordCount;
7470 begin
7471         No := KokoPopupMenu.Tag;
7472         if No = 0 then Exit;
7473         ThreadItem := GetActiveContent;
7474         if ThreadItem = nil then Exit;
7475         body := TStringList.Create;
7476         try
7477                 GikoSys.GetSameIDRes(No, ThreadItem, body);
7478
7479                 ReadList                := TStringList.Create;
7480                 wordCount               := TWordCount.Create;
7481                 try
7482                         ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7483 {$IFDEF SPAM_FILTER_ENABLED}
7484                         // \83X\83p\83\80\82É\90Ý\92è
7485                         ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7486 {$ENDIF}
7487                         for i := 0 to body.Count - 1 do begin
7488 {$IFDEF SPAM_FILTER_ENABLED}
7489                                 GikoSys.SpamCountWord( ReadList[ i ], wordCount );
7490                                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7491                                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7492 {$ENDIF}
7493                                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7494                                 GikoSys.FAbon.AddIndividualAbon(StrToInt(body[i]), Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7495                         end;
7496                 finally
7497                         wordCount.Free;
7498                         ReadList.Free;
7499                 end;
7500                 FActiveContent.Repaint := true;
7501                 if ThreadItem <> nil then
7502                         InsertBrowserTab( ThreadItem, True );
7503         finally
7504                 body.Free;
7505         end;
7506
7507 end;
7508
7509 procedure TGikoForm.KokoPopupMenuPopup(Sender: TObject);
7510 var
7511         firstElement: IHTMLElement;
7512         document: IHTMLDocument2;
7513 begin
7514         document := FActiveContent.Browser.Document as IHTMLDocument2;
7515         if Assigned(document) then
7516                 firstElement := document.all.item('idSearch', 0) as IHTMLElement;
7517                 if Assigned(firstElement) then
7518                         if firstElement.style.visibility <> 'hidden' then
7519                                 firstElement.style.visibility := 'hidden';
7520
7521 end;
7522
7523 procedure TGikoForm.RepaintAllTabsBrowser();
7524 var
7525         i : Integer;
7526         ThreadItem: TThreadItem;
7527 begin
7528         for i := BrowserTab.Tabs.Count - 1 downto 0 do
7529                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
7530
7531         ThreadItem := GetActiveContent;
7532         if ThreadItem <> nil then
7533                 InsertBrowserTab( ThreadItem, True );
7534
7535 end;
7536
7537 //ListView\82Ì\91I\91ð\8fó\91Ô\82ð\89ð\8f\9c\82·\82é
7538 procedure TGikoForm.ListViewKeyUp(Sender: TObject; var Key: Word;
7539   Shift: TShiftState);
7540 begin
7541         //\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Ì
7542         //\96³\8cø\8e\9e\8aÔ\82ÌTimer\82Ì\8f\88\97\9d
7543         //\82Æ\82è\82 \82¦\82¸\81A\83^\83C\83}\81[\82ð\92â\8e~\82·\82é\81B
7544         SelectTimer.Interval := 0;
7545         if not (GikoSys.Setting.BrowserTabVisible) then begin
7546                 if (GetActiveList is TBoard) then begin
7547                         //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
7548                         if not ((ssShift in Shift) or (ssAlt in Shift) or (ssCtrl in Shift))  and
7549                                 (( Key = VK_LEFT) or (Key = VK_RIGHT) or
7550                                                 (Key = VK_UP) or (Key = VK_DOWN)) then
7551                                         SelectTimer.Interval := GikoSys.Setting.SelectInterval;
7552                 end;
7553         end;
7554 end;
7555 // *************************************************************************
7556 //! \82¨\8bC\82É\93ü\82è\82Ì\95Ò\8fW\8aJ\8en\83C\83x\83\93\83g
7557 // *************************************************************************
7558 procedure TGikoForm.FavoriteTreeViewEditing(Sender: TObject;
7559   Node: TTreeNode; var AllowEdit: Boolean);
7560 begin
7561         //\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ\82ð\88ê\8e\9e\95Û\91\82·\82é
7562         FOrigenCaption := Node.Text;
7563 end;
7564 // *************************************************************************
7565 //! Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
7566 // *************************************************************************
7567 function TGikoForm.GetMainForm(): TComponent;
7568 begin
7569         Result := Application.MainForm;
7570 end;
7571 // *************************************************************************
7572 //! \8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
7573 // *************************************************************************
7574 function TGikoForm.GetScreenCursor(): TCursor;
7575 begin
7576         Result := Screen.Cursor;
7577 end;
7578 // *************************************************************************
7579 //! \83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
7580 // *************************************************************************
7581 procedure TGikoForm.SetScreenCursor(Cursor : TCursor);
7582 begin
7583         if (Screen.Cursor <> Cursor) then
7584                 Screen.Cursor := Cursor;
7585 end;
7586 // *************************************************************************
7587 //! \83X\83N\83\8a\81[\83\93\8fã\82ÉEditorForm\82ª\82¢\82é\82©
7588 // *************************************************************************
7589 function TGikoForm.EditorFormExists(): boolean;
7590 var
7591         i : Integer;
7592 begin
7593         Result := false;
7594         //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\92T\82·
7595         for i := 0 to Screen.CustomFormCount - 1 do begin
7596                 if TObject(Screen.CustomForms[i]) is TEditorForm then begin
7597                         Result := true;
7598                         Break;
7599                 end;
7600         end;
7601 end;
7602 // *************************************************************************
7603 //! \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é
7604 // *************************************************************************
7605 procedure TGikoForm.AllEditroFormNameTextClearClear();
7606 var
7607         i : Integer;
7608 begin
7609         for i := 0 to Screen.CustomFormCount - 1 do begin
7610                 if TObject(Screen.CustomForms[i]) is TEditorForm then
7611                         TEditorForm(Screen.CustomForms[i]).NameComboBox.Items.Clear;
7612         end;
7613 end;
7614 // *************************************************************************
7615 //! \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é
7616 // *************************************************************************
7617 procedure TGikoForm.AllEditroFormMailTextClearClear();
7618 var
7619         i : Integer;
7620 begin
7621         for i := 0 to Screen.CustomFormCount - 1 do begin
7622                 if TObject(Screen.CustomForms[i]) is TEditorForm then
7623                         TEditorForm(Screen.CustomForms[i]).MailComboBox.Items.Clear;
7624         end;
7625 end;
7626 // *************************************************************************
7627 //! \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
7628 // *************************************************************************
7629 procedure TGikoForm.CabinetCloseSpeedButtonClick(Sender: TObject);
7630 begin
7631         //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Ì
7632         //\8cÄ\82Ñ\8fo\82µ\82É\82µ\82½\81@by \82à\82\82ã
7633         if GikoDM.CabinetVisibleAction.Enabled then begin
7634                 GikoDM.CabinetVisibleAction.Execute;
7635         end;
7636 end;
7637 // *************************************************************************
7638 //! \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
7639 // *************************************************************************
7640 procedure TGikoForm.FavoriteArrangeToolButtonClick(Sender: TObject);
7641 begin
7642         if GikoDM.FavoriteArrangeAction.Enabled then begin
7643                 GikoDM.FavoriteArrangeAction.Execute;
7644         end;
7645 end;
7646 // *************************************************************************
7647 //! \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
7648 // *************************************************************************
7649 procedure TGikoForm.GikoApplicationEventsMessage(var Msg: tagMSG;
7650   var Handled: Boolean);
7651 var
7652         wmMsg: TWMKey;
7653 begin
7654         //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ß
7655         if Self.Active then begin
7656                 case Msg.message of
7657                         //\83L\81[\93ü\97Í\82·\82×\82Ä
7658                         WM_KEYFIRST..WM_KEYLAST :
7659                         begin
7660                                 //\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ç
7661                                 if (Msg.message <> WM_KEYUP) and (Msg.message <> WM_CHAR) then begin
7662                                         wmMsg.Msg := Msg.message;
7663                                         wmMsg.CharCode := Word(Msg.wParam);
7664                                         wmMsg.KeyData := Msg.lParam;
7665                                         //\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\82Ì\8f\88\97\9d\82É\93]\91\97
7666                                         Self.OnShortCut(wmMsg, Handled);
7667                                 end;
7668                         end;
7669                 end;
7670         end;
7671 end;
7672 // *************************************************************************
7673 //! \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
7674 // *************************************************************************
7675 procedure TGikoForm.GikoApplicationEventsDeactivate(Sender: TObject);
7676 begin
7677         Application.ProcessMessages;
7678         if not Application.Terminated then begin
7679                 if PreviewTimer.Enabled then
7680                         PreviewTimer.Enabled := False;
7681                 //\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
7682                 if FHint <> nil then begin
7683                         FHint.ReleaseHandle;
7684                         FHint.ClearAllRes;
7685                 end;
7686                 //\83v\83\8c\83r\83\85\81[\82ð\89B\82·
7687                 if FPreviewBrowser <> nil then
7688                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
7689         end;
7690
7691 end;
7692 // *************************************************************************
7693 //! \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
7694 // *************************************************************************
7695 procedure TGikoForm.GikoApplicationEventsException(Sender: TObject;
7696   E: Exception);
7697 var
7698         s : String;
7699 begin
7700         if (Sender <> nil) then begin
7701                 s := ' [' + Sender.ClassName + ']' + #13#10;
7702         end else begin
7703                 s := ' [ Sender is nil ] ' + #13#10;
7704         end;
7705         s := s + E.Message;
7706         MsgBox(Handle, s, '\8f\88\97\9d\82³\82ê\82È\82©\82Á\82½\97á\8aO', MB_OK or MB_ICONSTOP);
7707 end;
7708 // *************************************************************************
7709 //! \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¬
7710 // *************************************************************************
7711 procedure TGikoForm.CreateControlThread();
7712 begin
7713         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
7714         FControlThread := TThreadControl.Create(True);
7715         FControlThread.MaxThreadCount := 1;
7716         FControlThread.Resume;
7717         FControlThread.OnDownloadEnd := DownloadEnd;
7718         FControlThread.OnDownloadMsg := DownloadMsg;
7719         FControlThread.OnWork := Work;
7720         FControlThread.OnWorkBegin := WorkBegin;
7721         FControlThread.OnWorkEnd := WorkEnd;
7722 end;
7723 // *************************************************************************
7724 //! \83u\83\89\83E\83U\82Ì\90\90¬
7725 // *************************************************************************
7726 procedure TGikoForm.CreateBrowsers(count: Integer);
7727 var
7728         i: Integer;
7729         newBrowser: TWebBrowser;
7730 begin
7731         BrowserNullTab := TBrowserRecord.Create;
7732         BrowserNullTab.Browser := Browser;
7733         BrowserNullTab.Browser.Navigate(BLANK_HTML);
7734         FBrowsers := TList.Create;
7735         for i := 0 to count -1 do begin
7736                 FBrowsers.Add(TWebBrowser.Create(BrowserPanel));
7737                 newBrowser := FBrowsers[FBrowsers.Count - 1];
7738                 TOleControl(newBrowser).Parent := BrowserPanel;
7739                 TOleControl(newBrowser).Align := alNone;
7740                 TOleControl(newBrowser).Left    := 0;
7741                 TOleControl(newBrowser).Top     := 0;
7742                 newBrowser.RegisterAsDropTarget := False;
7743                 newBrowser.OnDocumentComplete   := BrowserDocumentComplete;
7744                 newBrowser.OnBeforeNavigate2    := BrowserBeforeNavigate2;
7745                 newBrowser.OnEnter                              := BrowserEnter;
7746                 newBrowser.OnNewWindow2                 := BrowserNewWindow2;
7747                 newBrowser.OnStatusTextChange   := BrowserStatusTextChange;
7748                 newBrowser.Navigate(BLANK_HTML);
7749                 ShowWindow(newBrowser.Handle, SW_HIDE);
7750         end;
7751         BrowserNullTab.Browser.BringToFront;
7752         ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
7753         //\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Ì
7754         //\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Å
7755         //\82±\82±\82Å\8fI\82í\82ç\82¹\82Ä\82¨\82­
7756         while (Browser.ReadyState <> READYSTATE_COMPLETE) and
7757                 (Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
7758                 Application.ProcessMessages;
7759         end;
7760 end;
7761 // *************************************************************************
7762 //! \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é
7763 // *************************************************************************
7764 procedure TGikoForm.SetSelectComboBox();
7765 const
7766         DUMMYCOMPNAME = 'SelectComboBoxDummy';
7767 var
7768         i: Integer;
7769         ToolButton: TToolButton;
7770 begin
7771         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
7772         SelectComboBoxPanel.Visible := False;
7773         try
7774                 for i := ListToolBar.ControlCount - 1 downto 0 do
7775                 begin
7776                         if ListToolBar.Controls[ i ].Action = GikoDM.SelectItemAction then
7777                         begin
7778                                 SelectComboBoxPanel.Left := ListToolBar.Controls[ i ].Left;
7779                                 SelectComboBoxPanel.Width := GikoSys.Setting.SelectComboBoxWidth;
7780                                 SelectComboBoxPanel.Parent := ListToolBar;
7781                                 SelectComboBoxPanel.Visible := True;
7782
7783                                 SelectComboBox.Left := 0;
7784                                 SelectComboBox.Top  := 0;
7785                                 SelectComboBox.Height := SelectComboBoxPanel.ClientHeight;
7786                                 SelectComboBox.Width := SelectComboBoxPanel.Width -
7787                                                                                 SelectComboBoxSplitter.Width;
7788
7789                                 //\88ê\82Â\8c©\82¦\82È\82¢\83{\83^\83\93\82ð\93Ë\82Á\8d\9e\82Þ
7790                                 ToolButton := TToolButton(ListToolBar.FindComponent(DUMMYCOMPNAME));
7791                                 if ToolButton = nil then begin
7792                                         ToolButton := TToolButton.Create(ListToolBar);
7793                                         ToolButton.Name := DUMMYCOMPNAME;
7794                                 end;
7795                                 ToolButton.Style := tbsSeparator;
7796                                 ToolButton.Width := 0;
7797                                 ToolButton.Left  := ListToolBar.Controls[ i ].Left;
7798                                 ListToolBar.InsertControl(ToolButton);
7799                                 ToolButton.Visible := False;
7800
7801                                 // \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·
7802                                 if (i + 1) < ListToolBar.ControlCount then
7803                                         if ListToolBar.Controls[ i + 1 ] is TToolButton then
7804                                                 if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
7805                                                         ListToolBar.Controls[ i + 1 ].Visible := False;
7806
7807
7808                                 // \83X\83\8c\83b\83h\8di\8d\9e\83{\83^\83\93\82ð\89B\82·
7809                                 ListToolBar.Controls[ i ].Visible := False;
7810
7811                                 break;
7812                         end;
7813                 end;
7814         except
7815         end;
7816 end;
7817 //! \83L\83\83\83r\83l\83b\83g\82Ì\83}\83E\83X\83_\83E\83\93\83C\83x\83\93\83g
7818 procedure TGikoForm.TreeViewMouseDown(Sender: TObject;
7819   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
7820 var
7821         rect : TRect;
7822 begin
7823         case Button of
7824         mbLeft:
7825                 begin
7826                         if (TreeView.Selected <> nil) and
7827                                 (TreeView.Selected = TreeView.GetNodeAt(X, Y)) then begin
7828                                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
7829                                 rect := TreeView.Selected.DisplayRect(true);
7830                                 // \83A\83C\83R\83\93\95ª\82¾\82¯\8d\82É\82¸\82ç\82·
7831                                 if ((rect.Left - TreeView.Indent <= X) and (rect.Right >= X)) and
7832                                         ((rect.Bottom >= Y) and (rect.Top <= Y)) then begin
7833                                         // \83N\83\8a\83b\83N\82Æ\83_\83u\83\8b\83N\83\8a\83b\83N\82ð\83R\83R\82Å\94»\92è
7834                                         if ssDouble in Shift then begin
7835                                                 TreeDoubleClick( TreeView.Selected );
7836                                         end else begin
7837                                                 TreeClick(TreeView.Selected);
7838                                         end;
7839                                 end;
7840                         end;
7841                 end;
7842         end;
7843 end;
7844 //! ActionList\82ÌGroupIndex\82Ì\95Û\91
7845 procedure TGikoForm.GetGroupIndex(ActionList: TActionList);
7846 var
7847         i: Integer;
7848 begin
7849         if ActionList <> nil then begin
7850                 SetLength(FActionListGroupIndexes, ActionList.ActionCount);
7851
7852                 for i := 0 to ActionList.ActionCount - 1 do begin
7853                         try
7854                                 FActionListGroupIndexes[i] :=
7855                                         TCustomAction(ActionList.Actions[i]).GroupIndex;
7856                                 TCustomAction(ActionList.Actions[i]).GroupIndex
7857                                         := 0;
7858                         except
7859                                 ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7860                         end;
7861                 end;
7862
7863         end;
7864 end;
7865 //! ActionList\82ÌGroupIndex\82Ì\90Ý\92è
7866 procedure TGikoForm.SetGroupIndex(ActionList: TActionList);
7867 var
7868         i: Integer;
7869 begin
7870         if ActionList <> nil then begin
7871                 if Length( FActionListGroupIndexes ) = ActionList.ActionCount then begin
7872                         for i := 0 to ActionList.ActionCount - 1 do begin
7873                                 try
7874                                         TCustomAction(ActionList.Actions[i]).GroupIndex
7875                                                 := FActionListGroupIndexes[i];
7876                                 except
7877                                         ;//Cast\82Å\82«\82È\82¢\82Æ\82«\91Î\8dô
7878                                 end;
7879                         end;
7880                 end;
7881         end;
7882 end;
7883 //! \82±\82Ì\83\8c\83X\82ÌURL\8eæ\93¾
7884 procedure TGikoForm.GetResURLMenuClick(Sender: TObject);
7885 begin
7886 ;
7887 end;
7888 //! ListView\81i\83X\83\8c\83b\83h\88ê\97\97\81j\82ð\8dX\90V\82·\82é
7889 procedure TGikoForm.RefreshListView(Thread: TThreadItem);
7890 begin
7891         //Thread\82Ì\94Â\82Æ\95\\8e¦\82µ\82Ä\82¢\82é\94Â\82ª\93¯\82\82È\82ç\95`\89æ\82ð\8dX\90V\82·\82é
7892         if (FActiveList is TBoard) and (TBoard(ActiveList) = Thread.ParentBoard) then begin
7893                 ListView.Refresh;
7894         end;
7895 end;
7896
7897 initialization
7898                                 OleInitialize(nil);
7899 finalization
7900                                 OleUninitialize;
7901
7902 end.