OSDN Git Service

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