OSDN Git Service

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