OSDN Git Service

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