OSDN Git Service

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