OSDN Git Service

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