OSDN Git Service

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