OSDN Git Service

レス指定リンクで、未取得部分を指定したときに自動でDLするように修正
[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, GikoSys.GetMainKeyFileName);
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 procedure TGikoForm.TreePopupMenuPopup(Sender: TObject);
3713 begin
3714         FClickNode := TreeView.Selected;
3715         if FClickNode = nil then begin
3716                 TreeSelectThreadPupupMenu.Visible := False;
3717                 TreeSelectBoardPupupMenu.Visible := False;
3718                 TPMSep01.Visible := False;
3719                 TreeSelectURLPupupMenu.Visible := False;
3720                 TreeSelectNamePupupMenu.Visible := False;
3721                 TreeSelectNameURLPupupMenu.Visible := False;
3722                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3723                 TreeSelectLogDeleteSeparator.Visible := False;
3724                 TreeSelectLogDeletePopupMenu.Visible := False;
3725         end else if TObject(FClickNode.Data) is TBoard then begin
3726                 TreeSelectThreadPupupMenu.Visible := False;
3727                 TreeSelectBoardPupupMenu.Visible := True;
3728                 TPMSep01.Visible := True;
3729                 TreeSelectURLPupupMenu.Visible := True;
3730                 TreeSelectNamePupupMenu.Visible := True;
3731                 TreeSelectNameURLPupupMenu.Visible := True;
3732                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3733                 TreeSelectLogDeleteSeparator.Visible := False;
3734                 TreeSelectLogDeletePopupMenu.Visible := False;
3735         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
3736                 TreeSelectThreadPupupMenu.Visible := False;
3737                 TreeSelectBoardPupupMenu.Visible := True;
3738                 TPMSep01.Visible := True;
3739                 TreeSelectURLPupupMenu.Visible := True;
3740                 TreeSelectNamePupupMenu.Visible := True;
3741                 TreeSelectNameURLPupupMenu.Visible := True;
3742                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3743                 TreeSelectLogDeleteSeparator.Visible := False;
3744                 TreeSelectLogDeletePopupMenu.Visible := False;
3745         end else if (TObject(FClickNode.Data) is TThreadItem) then begin
3746                 TreeSelectThreadPupupMenu.Visible := True;
3747                 TreeSelectBoardPupupMenu.Visible := False;
3748                 TPMSep01.Visible := True;
3749                 TreeSelectURLPupupMenu.Visible := True;
3750                 TreeSelectNamePupupMenu.Visible := True;
3751                 TreeSelectNameURLPupupMenu.Visible := True;
3752                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3753                 TreeSelectLogDeleteSeparator.Visible := True;
3754                 TreeSelectLogDeletePopupMenu.Visible := True;
3755         end else if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
3756                 TreeSelectThreadPupupMenu.Visible := True;
3757                 TreeSelectBoardPupupMenu.Visible := False;
3758                 TPMSep01.Visible := True;
3759                 TreeSelectURLPupupMenu.Visible := True;
3760                 TreeSelectNamePupupMenu.Visible := True;
3761                 TreeSelectNameURLPupupMenu.Visible := True;
3762                 TreeSelectFavoriteAddPupupMenu.Visible := True;
3763                 TreeSelectLogDeleteSeparator.Visible := True;
3764                 TreeSelectLogDeletePopupMenu.Visible := True;
3765         end else if (TObject(FClickNode.Data) is TCategory) then begin
3766                 TreeSelectThreadPupupMenu.Visible := False;
3767                 TreeSelectBoardPupupMenu.Visible := False;
3768                 TPMSep01.Visible := False;
3769                 TreeSelectURLPupupMenu.Visible := False;
3770                 TreeSelectNamePupupMenu.Visible := True;
3771                 TreeSelectNameURLPupupMenu.Visible := False;
3772                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3773                 TreeSelectLogDeleteSeparator.Visible := False;
3774                 TreeSelectLogDeletePopupMenu.Visible := False;
3775         end else if FClickNode.IsFirstNode then begin
3776                 TreeSelectThreadPupupMenu.Visible := False;
3777                 TreeSelectBoardPupupMenu.Visible := False;
3778                 TPMSep01.Visible := False;
3779                 TreeSelectURLPupupMenu.Visible := False;
3780                 TreeSelectNamePupupMenu.Visible := True;
3781                 TreeSelectNameURLPupupMenu.Visible := False;
3782                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3783                 TreeSelectLogDeleteSeparator.Visible := False;
3784                 TreeSelectLogDeletePopupMenu.Visible := False;
3785         end else begin
3786                 TreeSelectThreadPupupMenu.Visible := False;
3787                 TreeSelectBoardPupupMenu.Visible := False;
3788                 TPMSep01.Visible := False;
3789                 TreeSelectURLPupupMenu.Visible := False;
3790                 TreeSelectNamePupupMenu.Visible := False;
3791                 TreeSelectNameURLPupupMenu.Visible := False;
3792                 TreeSelectFavoriteAddPupupMenu.Visible := False;
3793                 TreeSelectLogDeleteSeparator.Visible := False;
3794                 TreeSelectLogDeletePopupMenu.Visible := False;
3795         end;
3796 end;
3797
3798 procedure TGikoForm.BrowserNewWindow2(Sender: TObject;
3799         var ppDisp: IDispatch; var Cancel: WordBool);
3800 var
3801         Text: string;
3802         Html: string;
3803         URL: string;
3804         idx: Integer;
3805         wkIntSt: Integer;
3806         wkIntTo: Integer;
3807     BNum, BRes: string;
3808     threadItem: TThreadItem;
3809 begin
3810
3811         Cancel := True;
3812         if (IHTMLDocument2(TWebBrowser(Sender).Document).activeElement <> nil) then begin
3813                 Text := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerText;
3814                 Html := IHTMLDocument2(TWebBrowser(Sender).Document).activeElement.Get_outerHTML;
3815                 if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
3816                         or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
3817                         if GikoSys.Setting.ResAnchorJamp then begin
3818                                 Text := ZenToHan(Trim(Text));
3819
3820                                 if(AnsiPos('>>', Text) = 1) then begin
3821                                         //Text := Copy(Text, 3, Length(Text) - 2);
3822                                         Delete(Text, 1, 2);
3823                                 end else begin
3824                                         //Text := Copy(Text, 2, Length(Text) - 1);
3825                                         Delete(Text, 1, 1);
3826                                 end;
3827
3828                                 if AnsiPos('-', Text) <> 0 then begin
3829                                         wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
3830                                         Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
3831                                         wkIntTo := StrToIntDef(Text, 0);
3832                                         if wkIntTo < wkIntSt then
3833                                                 wkIntSt := wkIntTo;
3834                                 end else begin
3835                                         wkIntSt := StrToIntDef(Text, 0);
3836                                 end;
3837
3838                                 if wkIntSt <> 0 then begin
3839                                         FActiveContent.IDAnchorPopup('');
3840                                         BrowserMovement(IntToStr(wkIntSt));
3841                                 end;
3842
3843
3844                         end;
3845                 end else begin
3846             ////'http://be.2ch.net/test/p.php?i='+id+'&u=d:'+bas+num
3847
3848                         URL := GikoSys.GetHRefText(Html);
3849                         URL := GikoSys.HTMLDecode(URL);
3850             if AnsiPos('BE:', URL) = 1 then begin
3851                                 BNum := Copy(URL, 4, AnsiPos('/', URL) - 4);
3852                                 BRes := Copy(URL, AnsiPos('/', URL) + 1,  Length(URL));
3853                 threadItem := FActiveContent.Thread;
3854                 if threadItem = nil then Exit;
3855                 URL := BE_PHP_URL + BNum + '&u=d'
3856                         + CustomStringReplace(threadItem.URL, 'l50', '') + BRes;
3857             end;
3858
3859                         if( AnsiPos('http://', URL) = 1) or (AnsiPos('https://', URL) = 1) or
3860                                 ( AnsiPos('ftp://', URL) = 1) then begin
3861                                 //\83A\83h\83\8c\83X\83o\81[\82Ì\97\9a\97ð
3862                                 if GikoSys.Setting.LinkAddAddressBar then begin
3863                                         idx := AddressComboBox.Items.IndexOf(URL);
3864                                         if idx = -1 then begin
3865                                                 AddressComboBox.Items.Insert(0, URL);
3866                                                 if AddressComboBox.Items.Count > GikoSys.Setting.AddressHistoryCount then
3867                                                         AddressComboBox.Items.Delete(AddressComboBox.Items.Count - 1);
3868                                         end else begin
3869                                                 AddressComboBox.Items.Delete(idx);
3870                                                 AddressComboBox.Items.Insert(0, URL);
3871                                         end;
3872                                 end;
3873                                 MoveToURL( URL );
3874                         end;
3875                 end;
3876         end;
3877
3878 end;
3879
3880 procedure TGikoForm.ListSplitterMoved(Sender: TObject);
3881 begin
3882         if Mouse.Capture <> 0 then
3883                 Exit;
3884         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3885                 if (ViewPanel.Width > 1) and (ViewPanel.Width <= (ThreadMainPanel.Width - 80)) then
3886                         FBrowserSizeWidth := ViewPanel.Width;
3887         end else begin
3888                 if (ViewPanel.Height > 1) and (ViewPanel.Height <= (ThreadMainPanel.Height - BrowserCoolBar.Height)) then
3889                         FBrowserSizeHeight := ViewPanel.Height;
3890         end;
3891         if GikoSys.Setting.ListOrientation = gloHorizontal then begin
3892                 if ViewPanel.Width < 2 then begin
3893                         ViewPanel.Width := 1;
3894                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3895                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3896                         GikoSys.Setting.ListWidthState := glsMax;
3897                 end else if ViewPanel.Width > (ThreadMainPanel.Width - 80) then begin
3898                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3899                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_NORMAL;
3900                         GikoSys.Setting.ListWidthState := glsMin;
3901                 end else begin
3902                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MAX;
3903                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_WIDTH_MIN;
3904                         GikoSys.Setting.ListWidthState := glsNormal;
3905                 end;
3906         end else begin
3907                 if ViewPanel.Height < 2 then begin
3908                         ViewPanel.Height := 1;
3909                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3910                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3911                         GikoSys.Setting.ListHeightState := glsMax;
3912                 end else if ViewPanel.Height > (ThreadMainPanel.Height - BrowserCoolBar.Height - 7) then begin
3913                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3914                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_NORMAL;
3915                         GikoSys.Setting.ListHeightState := glsMin;
3916                 end else begin
3917                         GikoDM.BrowserMaxAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MAX;
3918                         GikoDM.BrowserMinAction.ImageIndex := GikoDataModule.TOOL_ICON_HEIGHT_MIN;
3919                         GikoSys.Setting.ListHeightState := glsNormal;
3920                 end;
3921         end;
3922 {       if (Mouse.Capture = 0) and (ViewPanel.Height > 1) and (not ArrangeAction.Checked) then
3923                 FBrowserSizeHeight := ViewPanel.Height
3924         else if (Mouse.Capture = 0) and (ViewPanel.Width > 1) and (ArrangeAction.Checked) then
3925                 FBrowserSizeWidth := ViewPanel.Width;}
3926 end;
3927
3928 procedure TGikoForm.BrowserTabChange(Sender: TObject);
3929 var
3930         i, j: Integer;
3931         idx: Integer;
3932 begin
3933
3934 //      if NewTab = -1 then
3935 //      ThreadItem := nil;
3936         if not BrowserTab.Dragging then begin
3937                 FTabHintIndex := -1;
3938                 BrowserTab.Hint := '';
3939                 idx := BrowserTab.TabIndex;
3940                 if idx = -1 then begin
3941                         BrowserNullTab.Thread := nil;
3942                         SetContent(BrowserNullTab);
3943
3944                 end else if(BrowserTab.Tabs.Objects[idx] <> nil) and (BrowserTab.Tabs.Objects[idx] is TBrowserRecord) then begin
3945                         if TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser <> nil then begin
3946                                 j := FBrowsers.IndexOf(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser);
3947                                 if j <> -1 then
3948                                         FBrowsers.Move(j ,0);
3949                         end else begin
3950                                 if( FActiveContent <> nil ) and (FActiveContent.Browser <> nil) and
3951                                         (FActiveContent.Browser <> BrowserNullTab.Browser) and
3952                                         (FActiveContent.Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1])) then
3953                                         FBrowsers.Move(BROWSER_COUNT - 1, 0);
3954
3955                                 for i := 0 to BrowserTab.Tabs.Count - 1 do begin
3956                                         if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(FBrowsers[BROWSER_COUNT - 1]) then begin
3957                                                 ReleaseBrowser(TBrowserRecord(BrowserTab.Tabs.Objects[i]));
3958                                                 break;
3959                                         end;
3960                                 end;
3961                                 TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser := TWebBrowser(FBrowsers[BROWSER_COUNT - 1]);
3962                                 TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Repaint := true;
3963                                 FBrowsers.Move(BROWSER_COUNT - 1, 0);
3964                         end;
3965                         MoveWindow(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser.Handle, 0, 0, BrowserPanel.Width, BrowserPanel.Height, false);
3966                         TOleControl(TBrowserRecord(BrowserTab.Tabs.Objects[idx]).Browser).BringToFront;
3967 //                      GikoSys.OnlyAHundredRes := TBrowserRecord(BrowserTab.Tabs.Objects[idx]).OnlyHundred;
3968 //                      OnlyAHundredRes.Checked := TBrowserRecord(BrowserTab.Tabs.Objects[idx]).OnlyHundred;
3969                         SetContent(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
3970
3971                         if (GikoSys.Setting.URLDisplay) and (GetActiveContent <> nil) then
3972                                 AddressComboBox.Text := GetActiveContent.URL;
3973
3974                         if ((TreeView.Visible) and (TreeView.Focused)) or ((FavoriteTreeView.Visible) and (FavoriteTreeView.Focused)) or
3975                                 (ListView.Focused) or (SelectComboBox.Focused) or (AddressComboBox.Focused)
3976                         then
3977                         else
3978                                 GikoDM.SetFocusForBrowserAction.Execute;
3979
3980                 end;
3981
3982         end;
3983
3984 end;
3985
3986
3987 procedure TGikoForm.BrowserTabMouseDown(Sender: TObject;
3988         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
3989 var
3990         p: TPoint;
3991         p2: TPoint;
3992         idx: Integer;
3993 begin
3994         if Button = mbMiddle then begin
3995                 // \83}\83E\83X\92\86\83{\83^\83\93
3996                 GetCursorPos(p);
3997                 p2 := p;
3998                 p := BrowserTab.ScreenToClient(p);
3999                 idx := BrowserTab.IndexOfTabAt(p.X, p.Y);
4000                 if idx <> -1 then
4001                         DeleteTab(TBrowserRecord(BrowserTab.Tabs.Objects[idx]));
4002         end else if Button = mbLeft then begin
4003                 FDragWFirst := true;
4004                 FMouseDownPos.X := X;
4005                 FMouseDownPos.Y := Y;
4006         end;
4007
4008 end;
4009
4010 procedure TGikoForm.SetBrowserTabState;
4011 var
4012 //      i: Integer;
4013         CoolBand: TCoolBand;
4014 begin
4015         BrowserBottomPanel.AutoSize := False;
4016         if GikoSys.Setting.BrowserTabVisible then begin
4017                 if GikoSys.Setting.BrowserTabStyle = gtsTab then begin
4018                         BrowserTab.Style := tsTabs;
4019                         if GikoSys.Setting.BrowserTabPosition = gtpTop then
4020                                 BrowserTab.TabPosition := tpTop
4021                         else
4022                                 BrowserTab.TabPosition := tpBottom;
4023                 end else if GikoSys.Setting.BrowserTabStyle = gtsButton then begin
4024                         BrowserTab.TabPosition := tpTop;
4025                         BrowserTab.Style := tsButtons;
4026                 end else begin
4027                         BrowserTab.TabPosition := tpTop;
4028                         BrowserTab.Style := tsFlatButtons
4029                 end;
4030
4031                 if GikoSys.Setting.BrowserTabPosition = gtpTop then begin
4032                         BrowserTab.Parent := BrowserTabToolBar;
4033                         BrowserBottomPanel.Hide;
4034                         CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4035                         if CoolBand <> nil then
4036                                 CoolBand.Visible := True;
4037 //                      BrowserTab.Parent := BrowserTopPanel;
4038 //                      BrowserTab.Parent := BrowserCoolBar;
4039 //                      BrowserTab.Top := 26;
4040 //                      BrowserTopPanel.Height := 44;
4041
4042                 end else begin
4043                         BrowserTab.Parent := BrowserBottomPanel;
4044                         BrowserTab.Top := 0;
4045                         BrowserTab.Left := 0;
4046                         BrowserBottomPanel.Show;
4047                         CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4048                         if CoolBand <> nil then
4049                                 CoolBand.Visible := False;
4050 //                      BrowserTopPanel.Height := 26;
4051                 end;
4052                 BrowserTab.Show;
4053         end else begin
4054                 CoolBand := GetCoolBand(BrowserCoolBar, BrowserTabToolBar);
4055                 if CoolBand <> nil then
4056                         CoolBand.Visible := False;
4057                 BrowserBottomPanel.Visible := False;
4058 //              BrowserTab.Visible := False;
4059 //              BrowserTopPanel.Height := 26;
4060                 GikoDM.AllTabCloseAction.Execute;
4061         end;
4062 end;
4063
4064 procedure TGikoForm.BrowserTabDragOver(Sender, Source: TObject; X,
4065         Y: Integer; State: TDragState; var Accept: Boolean);
4066 var
4067         idx: Integer;
4068 begin
4069         idx := BrowserTab.IndexOfTabAt(X, Y);
4070         Accept := (Source = BrowserTab) and (BrowserTab.TabIndex <> idx);
4071 end;
4072
4073 procedure TGikoForm.BrowserTabDragDrop(Sender, Source: TObject; X,
4074         Y: Integer);
4075 var
4076         idx: Integer;
4077 begin
4078         idx := BrowserTab.IndexOfTabAt(X, Y);
4079         if idx <> -1 then
4080                 BrowserTab.Tabs.Move(BrowserTab.TabIndex, idx);
4081 end;
4082
4083 procedure TGikoForm.BrowserTabMouseMove(Sender: TObject;
4084         Shift: TShiftState; X, Y: Integer);
4085 var
4086         TabIdx: Integer;
4087         ThreadItem: TThreadItem;
4088 begin
4089
4090         TabIdx := BrowserTab.IndexOfTabAt(x, y);
4091
4092         if ( ssLeft in Shift ) and ( BrowserTab.Style = tsTabs ) then begin
4093                 if FDragWFirst = false then begin
4094                         FDragWFirst := true;
4095                 end else begin
4096                         BrowserTab.EndDrag(false);
4097                         BrowserTab.BeginDrag(false, DandD_THRESHOLD);
4098                         FDragWFirst := false;
4099                 end;
4100         end else begin
4101                 BrowserTab.EndDrag(false);
4102                 FDragWFirst := false;
4103         end;
4104         
4105         if (FTabHintIndex <> TabIdx) and (TabIdx <> -1) then begin
4106                 Application.CancelHint;
4107                 ThreadItem := TBrowserRecord(BrowserTab.Tabs.Objects[TabIdx]).Thread;
4108                 if ThreadItem.Title <> BrowserTab.Tabs[TabIdx] then begin
4109                         BrowserTab.Hint := ThreadItem.Title;
4110                         Application.ShowHint := True;
4111                 end else begin
4112                         BrowserTab.Hint := '';
4113                         Application.ShowHint := True;
4114                 end;
4115                 FTabHintIndex := TabIdx;
4116         end;
4117
4118 end;
4119
4120 procedure TGikoForm.BrowserDocumentComplete(Sender: TObject;
4121         const pDisp: IDispatch; var URL: OleVariant);
4122 var
4123         FDispHtmlDocument: DispHTMLDocument;
4124         BrowserRecord :TBrowserRecord;
4125         i :Integer;
4126         doc                                     : Variant;
4127         threadItem      : TThreadItem;
4128 begin
4129 //      AddMessageList('DocumentComplete', nil, gmiWhat);
4130         if TObject(Sender) is TWebBrowser then begin
4131                 BrowserRecord := nil;
4132                 if TWebBrowser(Sender) <> Browser then begin
4133                         for i := BrowserTab.Tabs.Count - 1 downto 0 do begin
4134                                 if TBrowserRecord(BrowserTab.Tabs.Objects[i]).Browser = TWebBrowser(Sender) then begin
4135                                                 BrowserRecord := TBrowserRecord(BrowserTab.Tabs.Objects[i]);
4136                                                 break;
4137                                 end;
4138                         end;
4139                         if BrowserRecord <> nil then begin
4140                                 if BrowserRecord.Event <> nil then
4141                                         BrowserRecord.Event.Free;
4142                                 FDispHtmlDocument := Idispatch(OleVariant(BrowserRecord.Browser.ControlInterface).Document) as DispHTMLDocument;
4143                                 BrowserRecord.Event := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4144                                 BrowserRecord.Event.OnContextMenu := OnDocumentContextMenu;
4145                                 BrowserRecord.Event.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4146                         end;
4147                 end else begin
4148                         if GetActiveContent <> nil then begin
4149                                 FDispHtmlDocument := Idispatch(OleVariant(Browser.ControlInterface).Document) as DispHTMLDocument;
4150                                 if FEvent <> nil then
4151                                         FEvent.Free;
4152                                 FEvent := THTMLDocumentEventSink.Create(Self, FDispHtmlDocument, HTMLDocumentEvents2);
4153                                 FEvent.OnContextMenu := OnDocumentContextMenu;
4154                                 FEvent.OnClick := WebBrowserClick;  //\92Ç\89Á\82µ\82½OnClick\83C\83x\83\93\83g
4155                         end;
4156                         
4157                 end;
4158
4159                 if (BrowserRecord <> nil) and
4160                          Assigned( BrowserRecord.Thread ) then begin
4161                         threadItem := BrowserRecord.Thread;
4162
4163                         if (BrowserRecord <> nil) and (Length( BrowserRecord.Movement ) > 0) then begin
4164                                 if threadItem.UnRead then begin
4165                                         threadItem.UnRead := False;
4166                                         TreeView.Refresh;
4167                                         ListView.Refresh;
4168                                 end;
4169                                 // \83X\83N\83\8d\81[\83\8b\90æ\82ª\8eæ\93¾\8aO\82Ì\83\8c\83X\82Ì\8e\9e\82Í\8fI\92[\82É\88Ú\93®
4170                                 if (StrToIntDef(BrowserRecord.Movement, 0) <= BrowserRecord.Thread.Count) then begin
4171                                         BrowserRecord.Move(BrowserRecord.Movement);
4172                                         BrowserRecord.Movement := '';
4173                                 end else begin
4174                                         BrowserRecord.Move(IntToStr(BrowserRecord.Thread.Count));
4175                                 end;
4176
4177                         end else if threadItem.UnRead then begin
4178                                 threadItem.UnRead := False;
4179                                 TreeView.Refresh;
4180                                 BrowserRecord.Move('new');
4181                                 ListView.Refresh;
4182                         end else if threadItem.ScrollTop <> 0 then begin
4183                                 try
4184                                         doc := Idispatch( OleVariant( BrowserRecord.Browser.ControlInterface ).Document ) as IHTMLDocument2;
4185                                         doc.Body.ScrollTop := threadItem.ScrollTop;
4186                                 except
4187                                         on E: Exception do
4188                                                 MsgBox(Handle, E.Message, 'SetContent[ScrollTop<-]', 0);
4189                                 end;
4190                         end;
4191                 end;
4192         end;
4193 end;
4194
4195 procedure TGikoForm.RoundNamePopupMenuPopup(Sender: TObject);
4196 begin
4197         AddRoundNameMenu(RoundNamePopupMenu.Items);
4198 end;
4199
4200 procedure TGikoForm.AddRoundNameMenu(MenuItem: TMenuItem);
4201 var
4202         i: Integer;
4203         Item: TMenuItem;
4204 begin
4205         MenuItem.Clear;
4206         Item := TMenuItem.Create(Self);
4207         Item.Caption := '\90V\82µ\82¢\96¼\91O\82Å\8f\84\89ñ\97\\96ñ(&N)...';
4208         Item.OnClick := GikoDM.SelectNewRoundNameExecute;
4209         MenuItem.Add(Item);
4210         Item := TMenuItem.Create(Self);
4211         Item.Caption := '\8f\84\89ñ\83\8a\83X\83g\82©\82ç\8dí\8f\9c(&D)';
4212         Item.OnClick := GikoDM.SelectDeleteRoundExecute;
4213         MenuItem.Add(Item);
4214         Item := TMenuItem.Create(Self);
4215         Item.Caption := '-';
4216         MenuItem.Add(Item);
4217         for i := 0 to RoundList.RoundNameList.Count - 1 do begin
4218                 Item := TMenuItem.Create(Self);
4219                 Item.Caption := RoundList.RoundNameList[i];
4220                 Item.OnClick := SetSelectRoundName;
4221                 MenuItem.Add(Item);
4222         end;
4223 end;
4224
4225 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string; ParentName: string);
4226 var
4227         threadItem : TThreadItem;
4228 begin
4229         if ParentName <> 'dummy1' then begin
4230                 SetSelectItemRound(RoundFlag, RoundName);
4231         end else begin
4232                 threadItem := GetActiveContent;
4233                 if threadItem <> nil then begin
4234                         threadItem.RoundName := RoundName;
4235                         if RoundFlag then
4236                                 RoundList.RoundNameList.Add(RoundName);
4237                         threadItem.Round := RoundFlag;
4238                 end;
4239         end;
4240 end;
4241
4242 procedure TGikoForm.SetSelectItemRound(RoundFlag: Boolean; RoundName: string);
4243 var
4244         i{, idx}: Integer;
4245         List: TList;
4246 begin
4247         List := TList.Create;
4248         try
4249                 SelectListItem(List);
4250                 for i := 0 to List.Count - 1 do begin
4251                         if TObject(List[i]) is TBoard then begin
4252                                 TBoard(List[i]).RoundName := RoundName;
4253                                 if RoundFlag then
4254                                         RoundList.RoundNameList.Add(RoundName);
4255                                 TBoard(List[i]).Round := RoundFlag;
4256                         end else if TObject(List[i]) is TThreadItem then begin
4257                                 if TThreadItem(List[i]).IsLogFile then begin
4258                                         TThreadItem(List[i]).RoundName := RoundName;
4259                                         if RoundFlag then
4260                                                 RoundList.RoundNameList.Add(RoundName);
4261                                         TThreadItem(List[i]).Round := RoundFlag;
4262                                 end;
4263                         end;
4264                 end;
4265         finally
4266                 List.Free;
4267         end;
4268 end;
4269
4270 procedure TGikoForm.SetSelectRoundName(Sender: TObject);
4271 var
4272         MenuItem: TMenuItem;
4273 begin
4274         if Sender is TMenuItem then begin
4275                 MenuItem := TMenuItem(Sender);
4276                 SetSelectItemRound(True, StripHotKey(MenuItem.Caption), TMenuItem(Sender).Parent.Name);
4277                 ListView.Refresh;
4278         end;
4279 end;
4280
4281 function TGikoForm.GetCoolBand(CoolBar: TCoolBar; Control: TWinControl): TCoolBand;
4282 var
4283         i: Integer;
4284 begin
4285         Result := nil;
4286         if CoolBar = nil then
4287                 Exit;
4288         for i := 0 to CoolBar.Bands.Count - 1 do begin
4289                 if CoolBar.Bands[i].Control = Control then begin
4290                         Result := CoolBar.Bands[i];
4291                         Exit;
4292                 end;
4293         end;
4294 end;
4295
4296 procedure TGikoForm.BrowserTabToolBarResize(Sender: TObject);
4297 begin
4298         if BrowserTab.Parent = BrowserTabToolBar then
4299                 BrowserTab.Width := BrowserTabToolBar.Width;
4300 end;
4301
4302 procedure TGikoForm.WMSettingChange(var Message: TWMWinIniChange);
4303 begin
4304         SetMenuFont;
4305 end;
4306
4307 procedure TGikoForm.SetMenuFont;
4308 begin
4309 //      GikoSys.MenuFont(MenuToolBar.Font);
4310 //      MenuToolBar.Buttons[0].AutoSize := False;
4311 //      MenuToolBar.Buttons[0].AutoSize := True;
4312 //      MenuToolBar.Font.Color := clMenuText;
4313         GikoSys.MenuFont(MainCoolBar.Font);
4314         MenuToolBar.Buttons[0].AutoSize := False;
4315         MenuToolBar.Buttons[0].AutoSize := True;
4316         MainCoolBar.AutoSize := False;
4317         MainCoolBar.AutoSize := True;
4318
4319         GikoSys.MenuFont(ListCoolBar.Font);
4320         GikoSys.MenuFont(BrowserCoolBar.Font);
4321 //      MenuToolBar.Font.Color := clMenuText;
4322 end;
4323
4324 procedure TGikoForm.FavoriteMenuClick(Sender: TObject);
4325 var
4326         NewMenu: TMenuItem;
4327 begin
4328         FavoriteMenu.Clear;
4329
4330         //\82¨\8bC\82É\93ü\82è\82Ì\92Ç\89Á
4331         NewMenu := TMenuItem.Create(MainMenu);
4332         NewMenu.Action := GikoDM.FavoriteAddAction;
4333         FavoriteMenu.Add(NewMenu);
4334         //\82¨\8bC\82É\93ü\82è\82Ì\90®\97\9d
4335         NewMenu := TMenuItem.Create(FavoriteMenu);
4336         NewMenu.Action := GikoDM.FavoriteArrangeAction;
4337         FavoriteMenu.Add(NewMenu);
4338         //\83Z\83p\83\8c\81[\83^
4339         NewMenu := TMenuItem.Create(FavoriteMenu);
4340         NewMenu.Caption := '-';
4341         FavoriteMenu.Add(NewMenu);
4342
4343         CreateFavMenu(FavoriteDM.TreeView.Items.GetFirstNode, FavoriteMenu);
4344 end;
4345
4346 procedure TGikoForm.CreateFavMenu(Node: TTreeNode; MenuItem: TMenuItem);
4347 var
4348         i: Integer;
4349         NewMenu: TMenuItem;
4350 begin
4351         for i := 0 to Node.Count - 1 do begin
4352                 NewMenu := TFavoriteMenuItem.Create(Self);
4353                 NewMenu.AutoHotkeys := maAutomatic;
4354                 NewMenu.Caption := CustomStringReplace(Node.Item[i].Text, '&', '&&');
4355                 TFavoriteMenuItem(NewMenu).Data := Node.Item[i].Data;
4356                 MenuItem.Add(NewMenu);
4357
4358                 if TObject(Node.Item[i].Data) is TFavoriteFolder then begin
4359                         NewMenu.ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
4360                         CreateFavMenu(Node.Item[i], NewMenu);
4361                 end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin
4362                         NewMenu.ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
4363                         NewMenu.OnClick := FavoriteClick;
4364                 end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin
4365                         NewMenu.ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
4366                         NewMenu.OnClick := FavoriteClick;
4367                 end;
4368         end;
4369 end;
4370
4371 procedure TGikoForm.ShowFavoriteAddDialog( Item : TObject );
4372 var
4373         Dlg                     : TFavoriteAddDialog;
4374         ItemURL : string;
4375         Data            : Pointer;
4376         Node            : TTreeNode;
4377 begin
4378
4379         if Item is TFavoriteBoardItem then
4380                 Item := TFavoriteBoardItem( Item ).Item
4381         else if Item is TFavoriteThreadItem then
4382                 Item := TFavoriteThreadItem( Item ).Item;
4383
4384         Node := FavoriteTreeView.Items.GetFirstNode;
4385         if Item is TBoard then begin
4386                 ItemURL := TBoard( Item ).URL;
4387                 while Node <> nil do begin
4388                         Data := Node.Data;
4389                         if TObject( Data ) is TFavoriteBoardItem then begin
4390                                 if ItemURL = TFavoriteBoardItem( Data ).URL then begin
4391                                         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
4392                                                 Exit;
4393                                         Break;
4394                                 end;
4395                         end;
4396                         Node := Node.GetNext;
4397                 end;
4398                 Dlg := TFavoriteAddDialog.Create(Self);
4399                 try
4400                         Dlg.SetBoard( TBoard( Item ) );
4401                         Dlg.ShowModal;
4402                 finally
4403                         Dlg.Release;
4404                 end;
4405         end else if Item is TThreadItem then begin
4406                 ItemURL := TThreadItem( Item ).URL;
4407                 while Node <> nil do begin
4408                         Data := Node.Data;
4409                         if TObject( Data ) is TFavoriteThreadItem then begin
4410                                 if ItemURL = TFavoriteThreadItem( Data ).URL then begin
4411                                         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
4412                                                 Exit;
4413                                         Break;
4414                                 end;
4415                         end;
4416                         Node := Node.GetNext;
4417                 end;
4418                 Dlg := TFavoriteAddDialog.Create(Self);
4419                 try
4420                         Dlg.SetThreadItem( TThreadItem( Item ) );
4421                         Dlg.ShowModal;
4422                 finally
4423                         Dlg.Release;
4424                 end;
4425         end;
4426
4427         SetLinkBar;
4428 end;
4429
4430 procedure TGikoForm.FavoriteClick(Sender: TObject);
4431 begin
4432
4433         FavoriteClick( Sender, True );
4434
4435 end;
4436
4437 procedure TGikoForm.FavoriteClick(Sender: TObject; ActiveTab: Boolean);
4438 var
4439         Board: TBoard;
4440         ThreadItem: TThreadItem;
4441         FavBoard: TFavoriteBoardItem;
4442         FavThread: TFavoriteThreadItem;
4443         Item: TObject;
4444 begin
4445 //      Item := nil;
4446         if Sender is TFavoriteMenuItem then
4447                 Item := TFavoriteMenuItem(Sender).Data
4448         else if Sender is TLinkToolButton then
4449                 Item := TLinkToolButton(Sender).Data
4450         else if Sender is TTreeNode then
4451                 Item := TTreeNode( Sender ).Data
4452         else
4453                 Exit;
4454
4455         if TObject(Item) is TFavoriteBoardItem then begin
4456                 FavBoard := TFavoriteBoardItem(Item);
4457                 Board := FavBoard.Item;
4458                 if Board <> nil then begin
4459                         if (FTreeType = gtt2ch) and (FActiveBBS <> Board.ParentCategory.ParenTBBS) then
4460                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4461                         SelectTreeNode(Board, True);
4462                 end;
4463         end else if TObject(Item) is TFavoriteThreadItem then begin
4464                 FavThread := TFavoriteThreadItem(Item);
4465                 ThreadItem := FavThread.Item;
4466                 if ThreadItem = nil then
4467                         Exit;
4468
4469                 InsertBrowserTab(ThreadItem, ActiveTab);
4470
4471                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
4472                         if GikoSys.Setting.ListWidthState = glsMin then begin
4473                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4474                         end;
4475                 end else begin
4476                         if GikoSys.Setting.ListHeightState = glsMin then begin
4477                                 GikoDM.BrowserMaxAndFocusAction.Execute;
4478                         end;
4479                 end;
4480         end;
4481 end;
4482
4483 procedure TGikoForm.BBSMenuItemOnClick(
4484         Sender  : TObject
4485 );
4486 begin
4487
4488         if Sender is TBBSMenuItem then
4489                 ShowBBSTree( TBBSMenuItem( Sender ).Data );
4490
4491 end;
4492
4493 procedure TGikoForm.MainCoolBarResize(Sender: TObject);
4494 begin
4495         TopPanel.Height := Max(MainCoolBar.Height, AnimePanel.Height);
4496
4497 end;
4498
4499 procedure TGikoForm.MoveToURL(const inURL: string);
4500 var
4501         protocol, host, path, document, port, bookmark : string;
4502         URL, protocol2, host2, path2, document2, port2, bookmark2 : string;
4503         tmp1, tmp2: string;
4504         BBSID, BBSKey: string;
4505         {tmpBoard,} Board: TBoard;
4506         ThreadItem: TThreadItem;
4507         i, bi                                   : Integer;
4508         boardURL                        : string;
4509         tmpThread                       : TThreadItem;
4510 //      category                        : TCategory;
4511 //      categoryNode    : TTreeNode;
4512 //      boardNode                       : TTreeNode;
4513         shiftDown                       : Boolean;
4514         ctrlDown                        : Boolean;
4515         stRes, edRes    : Int64;
4516         browserRec              : TBrowserRecord;
4517 begin
4518
4519         GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
4520         GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey );
4521
4522
4523         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
4524         ctrlDown        := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
4525         if shiftDown then begin
4526                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4527                 Exit;
4528         end else if ctrlDown then begin
4529                 GikoSys.OpenBrowser(inURL, gbtIE);
4530                 Exit;
4531         end;
4532
4533         //===== \83v\83\89\83O\83C\83\93
4534         try
4535                 //\8dì\8bÆ\92\86//
4536                 bi := Length(BoardGroups) - 1;
4537                 for i := 1 to bi do begin
4538                         if (BoardGroups[i].BoardPlugIn <> nil) and (Assigned(Pointer(BoardGroups[i].BoardPlugIn.Module))) then begin
4539                                 case BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) of
4540                                 atThread:
4541                                         begin
4542                                                 boardURL        := BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL );
4543                                                 Board           := BBSsFindBoardFromURL( boardURL );
4544
4545
4546                                                 if Board = nil then begin
4547                                                         //break;
4548                                                         // \81¦\8dì\82Á\82Ä\82à\92Ç\89Á\82·\82é\82Æ\82±\82ë\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82­\95Û\97¯
4549                                                         //GikoSys.OpenBrowser(inURL, gbtUserApp);
4550                                                         //Exit;
4551                                                         {
4552                                                         Board := GikoSys.GetUnknownBoard( tmpThread.BoardPlugIn, boardURL );
4553                                                         if (FTreeType = gtt2ch) and (FActiveBBS = BBSs[ 1 ]) then
4554                                                                 ShowBBSTree( BBSs[ 1 ] );
4555                                                         }
4556                                                 end else begin
4557                                                         tmpThread               := TThreadItem.Create( BoardGroups[i].BoardPlugIn, Board, inURL );
4558                                                         if not Board.IsThreadDatRead then begin
4559                                                                 GikoSys.ReadSubjectFile( Board );
4560                                                                 tmpThread.Free;
4561                                                                 Exit;
4562                                                         end;
4563                                                         ThreadItem := Board.FindThreadFromFileName( tmpThread.FileName );
4564                                                         if ThreadItem = nil then begin
4565                                                                 //tmpThread\82ð\82±\82Á\82¿\82Í\8aJ\95ú\82µ\82Ä\82Í\82¢\82¯\82È\82¢
4566                                                                 ThreadItem := tmpThread;
4567                                                                 Board.Insert( 0, ThreadItem );
4568                                                                 if ActiveList is TBoard then begin
4569                                                                         if TBoard(ActiveList) = Board then
4570                                                                                 ListView.Items.Count := ListView.Items.Count + 1;
4571                                                                 end;
4572                                                                 GikoSys.GetPopupResNumber( inURL, stRes, edRes );
4573                                                                 browserRec := InsertBrowserTab( ThreadItem );
4574                                                                 if (browserRec <> nil) and (stRes > 0) then
4575                                                                         browserRec.Movement := IntToStr( stRes );
4576                                                                 DownloadContent( ThreadItem );
4577                                                                 Exit;
4578                                                         end else begin
4579                                                                 tmpThread.Free;
4580                                                                 GikoSys.GetPopupResNumber( inURL, stRes, edRes );
4581                                                                 browserRec := InsertBrowserTab( ThreadItem );
4582                                                                 if ThreadItem.IsLogFile then begin
4583                                                                         if (browserRec <> nil) and (stRes > 0) then begin
4584                                                                                 browserRec.Movement := IntToStr( stRes );
4585                                                                                 if (stRes > ThreadItem.Count) then begin
4586                                                                                         DownloadContent( ThreadItem );
4587                                                                                 end;
4588                                                                         end;
4589                                                                 end else begin
4590                                                                         if (browserRec <> nil) and (stRes > 0) then
4591                                                                                 browserRec.Movement := IntToStr( stRes );
4592                                                                         DownloadContent( ThreadItem );
4593                                                                 end;
4594                                                                 Exit;
4595                                                         end;
4596                                                 end;
4597                                         end;
4598
4599                                 atBoard:
4600                                         begin
4601                                                 Board := BBSsFindBoardFromURL(
4602                                                                         BoardGroups[i].BoardPlugIn.ExtractBoardURL( inURL )
4603                                                                         );
4604                                                 if Board <> nil then begin
4605                                                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4606                                                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4607                                                         SelectTreeNode( Board, True );
4608                                                         Exit;
4609                                                 end;
4610                                         end;
4611                                 end;
4612                         end;
4613                 end;
4614         except
4615                 // 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¢
4616         end;
4617
4618
4619         if (Length( Trim(BBSKey) ) > 0) and (Length( Trim(BBSID) ) > 0) then begin
4620                 boardURL := GikoSys.Get2chThreadURL2BoardURL( inURL );
4621                 Board := BBSsFindBoardFromURL( boardURL );
4622                 //if Board = nil then
4623                 //      Board := BBSsFindBoardFromBBSID( BBSID );
4624                 { \82±\82Ì\95\94\95ª\82àBBS\82\93FindBoardFromURL\82É\8e\9d\82½\82¹\82½\81@20050523
4625                 if Board = nil then begin
4626                         // \81¦\8dì\82Á\82Ä\82à\92Ç\89Á\82·\82é\82Æ\82±\82ë\82ª\96³\82¢\82Ì\82Å\8c\83\82µ\82­\95Û\97¯
4627                         //\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)
4628                         Board := BBSs[ 0 ].FindBBSID( BBSID );
4629                 end;
4630                 }
4631                 if Board = nil then begin
4632                          // \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­
4633                          GikoSys.OpenBrowser(inURL, gbtUserApp);
4634                          Exit;
4635                 end else begin
4636                         // \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é
4637                         URL :=  Board.URL;
4638                         GikoSys.ParseURI(URL , protocol2, host2, path2, document2, port2, bookmark2 );
4639                         tmp1 := Copy(host, AnsiPos('.', host) + 1, Length(host));
4640                         tmp2 := Copy(host2, AnsiPos('.', host2) + 1, Length(host2));
4641                         if ( not GikoSys.Is2chHost(tmp1)) and (tmp1 <> tmp2) then begin
4642                                 GikoSys.OpenBrowser(inURL, gbtUserApp);
4643                                 Exit;
4644                         end;
4645                 end;
4646
4647                 if not Board.IsThreadDatRead then
4648                         GikoSys.ReadSubjectFile(Board);
4649                 URL := GikoSys.Get2chBrowsableThreadURL( inURL );
4650                 ThreadItem := Board.FindThreadFromURL( URL );
4651                 //\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)
4652                 if ThreadItem = nil then begin
4653                         ThreadItem := Board.FindThreadFromFileName( BBSKey + '.dat' );
4654                 end;
4655                 if ThreadItem = nil then begin
4656                         //shift -> \90Ý\92è\83u\83\89\83E\83U\81i\96³\82¯\82ê\82ÎIE\81j
4657                         //ctrl  -> IE
4658                         {shiftDown      := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
4659                         ctrlDown        := GetAsyncKeyState(VK_CONTROL) = Smallint($8001);
4660                         if shiftDown then
4661                                 GikoSys.OpenBrowser(URL1, gbtUserApp)
4662                         else if ctrlDown then
4663                                 GikoSys.OpenBrowser(URL1, gbtIE)
4664                         else begin
4665                         }
4666                         ThreadItem := TThreadItem.Create( nil, Board, URL );
4667                         ThreadItem.FileName := ChangeFileExt(BBSKey, '.dat');
4668                         if AnsiPos(Host, Board.URL) = 0 then
4669                                 ThreadItem.DownloadHost := Host
4670                         else
4671                                 ThreadItem.DownloadHost := '';
4672                         Board.Insert(0, ThreadItem);
4673                         if ActiveList is TBoard then begin
4674                                 if TBoard(ActiveList) = Board then
4675                                         ListView.Items.Count := ListView.Items.Count + 1;
4676                         end;
4677                         GikoSys.GetPopupResNumber( inURL, stRes, edRes );
4678                         browserRec := InsertBrowserTab(ThreadItem);
4679                         if (browserRec <> nil) and (stRes > 0) then
4680                                 browserRec.Movement := IntToStr( stRes );
4681                         DownloadContent(ThreadItem);
4682                         {end;}
4683                 end else begin
4684                         if ThreadItem.IsLogFile then begin
4685                                 GikoSys.GetPopupResNumber( inURL, stRes, edRes );
4686                                 browserRec := InsertBrowserTab(ThreadItem);
4687                                 if (browserRec <> nil) and (stRes > 0) then begin
4688                                         browserRec.Movement := IntToStr( stRes );
4689                                         if (stRes > ThreadItem.Count) then begin
4690                         DownloadContent(ThreadItem);
4691                                         end;
4692                                 end;
4693                         end else begin
4694                                 if AnsiPos(Host, Board.URL) = 0 then
4695                                         ThreadItem.DownloadHost := Host
4696                                 else
4697                                         ThreadItem.DownloadHost := '';
4698                                 GikoSys.GetPopupResNumber( inURL, stRes, edRes );
4699                                 browserRec := InsertBrowserTab(ThreadItem);
4700                                 if (browserRec <> nil) and (stRes > 0) then
4701                                         browserRec.Movement := IntToStr( stRes );
4702                                 DownloadContent(ThreadItem);
4703                         end;
4704                 end;
4705         end else begin
4706                 Board := BBSsFindBoardFromURL( inURL );
4707                 if Board = nil then begin
4708                         GikoSys.OpenBrowser(inURL, gbtAuto);
4709                 end else begin
4710                         if FActiveBBS <> Board.ParentCategory.ParenTBBS then
4711                                 ShowBBSTree( Board.ParentCategory.ParenTBBS );
4712                         SelectTreeNode( Board, True );
4713         end;
4714         end;
4715 end;
4716
4717 procedure TGikoForm.AddressToolBarResize(Sender: TObject);
4718 begin
4719         AddressComboBox.Width := AddressToolBar.Width - MoveToToolButton.Width - 10;
4720         CoolBarResized( Sender, MainCoolBar );
4721 end;
4722
4723 procedure TGikoForm.AddressComboBoxKeyDown(Sender: TObject; var Key: Word;
4724         Shift: TShiftState);
4725 begin
4726         if Key = VK_RETURN then
4727                 GikoDM.MoveToAction.Execute;
4728 end;
4729
4730 procedure TGikoForm.BrowserEnter(Sender: TObject);
4731 begin
4732         Browser.DoObjectVerb(OLEIVERB_UIACTIVATE);
4733 end;
4734
4735 procedure TGikoForm.WMCopyData(var Message: TWMCopyData);
4736 var
4737         CDS:PCopyDataStruct;
4738         PC:PChar;
4739         sURL: string;
4740 begin
4741         CDS := Message.CopyDataStruct;
4742         GetMem(PC, CDS^.cbData);
4743         try
4744                 lstrcpy(PC,CDS^.lpData);
4745                 SetString(sURL, PC,lstrlen(PC));
4746                 MoveToURL(sURL);
4747         finally
4748                 FreeMem(PC);
4749         end;
4750         Message.Result := 1;
4751 end;
4752
4753 procedure TGikoForm.WndProc(var Message: TMessage);
4754 var
4755         senderBrowser   : TWebBrowser;
4756         url                                             : OleVariant;
4757 begin
4758         try
4759                 case Message.Msg of
4760                 CM_DIALOGCHAR:
4761                         if not (ssAlt in KeyDataToShiftState(TWMChar(Message).KeyData)) then
4762                                 Exit;
4763                 WM_SYSCOMMAND:
4764                         if Message.WParam = SC_MINIMIZE then
4765                                 OnMinimize;
4766                 USER_TREECLICK:
4767                         TreeClick( TreeView.Selected );
4768                 USER_RESIZED:
4769                         OnResized;
4770                 USER_MINIMIZED:
4771                         OnMinimized;
4772                 USER_SETLINKBAR:
4773                         SetLinkBar;
4774                 USER_DOCUMENTCOMPLETE:
4775                         if (Message.WParam <> 0) and
4776                                  (TObject(Message.WParam) is TWebBrowser) then begin
4777                                 senderBrowser := TWebBrowser( Message.WParam );
4778                                 BrowserDocumentComplete( senderBrowser, senderBrowser.Parent, url );
4779                         end;
4780                 end;
4781
4782                 inherited;
4783         except
4784         end;
4785 end;
4786
4787 procedure TGikoForm.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
4788 var
4789         handle: THandle;
4790 begin
4791         Handled := False;
4792         //\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Í
4793         //\83V\83\87\81[\83g\83J\83b\83g\82È\82Ç\82ð\96³\8cø\82É\82·\82é
4794         if ((FavoriteTreeView.Visible) and (FavoriteTreeView.IsEditing)) then begin
4795                 if Msg.CharCode in [VK_BACK] then begin
4796                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4797                         if Msg.KeyData > 0 then begin
4798                                 handle := GetFocus;
4799                                 if handle <> 0 then
4800                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4801                                 Handled := True;
4802                         end;
4803                 end else
4804                 //\82¨\8bC\82É\93ü\82è\82ÍESC\82Å\92E\8fo\82µ\82½\82¢\82Ì\82Å\81A\82»\82ê\82à\91\97\82é
4805                 if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT, VK_ESCAPE] then begin
4806                         handle := GetFocus;
4807                         if handle <> 0 then
4808                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4809                         Handled := True;
4810                 end;
4811         end     else if (AddressComboBox.Focused) or (SelectComboBox.Focused) then begin
4812                 if Msg.CharCode in [VK_BACK] then begin
4813                         //BS\82ª\82Q\89ñ\91\97\82ç\82ê\82é\95s\8bï\8d\87\89ñ\94ð
4814                         if Msg.KeyData > 0 then begin
4815                                 handle := GetFocus;
4816                                 if handle <> 0 then
4817                                         SendMessage(handle, WM_CHAR, Msg.CharCode, Msg.KeyData);
4818                                 Handled := True;
4819                         end;
4820                 end else if Msg.CharCode in [VK_INSERT, VK_DELETE, VK_HOME, VK_END, VK_PRIOR, VK_NEXT] then begin
4821                         handle := GetFocus;
4822                         if handle <> 0 then
4823                                 SendMessage(handle, WM_KEYDOWN, Msg.CharCode, Msg.KeyData);
4824                         Handled := True;
4825                 end;
4826         end else begin
4827                 Handled := GikoDM.GikoFormActionList.IsShortCut(Msg);
4828         end;
4829 end;
4830
4831 procedure TGikoForm.PreviewTimerTimer(Sender: TObject);
4832 var
4833         p: TPoint;
4834         ARect: TRect;
4835         sl: TStringList;
4836         html: string;
4837         HtmlFileName: string;
4838
4839         NavURL: OleVariant;
4840         Flags: OleVariant;
4841         TargetFrameName: OleVariant;
4842         PostData: OleVariant;
4843         Headers: OleVariant;
4844         WindowHeight: Integer;
4845         WindowWidth: Integer;
4846
4847 //      Style: Longint;
4848         Referer: string;
4849         Protocol, Host, Path, Document, Port, Bookmark: string;
4850 begin
4851         PreviewTimer.Enabled := False;
4852
4853         GetCursorpos(p);
4854
4855         case GikoSys.Setting.PreviewSize of
4856                 gpsXSmall: begin
4857                         WindowWidth := 128;
4858                         WindowHeight := 96;
4859                 end;
4860                 gpsSmall: begin
4861                         WindowWidth := 256;
4862                         WindowHeight := 192;
4863                 end;
4864                 gpsLarge: begin
4865                         WindowWidth := 512;
4866                         WindowHeight := 384;
4867                 end;
4868                 gpsXLarge: begin
4869                         WindowWidth := 640;
4870                         WindowHeight := 480;
4871                 end;
4872                 else begin      //gpsMedium
4873                         WindowWidth := 384;
4874                         WindowHeight := 288;
4875                 end;
4876         end;
4877
4878         ARect := Rect(0, 0, WindowWidth, WindowHeight);
4879
4880         case GikoSys.Setting.PopupPosition of
4881                 gppRightTop:            OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -     15);
4882                 gppRight:                       OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
4883                 gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
4884                 gppTop:                                 OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -  15);
4885                 gppCenter:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
4886                 gppBottom:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
4887                 gppLeftTop:                     OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -  15);
4888                 gppLeft:                                OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
4889                 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Ó
4890         end;
4891
4892         html := '<html><head>'#13#10
4893                                 + '<SCRIPT>'#13#10
4894                                 + 'function init() {'#13#10
4895                                 + '     if ((document.body.clientHeight >= Image1.height) && (document.body.clientWidth >= Image1.width)) {'#13#10
4896                                 + '     } else {'#13#10
4897                                 + '             var dh, ih;'#13#10
4898                                 + '             dh = document.body.clientWidth / document.body.clientHeight;'#13#10
4899                                 + '             ih = Image1.width / Image1.height;'#13#10
4900                                 + '             if (document.body.clientWidth < document.body.clientHeight) {'#13#10
4901                                 + '                     if (ih > dh)'#13#10
4902                                 + '                             Image1.width = document.body.clientWidth;'#13#10
4903                                 + '                     else'#13#10
4904                                 + '                             Image1.height = document.body.clientHeight;'#13#10
4905                                 + '             } else {'#13#10
4906                                 + '                     if (ih < dh)'#13#10
4907                                 + '                             Image1.height = document.body.clientHeight;'#13#10
4908                                 + '                     else'#13#10
4909                                 + '                             Image1.width = document.body.clientWidth;'#13#10
4910                                 + '             }'#13#10
4911                                 + '     }'#13#10
4912                                 + '     Message.style.display = "none";'#13#10
4913                                 + '}'#13#10
4914                                 + '</SCRIPT>'#13#10
4915                                 + '</head>'#13#10
4916                                 + '<body topmargin="0" leftmargin="0" style="border-width: 1px; overflow:hidden; border-style: solid;" onLoad="init()">'#13#10
4917                                 + '<div align="center" id="Message">\83v\83\8c\83r\83\85\81[\8dì\90¬\92\86</div>'#13#10
4918                                 + '<div align="center"><img name="Image1" border="0" src="%ImageURL%"></div>'#13#10
4919                                 + '</body></html>';
4920         sl := TStringList.Create;
4921         try
4922                 try
4923                         HtmlFileName := GikoSys.GetAppDir + HTML_FILE_NAME;
4924                         sl.Text := AnsiReplaceStr(html, '%ImageURL%', FPreviewURL);
4925                         sl.SaveToFile(HtmlFileName);
4926                 finally
4927                         sl.Free;
4928                 end;
4929         except
4930         end;
4931
4932         NavURL := HtmlFileName;
4933         Flags := 0;
4934         TargetFrameName := '';
4935         PostData := '';
4936
4937         GikoSys.ParseURI(FPreviewURL, Protocol, Host, Path, Document, Port, Bookmark);
4938         Referer := Protocol + '://' + Host;
4939         if Port <> '' then
4940                 Referer := Referer + ':' + Port;
4941         Referer := Referer + Path;
4942         Headers := 'Referer: ' + Referer;
4943         FPreviewBrowser.Navigate(NavURL, Flags, TargetFrameName, PostData, Headers);
4944         if ARect.Top + WindowHeight > Screen.DesktopHeight then
4945                 ARect.Top := Screen.DesktopHeight - WindowHeight;
4946         if ARect.Left + WindowWidth > Screen.DesktopWidth then
4947                 ARect.Left := Screen.DesktopWidth - WindowWidth;
4948         if ARect.Left < Screen.DesktopLeft then ARect.Left := Screen.DesktopLeft;
4949         if ARect.Bottom < Screen.DesktopTop then ARect.Bottom := Screen.DesktopTop;
4950
4951         SetWindowPos(FPreviewBrowser.Handle, HWND_TOPMOST, ARect.Left, ARect.Top, WindowWidth, WindowHeight, SWP_NOACTIVATE or SWP_HIDEWINDOW);
4952         ShowWindow(FPreviewBrowser.Handle, SW_SHOWNOACTIVATE);
4953
4954 //      Style := GetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE);
4955 //      SetWindowLong(FPreviewBrowser.Handle, GWL_EXSTYLE, Style xor WS_EX_APPWINDOW);
4956
4957 end;
4958
4959 procedure TGikoForm.WMSetCursor(var Message: TWMSetCursor);
4960 begin
4961         if PreviewTimer.Enabled then
4962                 PreviewTimer.Enabled := False;
4963         if (FHint <> nil) and (IsWindowVisible(FHint.Handle)) then begin
4964                 FHint.ReleaseHandle;
4965                 FHint.ClearAllRes;
4966         end;
4967         if (FPreviewBrowser <> nil) and (IsWindowVisible(FPreviewBrowser.Handle)) then
4968                 ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
4969         Message.Result := 1;
4970         inherited;
4971 end;
4972
4973 procedure TGikoForm.MessageHideButtonClick(Sender: TObject);
4974 begin
4975         GikoDM.MsgBarCloseAction.Execute;
4976 end;
4977
4978 function TGikoForm.OnDocumentContextMenu(Sender: TObject): WordBool;
4979 var
4980         Doc: IHtmlDocument2;
4981         Range: IHTMLTxtRange;
4982         s: string;
4983         Num: Integer;
4984         ThreadItem: TThreadItem;
4985 begin
4986         Result := False;
4987         FactiveContent.IDAnchorPopup('');
4988         Doc := FactiveContent.Browser.Document as IHtmlDocument2;
4989         if Assigned(Doc) then begin
4990                 Range := Doc.selection.createRange as IHTMLTxtRange;
4991                 s := CustomStringReplace(Range.text, '\81@', ' ');//\91S\8ap\8bó\94\92\82ð\94¼\8ap\8bó\94\92\82É
4992                 s := ZenToHan(Trim(s));
4993                 if GikoSys.IsNumeric(s) then begin
4994
4995                         ThreadItem := GetActiveContent;
4996                         if ThreadItem <> nil then begin
4997                                 Num := StrToInt(s);
4998                                 FHint.PopupType := gptThread;
4999                                 HTMLCreater.SetResPopupText(FHint, ThreadItem, Num, Num, False, False);
5000                                 if FHint.ResCount <> 0 then
5001                                         ShowTextPopup;
5002                                 Result := False;
5003                         end else
5004                                 Result := True;
5005                 end else begin
5006                         Result := True;
5007                 end;
5008         end;
5009 end;
5010
5011 procedure TGikoForm.ShowTextPopup;
5012 var
5013         p: TPoint;
5014         ARect: TRect;
5015 begin
5016 //      if Trim(s) = '' then
5017 //              Exit;
5018         try
5019                 FHint.Font.Name := GikoSys.Setting.HintFontName;
5020                 FHint.Font.Size := GikoSys.Setting.HintFontSize;
5021                 FHint.Font.Color := GikoSys.Setting.HintFontColor;
5022                 FHint.Color := GikoSys.Setting.HintBackColor;
5023                 FHint.HeaderBold := GikoSys.Setting.ResPopupHeaderBold;
5024                 GetCursorpos(p);
5025                 if FHint.PopupType = gptRaw then
5026                         ARect := FHint.CalcHintRect(Screen.Width, FHint.Caption, nil)
5027                 else
5028                         ARect := FHint.CalcHintRect(Screen.Width, '', nil);
5029                 case GikoSys.Setting.PopupPosition of
5030                         gppRightTop:            OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - (ARect.Bottom - ARect.Top) -     15);
5031                         gppRight:                       OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
5032                         gppRightBottom: OffsetRect(ARect, p.x - (ARect.Right - ARect.Left) - 15, p.y + 15);
5033                         gppTop:                                 OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - (ARect.Bottom - ARect.Top) -  15);
5034                         gppCenter:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y - ((ARect.Bottom - ARect.Top) div 2));
5035                         gppBottom:                      OffsetRect(ARect, p.x - ((ARect.Right - ARect.Left) div 2), p.y + 15);
5036                         gppLeftTop:                     OffsetRect(ARect, p.x + 15, p.y - (ARect.Bottom - ARect.Top) -  15);
5037                         gppLeft:                                OffsetRect(ARect, p.x + 15, p.y - ((ARect.Bottom - ARect.Top) div 2));
5038                         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Ó
5039                 end;
5040                 //FHint.ActivateHint(ARect, s);
5041                 if FHint.PopupType = gptRaw then
5042                         FHint.ActivateHint(ARect, FHint.Caption)
5043                 else
5044                         FHint.ActivateHint(ARect, '');
5045         except
5046                 FHint.ReleaseHandle;
5047                 FHint.ClearAllRes;
5048         end;
5049 end;
5050
5051 procedure TGikoForm.HistoryAllClearToolButtonClick(Sender: TObject);
5052 const
5053         DEL_MSG = '\91S\97\9a\97ð\82ð\8dí\8f\9c\82µ\82Ü\82·\81B\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
5054         DEL_TITLE = '\8dí\8f\9c\8am\94F';
5055 begin
5056         if FTreeType = gttHistory then begin
5057                 if (GetKeyState( VK_SHIFT ) and $80000000) = 0 then
5058                         if MsgBox(Handle, DEL_MSG, DEL_TITLE, MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> ID_YES then
5059                                 Exit;
5060                 ClearHistory;
5061                 FHistoryList.Clear;
5062                 TreeView.Items.Clear;
5063         end;
5064 end;
5065
5066 procedure TGikoForm.SetLinkBar;
5067 var
5068         i: Integer;
5069         j: Integer;
5070         ToolButton: TLinkToolButton;
5071         MenuItem: TMenuItem;
5072         oldIgnoreResize : TResizeType;
5073 begin
5074         oldIgnoreResize := FIsIgnoreResize;
5075         FIsIgnoreResize := rtResizing;
5076         MainCoolBar.Bands.BeginUpdate;
5077         try
5078                 LinkBarPopupMenu.Items.Clear;
5079                 for i := LinkToolBar.ButtonCount - 1 downto 0 do
5080                         //LinkToolBar.RemoveControl(LinkToolBar.Buttons[i]);
5081                         LinkToolBar.Buttons[i].Free;
5082                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5083                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5084                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5085                                         ToolButton := TLinkToolButton.Create(LinkToolBar);
5086 //                    ToolButton.Parent := LinkToolBar;
5087                                         if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteFolder then begin
5088                                                 MenuItem := TMenuItem.Create(Self);
5089                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], MenuItem);
5090                                                 LinkBarPopupMenu.Items.Add(MenuItem);
5091                                                 ToolButton.MenuItem := MenuItem;
5092                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_FOLDER;
5093                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteBoardItem then begin
5094                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_BOARD;
5095                                                 ToolButton.OnClick := FavoriteClick;
5096                                         end else if TObject(FavoriteTreeView.Items[i].Item[j].Data) is TFavoriteThreadItem then begin
5097                                                 ToolButton.ImageIndex := GikoDataModule.TOOL_ICON_FAV_THREAD;
5098                                                 ToolButton.OnClick := FavoriteClick;
5099                                         end;
5100                                         ToolButton.Caption := FavoriteTreeView.Items[i].Item[j].Text;
5101                                         ToolButton.Left := 10000;
5102                                         ToolButton.Data := FavoriteTreeView.Items[i].Item[j].Data;
5103                                         ToolButton.AutoSize := True;
5104                                         ToolButton.OnDragDrop := LinkToolButtonDragDrop;
5105                                         ToolButton.OnDragOver := FavoriteDragOver;
5106                                         ToolButton.OnMouseDown := LinkToolButtonOnMouseDown;
5107                                         ToolButton.OnMouseMove := LinkToolButtonOnMouseMove;
5108                                         ToolButton.OnMouseUp := LinkToolButtonOnMouseUp;
5109                                         ToolButton.OnStartDrag := LinkToolButtonStartDrag;
5110                                         //ToolButton.DragMode := dmAutomatic;
5111                                         ToolButton.DragMode := dmManual;
5112                                         ToolButton.PopupMenu := FavoriteTreePopupMenu;
5113
5114                                         LinkToolBar.InsertControl(ToolButton);
5115                                 end;
5116                                 break;
5117                         end;
5118                 end;
5119 {               if LinkToolBar.ButtonCount = 0 then begin
5120                         ToolButton := TLinkToolButton.Create(LinkToolBar);
5121                         ToolButton.Style := tbsButton;
5122                         ToolButton.ImageIndex := -1;
5123                         ToolButton.Caption := '';
5124                         LinkToolBar.InsertControl(ToolButton);
5125                 end;}
5126         finally
5127                 MainCoolBar.Bands.EndUpdate;
5128                 LoadCoolBarSettings;
5129                 FIsIgnoreResize := oldIgnoreResize;
5130         end;
5131 end;
5132
5133 procedure TGikoForm.FavoriteDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5134 var
5135         Node: TTreeNode;
5136         bound: TRect;
5137         height: Integer;
5138         Change: Boolean;
5139 begin
5140
5141         if Sender = FavoriteTreeView then begin
5142                 Node := FavoriteTreeView.GetNodeAt(X, Y);
5143
5144                 if Node = nil then
5145                         Exit;
5146
5147                 bound := Node.DisplayRect( False );
5148                 height := bound.Bottom - bound.Top;
5149                 if (bound.Top + height / 2) <= Y then
5150                         Node := FavoriteTreeView.GetNodeAt(X, Y + height);
5151
5152                 if Node = nil then
5153                         Exit;
5154
5155                 if Node.IsFirstNode then
5156                         Exit;
5157
5158                 Change := True;
5159
5160                 if FDropSpaceNode <> nil then
5161                         if FDropSpaceNode.AbsoluteIndex = Node.AbsoluteIndex then
5162                                 Change := False;
5163
5164                 if Change then begin
5165                         if FDropSpaceNode <> nil then
5166                                 FDropSpaceNode.Free;
5167
5168                         FDropSpaceNode := FavoriteDM.TreeView.Items.AddChildObjectFirst(Node.Parent, '', nil );
5169                         FDropSpaceNode.MoveTo( Node, naInsert );
5170                         FDropSpaceNode.ImageIndex := -1;
5171                         FDropSpaceNode.SelectedIndex := -1;
5172                 end;
5173         end;
5174
5175         if Source = FavoriteTreeView then begin
5176                 if FavoriteTreeView.Selected = FavoriteTreeView.Items.GetFirstNode then begin
5177                         Accept := False;
5178                         Exit;
5179                 end;
5180                 Accept := True;
5181         end else if Source = BrowserTab then
5182                 Accept := True
5183         else if Source = ListView then
5184                 Accept := True
5185         else if Source is TLinkToolButton then
5186                 Accept := True
5187         else if Source = TreeView then
5188                 Accept := True
5189         else
5190                 Accept := False;
5191 end;
5192
5193 procedure TGikoForm.FavoriteTreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
5194 begin
5195
5196         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
5197
5198 end;
5199 procedure TGikoForm.LinkToolButtonStartDrag(Sender: TObject; var DragObject: TDragObject);
5200 begin
5201          //     FDragging := true;
5202 end;
5203
5204 procedure TGikoForm.LinkToolButtonDragDrop(Sender, Source: TObject; X, Y: Integer);
5205 var
5206         SenderNode: TTreeNode;
5207         LinkToolButton: TLinkToolButton;
5208 begin
5209
5210         LinkToolButton := TLinkToolButton( Sender );
5211         SenderNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
5212         SenderNode.Selected := False;
5213         FavoriteDragDrop( SenderNode, Source );
5214
5215         SetLinkBar;
5216
5217 end;
5218
5219 procedure TGikoForm.LinkToolButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5220 var
5221         favButton                       : TLinkToolButton;
5222         favThreadItem   : TFavoriteThreadItem;
5223 begin
5224
5225         case Button of
5226         mbMiddle:
5227                 begin
5228                         if Sender is TLinkToolButton then begin
5229                                 favButton := TLinkToolButton( Sender );
5230                                 if TObject( favButton.Data ) is TFavoriteThreadItem then begin
5231                                         favThreadItem := TFavoriteThreadItem( favButton.Data );
5232                                         if favThreadItem.Item <> nil then
5233                                                 InsertBrowserTab( favThreadItem.Item, False );
5234                                 end;
5235                         end;
5236                 end;
5237         end;
5238
5239 end;
5240
5241 procedure TGikoForm.LinkToolButtonOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
5242 var
5243         Now : Cardinal;
5244 begin
5245         TToolButton( Sender ).DragMode := dmManual;
5246         if ssLeft in Shift then begin
5247 //              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)
5248                 if FDragTime = 0 then begin
5249                         FDragTime := GetTickCount();
5250                 end else begin
5251                         Now := GetTickCount();
5252                         if (Now - FDragTime) > 500 then begin
5253                                 if FDragButton <> TToolButton( Sender ) then begin
5254                                         try
5255                                                 FDragButton := TToolButton( Sender );
5256                                                 TToolButton(Sender).BeginDrag(false ,5);
5257                                                 FDragTime := 0;
5258                                         except
5259                                                 {$IF Defined(debug)}
5260                                                 ShowMessage('Error');
5261                                                 {$IFEND}
5262                                         end;
5263                                 end;
5264                         end;
5265                 end;
5266         end else begin
5267                 FDragTime := 0;
5268         end;
5269 end;
5270
5271 procedure TGikoForm.LinkToolButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5272 begin
5273         FDragTime := 0;
5274 end;
5275
5276 function TGikoForm.GetWidthAllToolButton(ToolBar: TToolBar): Integer;
5277 var
5278         i: Integer;
5279 begin
5280         Result := 0;
5281         for i := 0 to ToolBar.ButtonCount - 1 do
5282                 if ToolBar.Buttons[i].Visible then
5283                         Result := Result + ToolBar.Buttons[i].Width;
5284 end;
5285
5286 procedure TGikoForm.MainCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5287 var
5288         Control : TWinControl;
5289         i, idx  : Integer;
5290 begin
5291         Control := FindControl(BandInfo^.hwndChild);
5292         if Control = nil then
5293                 Exit;
5294         idx := 0;
5295         for i := MainCoolBar.Bands.Count - 1 downto 0 do begin
5296                 if MainCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5297                         idx := MainCoolBar.Bands[ i ].ID;
5298                         Break;
5299                 end;
5300         end;
5301         Canvas.Font.Handle := GetStockObject( DEFAULT_GUI_FONT );
5302         if (Control = MenuToolBar) or (Control = StdToolBar) then begin
5303                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5304                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5305                 BandInfo^.cxMinChild    := 0;
5306                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth;
5307                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5308         end else if Control = LinkToolBar then begin
5309                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5310                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5311                 BandInfo^.cxMinChild    := 0;
5312                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83\8a\83\93\83N' );
5313                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5314         end else begin // AddressToolBar
5315                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5316                 BandInfo^.cxMinChild    := 0;
5317                 BandInfo^.cx                                    := GikoSys.Setting.MainCoolSet[ idx ].FCoolWidth + Canvas.TextWidth( '\83A\83h\83\8c\83X' );
5318         end;
5319 end;
5320
5321 procedure TGikoForm.MainCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5322 var
5323         i : Integer;
5324         Idx: Integer;
5325         p: TPoint;
5326 begin
5327         ChevronPopupMenu.Items.Clear;
5328         Idx := 0;
5329         for i := 0 to MainCoolBar.Bands.Count - 1 do begin
5330                 if MainCoolBar.Bands[ i ].Visible then begin
5331                         if Idx = Int64(RebarChevron^.uBand) then begin
5332                                 Idx := i;
5333                                 break;
5334                         end;
5335                         Inc( Idx );
5336                 end;
5337         end;
5338         if (Idx >= 0) and (MainCoolBar.Bands.Count > Idx) then begin
5339                 if MainCoolBar.Bands[Idx].Control = MenuToolbar then begin
5340                         MenuBarChevronMenu;
5341                 end else if MainCoolBar.Bands[Idx].Control = StdToolbar then begin
5342                         ToolBarChevronMenu(StdToolBar);
5343                 end else if MainCoolBar.Bands[Idx].Control = LinkToolbar then begin
5344                         LinkBarChevronMenu;
5345                 end else
5346                         Exit;
5347                 p := MainCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5348                 ChevronPopupMenu.Popup(p.x, p.y);
5349         end;
5350 end;
5351
5352 procedure TGikoForm.MenuBarChevronMenu;
5353         procedure SetSubMenu(MenuItem: TMenuItem; PopupItem: TMenuItem);
5354         var
5355                 i: Integer;
5356                 Item: TMenuItem;
5357         begin
5358                 MenuItem.Click;
5359                 for i := 0 to MenuItem.Count - 1 do begin
5360 //                      Item := nil;
5361                         if MenuItem[i] is TFavoriteMenuItem then begin
5362                                 Item := TFavoriteMenuItem.Create(Self);
5363                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(MenuItem[i]).Data;
5364                         end else
5365                                 Item := TMenuItem.Create(Self);
5366                         Item.Caption := MenuItem[i].Caption;
5367                         Item.Action := MenuItem[i].Action;
5368                         Item.ImageIndex := MenuItem[i].ImageIndex;
5369                         Item.OnClick := MenuItem[i].OnClick;
5370                         PopupItem.Add(Item);
5371                         if MenuItem[i].Count > 0 then
5372                                 SetSubMenu(MenuItem[i], Item);
5373                 end;
5374         end;
5375 var
5376         i: Integer;
5377         w: Integer;
5378         bw: Integer;
5379         Item: TMenuItem;
5380 begin
5381         ChevronPopupMenu.Items.Clear;
5382         ChevronPopupMenu.Images := MainMenu.Images;
5383         bw := GetWidthAllToolButton(MenuToolBar);
5384         if MenuToolBar.Width < bw then begin
5385                 w := 0;
5386                 for i := 0 to MenuToolBar.ButtonCount - 1 do begin
5387                         w := w + MenuToolBar.Buttons[i].Width;
5388                         if MenuToolBar.Width <= w then begin
5389                                 Item := TMenuItem.Create(Self);
5390                                 Item.Caption := MenuToolBar.Buttons[i].MenuItem.Caption;
5391                                 //Item.Action := MenuToolBar.Buttons[i].MenuItem.Action;
5392                                 ChevronPopupMenu.Items.Add(Item);
5393                                 SetSubMenu(MenuToolbar.Buttons[i].MenuItem, Item);
5394                         end;
5395                 end;
5396         end;
5397 end;
5398
5399 procedure TGikoForm.ToolBarChevronMenu(ToolBar: TToolBar);
5400         procedure SetSubMenu(PopupMenu: TPopupMenu; PopupItem: TMenuItem);
5401         var
5402                 i: Integer;
5403                 Item: TMenuItem;
5404         begin
5405                 if Assigned(PopupMenu.OnPopup) then
5406                         PopupMenu.OnPopup(nil);
5407                 for i := 0 to PopupMenu.Items.Count - 1 do begin
5408 //                      Item := nil;
5409                         if PopupMenu.Items[i] is TFavoriteMenuItem then begin
5410                                 Item := TFavoriteMenuItem.Create(Self);
5411                                 TFavoriteMenuItem(Item).Data := TFavoriteMenuItem(PopupMenu.Items[i]).Data;
5412                         end else
5413                         Item := TMenuItem.Create(Self);
5414                         Item.Caption := PopupMenu.Items[i].Caption;
5415                         Item.Action := PopupMenu.Items[i].Action;
5416                         Item.ImageIndex := PopupMenu.Items[i].ImageIndex;
5417                         Item.OnClick := PopupMenu.Items[i].OnClick;
5418                         PopupItem.Add(Item);
5419                 end;
5420         end;
5421 var
5422         i: Integer;
5423         w: Integer;
5424         bw: Integer;
5425         Item: TMenuItem;
5426 begin
5427         ChevronPopupMenu.Items.Clear;
5428         ChevronPopupMenu.Images := ToolBar.HotImages;
5429         bw := GetWidthAllToolButton(ToolBar);
5430         if ToolBar.Width < bw then begin
5431                 w := 0;
5432                 for i := 0 to ToolBar.ButtonCount - 1 do begin
5433                         if ToolBar.Buttons[i].Visible then
5434                                 w := w + ToolBar.Buttons[i].Width;
5435                         if ToolBar.Width <= w then begin
5436                                 if ToolBar.Buttons[i].Tag = 0 then begin
5437                                         Item := TMenuItem.Create(Self);
5438                                         if ToolBar.Buttons[i].Style = tbsSeparator then
5439                                                 Item.Caption := '-'
5440                                         else begin
5441                                                 //\83X\83\8c\8di\8d\9e\82ÝComBox\82ÌTPanel\82ð\94r\8f\9c\82·\82é
5442                                                 if TObject(ToolBar.Buttons[i]) is TPanel then begin
5443                                                         Continue;
5444                                                 end else begin
5445                                                         Item.Caption := ToolBar.Buttons[i].Caption;
5446                                                         Item.Action := ToolBar.Buttons[i].Action;
5447                                                 end;
5448                                                 //Item.Visible := True;
5449                                         end;
5450                                         ChevronPopupMenu.Items.Add(Item);
5451                                         if ToolBar.Buttons[i].DropdownMenu <> nil then begin
5452                                                 Item.Action := nil;
5453                                                 Item.OnClick := nil;
5454                                                 SetSubMenu(ToolBar.Buttons[i].DropdownMenu, Item);
5455                                         end;
5456                                 end;
5457                         end;
5458                 end;
5459         end;
5460 end;
5461
5462 procedure TGikoForm.LinkBarChevronMenu;
5463 var
5464         i: Integer;
5465         j: Integer;
5466         w: Integer;
5467         Item: TFavoriteMenuItem;
5468         bw: Integer;
5469         Button: TLinkToolButton;
5470 begin
5471         ChevronPopupMenu.Items.Clear;
5472         ChevronPopupMenu.Images := LinkToolBar.Images;
5473         bw := GetWidthAllToolButton(LinkToolBar);
5474         if LinkToolBar.Width < bw then begin
5475                 w := 0;
5476                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
5477                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
5478                                 for j := 0 to FavoriteTreeView.Items[i].Count - 1 do begin
5479                                         w := w + LinkToolBar.Buttons[j].Width;
5480                                         if LinkToolBar.Width <= w then begin
5481                                                 if LinkToolBar.Buttons[j] is TLinkToolButton then begin
5482                                                         Button := TLinkToolButton(LinkToolBar.Buttons[j]);
5483                                                         Item := TFavoriteMenuItem.Create(Self);
5484                                                         if TObject(Button.Data) is TFavoriteFolder then begin
5485                                                                 CreateFavMenu(FavoriteTreeView.Items[i].Item[j], Item);
5486                                                         end else if TObject(Button.Data) is TFavoriteBoardItem then begin
5487                                                                 Item.OnClick := FavoriteClick;
5488                                                         end else if TObject(Button.Data) is TFavoriteThreadItem then begin
5489                                                                 Item.OnClick := FavoriteClick;
5490                                                         end;
5491                                                         Item.Data := Button.Data;
5492                                                         Item.Caption := LinkToolBar.Buttons[j].Caption;
5493                                                         Item.ImageIndex := LinkToolBar.Buttons[j].ImageIndex;
5494                                                         ChevronPopupMenu.Items.Add(Item);
5495                                                 end;
5496                                         end;
5497                                 end;
5498                                 break;
5499                         end;
5500                 end;
5501         end;
5502 end;
5503
5504 {!
5505 \brief  \83o\83\93\83h\95\9d\82ð\8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é
5506 \param  bar             \83o\83\93\83h\82ª\8f\8a\91®\82·\82é CoolBar
5507 \param  band    \8dÄ\8cv\8eZ\81E\8dÄ\90Ý\92è\82·\82é\83o\83\93\83h
5508
5509 \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É
5510 \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
5511 }
5512 procedure TGikoForm.ResetBandInfo( bar : TGikoCoolBar; band : TToolBar );
5513 var
5514         bandInfo        : tagREBARBANDINFOA;
5515         pBandInfo       : PReBarBandInfoA;
5516         lResult         : Integer;
5517         h                                       : HWND;
5518         i, idx          : Integer;
5519 begin
5520
5521         h                                                                               := band.Handle;
5522         pBandInfo := @bandInfo;
5523         ZeroMemory( pBandInfo, sizeof( bandInfo ) );
5524         bandInfo.cbSize                 := sizeof( bandInfo );
5525         bandInfo.hwndChild      := h;
5526         bandInfo.cyMinChild     := bar.Height;
5527         bar.OnBandInfo( nil, pBandInfo );
5528         // band \82Ì\83C\83\93\83f\83b\83N\83X\82ð\92T\82·
5529         idx := 0;
5530         for i := bar.Bands.Count - 1 downto 0 do begin
5531                 if bar.Bands[ i ].Control.Handle = h then begin
5532                         idx := i;
5533                         Break;
5534                 end;
5535         end;
5536         // \90Ý\92è
5537         lResult := SendMessage( bar.Handle, RB_SETBANDINFO, idx, Integer( pBandInfo ) );
5538
5539 end;
5540
5541 procedure TGikoForm.ListCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5542 var
5543         Control: TWinControl;
5544         i, idx  : Integer;
5545 begin
5546         Control := FindControl(BandInfo^.hwndChild);
5547         if Control = nil then
5548                 Exit;
5549         idx := 0;
5550         for i := ListCoolBar.Bands.Count - 1 downto 0 do begin
5551                 if ListCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5552                         idx := ListCoolBar.Bands[ i ].ID;
5553                         Break;
5554                 end;
5555         end;
5556         if Control = ListToolBar then begin
5557                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5558                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5559                 BandInfo^.cxMinChild    := 0;
5560                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5561                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5562         end else begin
5563                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5564                 BandInfo^.cxMinChild    := 0;
5565                 BandInfo^.cx                                    := GikoSys.Setting.ListCoolSet[ idx ].FCoolWidth;
5566         end;
5567 end;
5568
5569 procedure TGikoForm.ListCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5570 var
5571         Idx: Integer;
5572         p: TPoint;
5573 begin
5574         ChevronPopupMenu.Items.Clear;
5575         Idx := RebarChevron^.uBand;
5576         if (Idx >= 0) and (ListCoolBar.Bands.Count > Idx) then begin
5577                 if ListCoolBar.Bands[Idx].Control = ListToolBar then begin
5578                         ToolBarChevronMenu(ListToolBar);
5579                 end else
5580                         Exit;
5581                 p := ListCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5582                 ChevronPopupMenu.Popup(p.x, p.y);
5583         end;
5584 end;
5585
5586 procedure TGikoForm.BrowserCoolBarBandInfo(Sender: TObject; var BandInfo: PReBarBandInfoA);
5587 var
5588         Control: TWinControl;
5589         i, idx  : Integer;
5590 begin
5591         Control := FindControl(BandInfo^.hwndChild);
5592         if Control = nil then
5593                 Exit;
5594         idx := 0;
5595         for i := BrowserCoolBar.Bands.Count - 1 downto 0 do begin
5596                 if BrowserCoolBar.Bands[ i ].Control.Handle = Control.Handle then begin
5597                         idx := BrowserCoolBar.Bands[ i ].ID;
5598                         Break;
5599                 end;
5600         end;
5601         if Control = BrowserToolBar then begin
5602                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE or RBBIM_STYLE or RBBIM_IDEALSIZE;
5603                 BandInfo^.fStyle                        := BandInfo.fStyle or RBBS_USECHEVRON;
5604                 BandInfo^.cxMinChild    := 0;
5605                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5606                 BandInfo^.cxIdeal                       := GetWidthAllToolButton(TToolBar(Control));
5607         end else begin
5608                 BandInfo^.fMask                         := BandInfo.fMask or RBBIM_CHILDSIZE;
5609                 BandInfo^.cxMinChild    := 0;
5610                 BandInfo^.cx                                    := GikoSys.Setting.BrowserCoolSet[ idx ].FCoolWidth;
5611         end;
5612 end;
5613
5614 procedure TGikoForm.BrowserCoolBarChevronClick(Sender: TObject; RebarChevron: PNMRebarChevron);
5615 var
5616         Idx: Integer;
5617         p: TPoint;
5618 begin
5619         ChevronPopupMenu.Items.Clear;
5620         Idx := RebarChevron^.uBand;
5621         if (Idx >= 0) and (BrowserCoolBar.Bands.Count > Idx) then begin
5622                 if BrowserCoolBar.Bands[Idx].Control = BrowserToolBar then
5623                         ToolBarChevronMenu(BrowserToolBar)
5624                 else
5625                         Exit;
5626                 p := BrowserCoolBar.ClientToScreen(Point(RebarChevron^.rc.left, RebarChevron^.rc.bottom));
5627                 ChevronPopupMenu.Popup(p.x, p.y);
5628         end;
5629 end;
5630
5631 procedure TGikoForm.ListViewColumnInfo(Sender: TObject; var Column: PLVColumnA);
5632 begin
5633         if Column^.iImage = -1 then begin
5634                 Column^.mask := Column^.mask or LVCF_FMT;
5635         end else begin
5636                 Column^.mask := Column^.mask or LVCF_FMT or LVCF_IMAGE;
5637                 Column^.fmt := Column^.fmt or LVCFMT_IMAGE or LVCFMT_BITMAP_ON_RIGHT;
5638         end;
5639 end;
5640
5641 function TGikoForm.FindToolBarButton( bar : TToolBar; action : TAction ) : TToolButton;
5642 var
5643         i : Integer;
5644 begin
5645         Result := nil;
5646         for i := bar.ButtonCount - 1 downto 0 do begin
5647                 if bar.Buttons[ i ].Action = action then begin
5648                         Result := bar.Buttons[ i ];
5649                         Break;
5650                 end;
5651         end;
5652 end;
5653
5654 procedure TGikoForm.SetToolBarPopup;
5655 var
5656         i                                                                       : Integer;
5657         aIEButton                                       : TToolButton;
5658         aCabinetBBSButton       : TToolButton;
5659         aResRangeButton         : TToolButton;
5660         aThreadRangeButton:     TToolButton;
5661 begin
5662         for i := 0 to StdToolBar.ButtonCount - 1 do begin
5663         end;
5664         for i := 0 to ListToolBar.ButtonCount - 1 do begin
5665                 if ListToolBar.Buttons[i].Action = GikoDM.IconStyle then
5666                         ListToolBar.Buttons[i].DropdownMenu := ListIconPopupMenu;
5667                 if ListToolBar.Buttons[i].Action = GikoDM.SelectReservAction then
5668                         ListToolBar.Buttons[i].DropdownMenu := RoundNamePopupMenu;
5669         end;
5670         aIEButton                                       := FindToolBarButton( BrowserToolBar, GikoDM.IEAction );
5671         if aIEButton <> nil then
5672                 aIEButton.DropdownMenu                                  := BrowserPopupMenu;
5673         aCabinetBBSButton       := FindToolBarButton( StdToolBar, GikoDM.CabinetBBSAction );
5674         if aCabinetBBSButton <> nil then
5675                 aCabinetBBSButton.DropdownMenu  := BBSSelectPopupMenu;
5676         aResRangeButton         := FindToolBarButton( BrowserToolBar, GikoDM.ResRangeAction );
5677         if aResRangeButton <> nil then
5678                 aResRangeButton.DropdownMenu            := ResRangePopupMenu;
5679         aThreadRangeButton:= FindToolBarButton( ListToolBar, GikoDM.ThreadRangeAction );
5680         if aThreadRangeButton <> nil then
5681                 aThreadRangeButton.DropdownMenu := ThreadRangePopupMenu;
5682 end;
5683
5684 procedure TGikoForm.FormMouseWheel(Sender: TObject; Shift: TShiftState;
5685         WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
5686 var
5687         Wnd: THandle;
5688         delta: Integer;
5689 //      browserPos : TPoint;
5690 const
5691         ICON_SIZE = 16;
5692 begin
5693         Wnd := WindowFromPoint(Mouse.CursorPos);
5694         Handled := True;
5695         if WheelDelta > 0 then
5696                 Delta := -1
5697         else
5698                 Delta := 1;
5699
5700         if (Wnd = BrowserTab.Handle) or
5701                  (Wnd = BrowserTab.Parent.Handle) then begin
5702                 BrowserTab.ScrollTabs(Delta);
5703         end else begin
5704                 if FIsHandledWheel then begin
5705                         FIsHandledWheel := False;
5706                         Handled := False;
5707                 end else begin
5708                         FIsHandledWheel := True;
5709                         if (Wnd = TreeView.Handle) or  (Wnd = FavoriteTreeView.Handle)
5710                         or (Wnd = ListView.Handle) or (Wnd = MessageListView.Handle)
5711                         then
5712                                 SendMessage( Wnd, WM_MOUSEWHEEL, WheelDelta shl 16, (Mouse.CursorPos.X shl 16) or Mouse.CursorPos.Y )
5713                         else
5714                                 Handled := False;
5715
5716                 end;
5717         end;
5718 end;
5719
5720 procedure TGikoForm.SetSelectWord( const text : string );
5721 begin
5722
5723         if Length( text ) = 0 then
5724         begin
5725                 GikoDM.AllItemAction.Checked := True;
5726                 GikoDM.LogItemAction.Checked := False;
5727                 GikoDM.NewItemAction.Checked := False;
5728         end else begin
5729                 // \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é
5730                 if GikoDM.AllItemAction.Checked then
5731                         GikoDM.AllItemAction.Checked := False;
5732                 if GikoDM.LogItemAction.Checked then
5733                         GikoDM.LogItemAction.Checked := False;
5734                 if GikoDM.NewItemAction.Checked then
5735                         GikoDM.NewItemaction.Checked := False;
5736         end;
5737
5738         if Length( text ) = 0 then
5739                 SetListViewType( gvtAll )
5740         else
5741                 SetListViewType( gvtUser, text, false );
5742
5743 end;
5744
5745 procedure TGikoForm.SelectComboBoxChange(Sender: TObject);
5746 begin
5747
5748         SetSelectWord( SelectComboBox.Text );
5749
5750 end;
5751
5752 procedure TGikoForm.SelectComboBoxKeyDown(Sender: TObject; var Key: Word;
5753         Shift: TShiftState);
5754 var
5755   IMC: HIMC;
5756   Len: integer;
5757   Str: string;
5758   tmp: string;
5759 begin
5760
5761         if Key = VK_Return then
5762         begin
5763                 ModifySelectList;
5764         end else if Key = 229 then begin
5765                 if GikoSys.Setting.UseUndecided then begin
5766                         IMC := ImmGetContext(SelectComboBox.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
5767                         Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5768                         SetLength(Str, Len + 1); //Buffer\82Ì\83\81\83\82\83\8a\82ð\90Ý\92è
5769                         ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
5770                         ImmReleaseContext(SelectComboBox.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
5771                         SetLength(Str, Len);
5772                         if SelectComboBox.SelLength > 0 then begin //\91I\91ð\92\86\82Ì\95\8e\9a\97ñ\82ª\82 \82é\82©
5773                                 tmp := Copy(SelectComboBox.Text, 1, SelectComboBox.SelStart);
5774                                 Str := tmp + Str + Copy(SelectComboBox.Text, SelectComboBox.SelStart + SelectComboBox.SelLength + 1, Length(SelectComboBox.Text));
5775                         end else
5776                                 Str := SelectComboBox.Text + Str;
5777
5778                         SetSelectWord(Str);
5779                 end;
5780         end else if Length( SelectComboBox.Text ) = 0 then
5781         begin
5782                 {* SelectComboBox.Text\82ª\8bó\82Å\82à\81A\93ü\97Í\93r\92\86\82ÅEsc\82µ\82½\82Æ\82©
5783                  * \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
5784                  * \81i\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢\81j
5785                  *}
5786         end else begin
5787                 // \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é
5788                 if GikoDM.AllItemAction.Checked then
5789                         GikoDM.AllItemAction.Checked := False;
5790                 if GikoDM.LogItemAction.Checked then
5791                         GikoDM.LogItemAction.Checked := False;
5792                 if GikoDM.NewItemAction.Checked then
5793                         GikoDM.NewItemaction.Checked := False;
5794         end;
5795
5796 end;
5797
5798 procedure TGikoForm.SelectComboBoxExit(Sender: TObject);
5799 begin
5800
5801         ModifySelectList;
5802
5803         if Length( SelectComboBox.Text ) = 0 then
5804         begin
5805                 SelectComboBox.Text := GikoDataModule.SELECTCOMBOBOX_NAME;
5806                 SelectComboBox.Color := GikoDataModule.SELECTCOMBOBOX_COLOR;
5807         end;
5808
5809 end;
5810
5811 // \8di\82è\8d\9e\82Ý\8c\9f\8dõ\82Ì\97\9a\97ð\8dX\90V
5812 procedure TGikoForm.ModifySelectList;
5813 var
5814         idx : Integer;
5815         oldText : string;
5816 begin
5817
5818         try
5819                 if not SelectComboBoxPanel.Visible then
5820                         exit;
5821
5822                 if Length( SelectComboBox.Text ) > 0 then
5823                 begin
5824                         oldText := SelectComboBox.Text;
5825                         idx := GikoSys.Setting.SelectTextList.IndexOf( oldText );
5826                         if idx <> -1 then
5827                                 GikoSys.Setting.SelectTextList.Delete( idx );
5828                         idx := SelectComboBox.Items.IndexOf( oldText );
5829                         if idx <> -1 then
5830                                 SelectComboBox.Items.Delete( idx );
5831                         GikoSys.Setting.SelectTextList.Insert( 0, oldText );
5832                         SelectComboBox.Items.Insert( 0, oldText );
5833                         SelectComboBox.Text := oldText;
5834                 end;
5835         except
5836         end;
5837
5838 end;
5839
5840
5841 procedure TGikoForm.SelectComboBoxSplitterMouseMove(Sender: TObject;
5842         Shift: TShiftState; X, Y: Integer);
5843 var
5844         pos                             : TPoint;
5845         w                                       : Integer;
5846 begin
5847         If (SelectComboBoxPanel.Visible) and (IsDraggingSelectComboBox) Then begin
5848                 pos.X := X;
5849                 pos.Y := Y;
5850                 pos := SelectComboBoxSplitter.ClientToScreen( pos );
5851                 //w := SelectComboBox.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5852                 w := SelectComboBoxPanel.Width + (pos.X - DraggingSelectComboBoxPosition.X);
5853
5854                 If w <= 50 Then Begin
5855                         // \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­
5856                         // \81u\8e~\82Ü\82Á\82½(50pixel)\88Ê\92u\81v\82É\82È\82é\82æ\82¤\82É
5857                         pos.X := pos.X + (50 - w);
5858
5859                         // \8f¬\82³\82­\82È\82è\82·\82¬\82È\82¢\82æ\82¤\82É
5860                         w := 50;
5861                 End;
5862
5863                 // \83`\83\89\82Â\82«\8cy\8c¸\82Ì\88×
5864                 //If SelectComboBox.Width <> w Then Begin
5865                 If SelectComboBoxPanel.Width <> w Then Begin
5866                         SelectComboBoxPanel.Width := w;
5867                         SelectComboBox.Width := SelectComboBoxPanel.Width - SelectComboBoxSplitter.Width;
5868                         GikoSys.Setting.SelectComboBoxWidth := w;
5869                         DraggingSelectComboBoxPosition := pos;
5870
5871                         // \83V\83F\83u\83\8d\83\93\88Ê\92u\82ª\95Ï\82í\82é\82Ì\82Å BandInfo \82Ì\8dÄ\90Ý\92è
5872                         ResetBandInfo( ListCoolBar, ListToolBar );
5873                 End;
5874         End;
5875
5876 end;
5877
5878 procedure TGikoForm.SelectComboBoxSplitterMouseDown(Sender: TObject;
5879         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5880 var
5881         pos : TPoint;
5882 begin
5883         IsDraggingSelectComboBox := True;
5884         pos.X := X;
5885         pos.Y := Y;
5886         DraggingSelectComboBoxPosition := SelectComboBoxSplitter.ClientToScreen( pos );
5887
5888 end;
5889
5890 procedure TGikoForm.SelectComboBoxSplitterMouseUp(Sender: TObject;
5891         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
5892 begin
5893         IsDraggingSelectComboBox := False;
5894
5895 end;
5896
5897 procedure TGikoForm.StatusBarResize(Sender: TObject);
5898 begin
5899         StatusBar.Panels[1].Width := StatusBar.Width -
5900                                                                                                                          StatusBar.Panels[0].Width -
5901                                                                                                                          StatusBar.Panels[2].Width;
5902 end;
5903 procedure TGikoForm.SelectComboBoxEnter(Sender: TObject);
5904 begin
5905
5906         if (Length( SelectComboBox.Text ) = 0) or
5907                 (SelectComboBox.Text = GikoDataModule.SELECTCOMBOBOX_NAME) then
5908         begin
5909                 SelectComboBox.Text := '';
5910                 SelectComboBox.Color := clWindow;
5911         end;
5912
5913 end;
5914
5915 procedure TGikoForm.FavoriteMoveTo( SenderNode, SourceNode: TTreeNode );
5916 begin
5917
5918         if (SenderNode = nil) or (SourceNode = nil) or (SenderNode = SourceNode) then
5919                 Exit;
5920
5921         if TObject(SenderNode.Data) is TFavoriteFolder then
5922                 SourceNode.MoveTo(SenderNode, naAddChild)
5923         else
5924                 SourceNode.MoveTo(SenderNode, naInsert);
5925
5926 end;
5927
5928 procedure TGikoForm.FavoriteAddTo( SenderNode: TTreeNode; Source: TObject );
5929 var
5930         Node: TTreeNode;
5931         FavNode: TTreeNode;
5932         FavoBoardItem: TFavoriteBoardItem;
5933         FavoThreadItem: TFavoriteThreadItem;
5934         Board: TBoard;
5935         ThreadItem: TThreadItem;
5936 begin
5937
5938         if (SenderNode = nil) or (Source = nil) then
5939                 Exit;
5940
5941         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
5942                 FavNode := SenderNode.Parent
5943         else
5944                 FavNode := SenderNode;
5945
5946         Node := nil;
5947
5948         if Source is TBoard then begin
5949                 Board := TBoard( Source );
5950                 FavoBoardItem                           := TFavoriteBoardItem.CreateWithItem( Board );
5951                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, FavoBoardItem);
5952                 Node.ImageIndex := 15;
5953                 Node.SelectedIndex := 15;
5954         end else if Source is TFavoriteBoardItem then begin
5955                 FavoBoardItem := TFavoriteBoardItem( Source );
5956                 Board := FavoBoardItem.Item;
5957                 if Board <> nil then
5958                         if not Board.IsThreadDatRead then
5959                                 GikoSys.ReadSubjectFile(Board);
5960                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Board.Title, Source);
5961                 Node.ImageIndex := 15;
5962                 Node.SelectedIndex := 15;
5963         end else if Source is TThreadItem then begin
5964                 ThreadItem := TThreadItem( Source );
5965                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
5966                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
5967                 Node.ImageIndex := 16;
5968                 Node.SelectedIndex := 16;
5969         end else if Source is TBrowserRecord then begin
5970                 ThreadItem := TBrowserRecord( Source ).Thread;
5971                 FavoThreadItem                          := TFavoriteThreadItem.CreateWithItem( ThreadItem );
5972                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, FavoThreadItem);
5973                 Node.ImageIndex := 16;
5974                 Node.SelectedIndex := 16;
5975         end else if Source is TFavoriteThreadItem then begin
5976                 FavoThreadItem := TFavoriteThreadItem( Source );
5977                 ThreadItem := FavoThreadItem.Item;
5978                 Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, ThreadItem.Title, Source);
5979                 Node.ImageIndex := 16;
5980                 Node.SelectedIndex := 16;
5981         end;
5982
5983         if not (TObject(SenderNode.Data) is TFavoriteFolder) then
5984                 if Node <> nil then
5985                         FavoriteMoveTo( SenderNode, Node );
5986
5987 end;
5988
5989 procedure TGikoForm.FavoriteDragDrop( SenderNode: TTreeNode; Source: TObject );
5990 var
5991         idx: Integer;
5992         SourceNode: TTreeNode;
5993         LinkToolButton: TLinkToolButton;
5994 begin
5995
5996         if SenderNode = nil then
5997                 Exit;
5998
5999         if not (TObject( SenderNode.Data ) is TFavoriteFolder) then
6000                 if FDropSpaceNode <> nil then
6001                         SenderNode := FDropSpaceNode;
6002
6003         if Source = FavoriteTreeView then begin
6004                 SourceNode := FavoriteTreeView.Selected;
6005                 FavoriteMoveTo( SenderNode, SourceNode );
6006         end else if Source is TLinkToolButton then begin
6007                 LinkToolButton := TLinkToolButton( Source );
6008                 SourceNode := TreeNodeDataFind( FavoriteTreeView.Items.GetFirstNode, LinkToolButton.Data );
6009                 FavoriteMoveTo( SenderNode, SourceNode );
6010         end else if Source = BrowserTab then begin
6011                 idx := BrowserTab.TabIndex;
6012                 FavoriteAddTo( SenderNode, BrowserTab.Tabs.Objects[idx] );
6013         end else if Source = ListView then begin
6014                 FavoriteAddTo( SenderNode, ListView.Selected.Data );
6015         end else if Source = TreeView then begin
6016                 FavoriteAddTo( SenderNode, TreeView.Selected.Data );
6017         end;
6018 end;
6019
6020 procedure TGikoForm.FavoriteTreeViewDragDrop(Sender, Source: TObject; X,
6021         Y: Integer);
6022 var
6023         SenderNode: TTreeNode;
6024 begin
6025
6026         SenderNode := FavoriteTreeView.GetNodeAt(X, Y);
6027         if SenderNode <> nil then begin
6028                 FavoriteDragDrop( SenderNode, Source );
6029         end;
6030
6031         //\8bó\94\92\8d\80\96Ú\82ª\82¢\82½\82ç\8dí\8f\9c\82·\82é
6032         if FDropSpaceNode <> nil then begin
6033                 try
6034                         FDropSpaceNode.Delete;
6035                 finally
6036                         FDropSpaceNode := nil;
6037                 end;
6038         end;
6039
6040         SetLinkBar;
6041
6042 end;
6043
6044 procedure TGikoForm.FavoriteTreeViewEdited(Sender: TObject;
6045         Node: TTreeNode; var S: String);
6046 begin
6047
6048         FavoriteTreeView.ReadOnly := True;
6049         SetLinkBar;
6050
6051 end;
6052
6053 procedure TGikoForm.FavoriteTreeViewKeyDown(Sender: TObject; var Key: Word;
6054         Shift: TShiftState);
6055 begin
6056         if not TTreeView(Sender).IsEditing then begin
6057                 Case Key of
6058                 VK_F2:
6059                         begin
6060                                 FClickNode := FavoriteTreeView.Selected;
6061                                 GikoDM.FavoriteTreeViewRenameActionExecute( Sender );
6062                         end;
6063                 VK_DELETE:
6064                         begin
6065                                 FClickNode := FavoriteTreeView.Selected;
6066                                 GikoDM.FavoriteTreeViewDeleteActionExecute( Sender );
6067                         end;
6068                 VK_RETURN:
6069                         begin
6070                         FavoriteClick( FavoriteTreeView.Selected );
6071                         FavoriteTreeView.Selected.Expanded := not FavoriteTreeView.Selected.Expanded;
6072                         end;
6073                 VK_SPACE:
6074                         FavoriteTreeViewDblClick( Sender );
6075                 end;
6076         end else begin
6077                 //\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·
6078                 if Key = VK_ESCAPE then begin
6079                         if (TTreeView(Sender).Selected <> nil) then begin
6080                                 TTreeView(Sender).Selected.Text := FOrigenCaption;
6081                         end;
6082                         TTreeView(Sender).Selected.Focused := False;
6083                 end;
6084         end;
6085
6086 end;
6087
6088 procedure TGikoForm.FavoriteTreePopupMenuPopup(Sender: TObject);
6089 var
6090         i: Integer;
6091         LinkToolButton: TLinkToolButton;
6092 begin
6093
6094         if FavoriteTreePopupMenu.PopupComponent = FavoriteTreeView then begin
6095         
6096                 FClickNode := FavoriteTreeView.Selected;
6097
6098         end else if FavoriteTreePopupMenu.PopupComponent is TLinkToolButton then begin
6099
6100                 LinkToolButton := TLinkToolButton( FavoriteTreePopupMenu.PopupComponent );
6101                 for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6102                         if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6103                                 FClickNode := FavoriteTreeView.Items[i];
6104                                 Break;
6105                         end;
6106                 end;
6107                 for i := 0 to FClickNode.Count - 1 do begin
6108                         if FClickNode.Item[i].Data = LinkToolButton.Data then begin
6109                                 FClickNode := FClickNode.Item[i];
6110                                 Break;
6111                         end;
6112                 end;
6113
6114         end;
6115
6116         if FClickNode = nil then begin
6117                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6118                 FavoriteTreeDeletePopupMenu.Visible := False;
6119                 FavoriteTreeRenamePopupMenu.Visible := False;
6120                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6121                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6122                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6123                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6124                 FavoriteTreeReloadPopupMenu.Visible := False;
6125                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6126         end else if FClickNode.IsFirstNode then begin
6127                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6128                 FavoriteTreeDeletePopupMenu.Visible := False;
6129                 FavoriteTreeRenamePopupMenu.Visible := False;
6130                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6131                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6132                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6133                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6134                 FavoriteTreeReloadPopupMenu.Visible := False;
6135                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6136         end else if FClickNode.Text = Favorite.FAVORITE_LINK_NAME then begin
6137                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6138                 FavoriteTreeDeletePopupMenu.Visible := True;
6139                 FavoriteTreeRenamePopupMenu.Visible := False;
6140                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6141                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6142                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6143                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6144                 FavoriteTreeReloadPopupMenu.Visible := False;
6145                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6146         end else if TObject(FClickNode.Data) is TFavoriteFolder then begin
6147                 FavoriteTreeBrowseFolderPopupMenu.Visible := True;
6148                 FavoriteTreeDeletePopupMenu.Visible := True;
6149                 FavoriteTreeRenamePopupMenu.Visible := True;
6150                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6151                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6152                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6153                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6154                 FavoriteTreeReloadPopupMenu.Visible := False;
6155                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6156         end else if TObject(FClickNode.Data) is TFavoriteThreadItem then begin
6157                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6158                 FavoriteTreeDeletePopupMenu.Visible := True;
6159                 FavoriteTreeRenamePopupMenu.Visible := True;
6160                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6161                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6162                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6163                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6164                 FavoriteTreeReloadPopupMenu.Visible := True;
6165                 FavoriteTreeLogDeletePopupMenu.Visible := True;
6166         end else if TObject(FClickNode.Data) is TFavoriteBoardItem then begin
6167                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6168                 FavoriteTreeDeletePopupMenu.Visible := True;
6169                 FavoriteTreeRenamePopupMenu.Visible := True;
6170                 FavoriteTreeNewFolderPopupMenu.Visible := True;
6171                 FavoriteTreeURLCopyPopupMenu.Visible := True;
6172                 FavoriteTreeNameCopyPopupMenu.Visible := True;
6173                 FavoriteTreeNameURLCopyPopupMenu.Visible := True;
6174                 FavoriteTreeReloadPopupMenu.Visible := True;
6175                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6176         end else begin
6177                 FavoriteTreeBrowseFolderPopupMenu.Visible := False;
6178                 FavoriteTreeDeletePopupMenu.Visible := False;
6179                 FavoriteTreeRenamePopupMenu.Visible := False;
6180                 FavoriteTreeNewFolderPopupMenu.Visible := False;
6181                 FavoriteTreeURLCopyPopupMenu.Visible := False;
6182                 FavoriteTreeNameCopyPopupMenu.Visible := False;
6183                 FavoriteTreeNameURLCopyPopupMenu.Visible := False;
6184                 FavoriteTreeReloadPopupMenu.Visible := False;
6185                 FavoriteTreeLogDeletePopupMenu.Visible := False;
6186         end;
6187
6188 end;
6189
6190 procedure TGikoForm.FavoriteBrowseFolder( node: TTreeNode );
6191 var
6192         i: Integer;
6193 begin
6194
6195         if not (TObject(node.Data) is TFavoriteFolder) then
6196                 exit;
6197
6198         for i := 0 to node.Count - 1 do
6199         begin
6200                 if TObject(node.Item[i].Data) is TFavoriteFolder then
6201                         FavoriteBrowseFolder( node.Item[i] )
6202                 else if TObject(node.Item[i].Data) is TFavoriteThreadItem then
6203                         FavoriteClick( node.Item[i], False );
6204         end;
6205
6206 end;
6207 // *************************************************************************
6208 //! \82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83_\83u\83\8b\83N\83\8a\83b\83N\83C\83x\83\93\83g
6209 // *************************************************************************
6210 procedure TGikoForm.FavoriteTreeViewDblClick(Sender: TObject);
6211 var
6212         pos : TPoint;
6213         rect: TRect;
6214 begin
6215         //\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
6216         pos := FMouseDownPos;
6217         if (FClickNode <> nil) and (FClickNode = FavoriteTreeView.GetNodeAt(pos.X, pos.Y)) then begin
6218                 //\83}\83E\83X\82ªnode\82Ì\8fã\82É\82¢\82é\82©
6219                 rect := FClickNode.DisplayRect(true);
6220                 if ((rect.Left <= pos.X) and (rect.Right >= pos.X)) and
6221                         ((rect.Bottom >= pos.Y) and (rect.Top <= pos.Y)) then begin
6222                         GikoDM.FavoriteTreeViewReloadActionExecute( Sender );
6223                         FClickNode := nil;
6224                 end;
6225         end;
6226 end;
6227
6228 function TGikoForm.TreeNodeDataFind(Node: TTreeNode; FindPointer: Pointer): TTreeNode;
6229 var
6230         Found: TTreeNode;
6231         i: Integer;
6232 begin
6233
6234         for i := 0 to Node.Count - 1 do begin
6235                 if Node.Item[i].Data = FindPointer then begin
6236                         Result := Node.Item[i];
6237                         Exit;
6238                 end else if Node.Item[i].Count > 0 then begin
6239                         Found := TreeNodeDataFind( Node.Item[i], FindPointer );
6240                         if Found <> nil then begin
6241                                 Result := Found;
6242                                 Exit;
6243                         end;
6244                 end;
6245         end;
6246
6247         Result := nil;
6248
6249 end;
6250
6251 procedure TGikoForm.LinkToolBarDragDrop(Sender, Source: TObject; X,
6252         Y: Integer);
6253 var
6254         i: Integer;
6255         SenderNode: TTreeNode;
6256 begin
6257
6258         SenderNode := nil;
6259         for i := 0 to FavoriteTreeView.Items.Count - 1 do begin
6260                 if FavoriteTreeView.Items[i].Text = Favorite.FAVORITE_LINK_NAME then begin
6261                         SenderNode := FavoriteTreeView.Items[i];
6262                         Break;
6263                 end;
6264         end;
6265         SenderNode.Selected := False;
6266         
6267         FavoriteDragDrop( SenderNode, Source );
6268
6269         SetLinkBar;
6270 end;
6271
6272 procedure TGikoForm.BrowserTabMouseUp(Sender: TObject;
6273         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6274 begin
6275         if FDragWFirst <> true then begin
6276                 FDragWFirst := false;
6277 {
6278         end else if (abs( X - FMouseDownPos.X ) < Mouse.DragThreshold)
6279         and (abs( Y - FMouseDownPos.Y ) < Mouse.DragThreshold) then begin
6280 (*}
6281         end else begin
6282 //*)
6283                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6284                         if GikoSys.Setting.ListWidthState = glsMin then begin
6285                                 GikoDM.BrowserMaxAndFocusAction.Execute;
6286                         end;
6287                 end else begin
6288                         if GikoSys.Setting.ListHeightState = glsMin then begin
6289                                 GikoDM.BrowserMaxAndFocusAction.Execute;
6290                         end;
6291                 end;
6292         end;
6293 end;
6294
6295 procedure TGikoForm.LinkToolBarDragOver(Sender, Source: TObject; X,
6296         Y: Integer; State: TDragState; var Accept: Boolean);
6297 begin
6298
6299         FavoriteDragOver( Sender, Source, X, Y, State, Accept );
6300
6301 end;
6302
6303 procedure TGikoForm.FavoriteTreeViewEndDrag(Sender, Target: TObject; X,
6304         Y: Integer);
6305 begin
6306
6307         if FDropSpaceNode <> nil then begin
6308                 try
6309                         FDropSpaceNode.Delete;
6310                 finally
6311                         FDropSpaceNode := nil;
6312                 end;
6313                 SetLinkBar;
6314         end;
6315
6316 end;
6317
6318 procedure TGikoForm.ListCoolBarContextPopup(Sender: TObject;
6319         MousePos: TPoint; var Handled: Boolean);
6320 begin
6321
6322         FToolBarSettingSender := tssList;
6323         MousePos := ListCoolBar.ClientToScreen( MousePos );
6324         MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
6325
6326 end;
6327
6328 procedure TGikoForm.MainCoolBarContextPopup(Sender: TObject;
6329         MousePos: TPoint; var Handled: Boolean);
6330 begin
6331
6332         FToolBarSettingSender := tssMain;
6333         MousePos := MainCoolBar.ClientToScreen( MousePos );
6334         MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
6335
6336 end;
6337
6338 procedure TGikoForm.BrowserCoolBarContextPopup(Sender: TObject;
6339         MousePos: TPoint; var Handled: Boolean);
6340 begin
6341
6342         FToolBarSettingSender := tssBrowser;
6343         MousePos := BrowserCoolBar.ClientToScreen( MousePos );
6344         MainCoolBarPopupMenu.Popup( MousePos.X, MousePos.Y );
6345
6346 end;
6347 procedure TGikoForm.SetListViewBackGroundColor(value: TColor);
6348 begin
6349         if FListViewBackGroundColor <> value then begin
6350                 FListViewBackGroundColor := value;
6351                 ListView.Color := FListViewBackGroundColor;
6352         end;
6353 end;
6354 procedure TGikoForm.FavoriteTreeBrowseBoardPopupMenuClick(Sender: TObject);
6355 var
6356         threadItem      : TThreadItem;
6357         boardItem               : TBoard;
6358 begin
6359
6360         if FClickNode = nil then Exit;
6361
6362         if (TObject(FClickNode.Data) is TFavoriteThreadItem) then begin
6363
6364                 threadItem := TFavoriteThreadItem( FClickNode.Data ).Item;
6365                 if threadItem = nil then
6366                         Exit;
6367                 GikoSys.OpenBrowser( threadItem.ParentBoard.URL, gbtAuto );
6368
6369         end else if (TObject(FClickNode.Data) is TFavoriteBoardItem) then begin
6370
6371                 boardItem := TFavoriteBoardItem( FClickNode.Data ).Item;
6372                 if boardItem = nil then
6373                         Exit;
6374                 GikoSys.OpenBrowser( boardItem.URL, gbtAuto );
6375
6376         end;
6377
6378 end;
6379
6380 procedure TGikoForm.BrowserTabContextPopup(Sender: TObject;
6381         MousePos: TPoint; var Handled: Boolean);
6382 var
6383         idx : Integer;
6384 begin
6385                 idx := BrowserTab.IndexOfTabAt(MousePos.X, MousePos.Y);
6386                 if BrowserTab.TabIndex <> idx then begin
6387                 BrowserTab.TabIndex := idx;
6388                         BrowserTab.OnChange(nil);
6389                 end;
6390 end;
6391
6392 procedure TGikoForm.KonoresCopy(Number: Integer; ReplaceTag : Boolean);
6393 var
6394         ThreadItem: TThreadItem;
6395         tmp: string;
6396         FileName: string;
6397         Res: TResRec;
6398         Header: string;
6399         Body: string;
6400         boardPlugIn : TBoardPlugIn;
6401 begin
6402         if Number = 0 then Exit;
6403         ThreadItem := GetActiveContent;
6404
6405         if ThreadItem <> nil then begin
6406                 //if ThreadItem.IsBoardPlugInAvailable then begin
6407         if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6408                         //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
6409                         //boardPlugIn           := ThreadItem.BoardPlugIn;
6410             boardPlugIn         := ThreadItem.ParentBoard.BoardPlugIn;
6411
6412                         // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
6413                         // \95\8e\9a\83R\81[\83h\82Í\83v\83\89\83O\83C\83\93\82É\94C\82¹\82é
6414                         //\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
6415                         tmp := boardPlugIn.GetDat( DWORD( threadItem ), Number );
6416                 end else begin
6417       FileName := ThreadItem.FilePath;
6418       tmp := GikoSys.ReadThreadFile(FileName, Number);
6419                 end;
6420                 if tmp <> '' then begin
6421                         THTMLCreate.DivideStrLine(tmp, @Res);
6422
6423                         Header := IntToStr(Number) + ' \81F' + Res.FName + ' \81F' + Res.FDateTime + #13#10;
6424                         if ReplaceTag then begin
6425                                 Header := CustomStringReplace(Header, '</b>', '',true);
6426                                 Header := CustomStringReplace(Header, '<b>', '',true);
6427                                 Header := CustomStringReplace(Header, '<br>', '',true);
6428                                 Header := DeleteFontTag(Header);
6429                         end;
6430                         //if ThreadItem.IsBoardPlugInAvailable then begin
6431             if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
6432                                 Body := CustomStringReplace(Res.FBody, '<br>', #13#10,true);
6433                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6434                         end else begin
6435                                 Body := CustomStringReplace(Res.FBody, ' <br> ', #13#10,true);
6436                                 Body := CustomStringReplace(Body, ' <br>', #13#10,true);
6437                                 Body := CustomStringReplace(Body, '<br> ', #13#10,true);
6438                                 Body := CustomStringReplace(Body, '<br>', #13#10,true);
6439
6440                         end;
6441                         Body := CustomStringReplace(Body, '</a>', '',true);
6442
6443                         Body := HTMLCreater.DeleteLink(Body);
6444                         if ReplaceTag then begin
6445                                 Body := CustomStringReplace(Body, '&lt;', '<');
6446                                 Body := CustomStringReplace(Body, '&gt;', '>');
6447                                 Body := CustomStringReplace(Body, '&quot;', '"');
6448                                 Body := CustomStringReplace(Body, '&amp;', '&');
6449                                 //Body := CustomStringReplace(Body, '&nbsp;', ' ');
6450                         end;
6451
6452                         Header := Header + Body;
6453
6454                         Clipboard.SetTextBuf( PChar(Header) );
6455                 end;
6456         end;
6457 end;
6458
6459
6460 procedure TGikoForm.BrowserTabPopupMenuPopup(Sender: TObject);
6461 begin
6462         AddRoundNameMenu(dummy1);
6463 end;
6464
6465 procedure TGikoForm.FavoritesURLReplace(oldURLs: TStringList; newURLs: TStringList);
6466 begin
6467         FavoriteDM.URLReplace(oldURLs, newURLs);
6468 end;
6469
6470 procedure TGikoForm.RoundListURLReplace(oldURLs: TStringList; newURLs: TStringList);
6471 begin
6472         RoundList.URLReplace(oldURLs, newURLs);
6473 end;
6474
6475 procedure TGikoForm.TabFileURLReplace(oldURLs: TStringList; newURLs: TStringList);
6476 const
6477         Filename = 'tab.sav';
6478         bFilename = '~tab.sav';
6479 var
6480         i, j: Integer;
6481         tempString: string;
6482         tmpURL: string;
6483         oldHost: string;
6484         oldBoardName: string;
6485         newHost: string;
6486         newBoardName: string;
6487         TabList: TStringList;
6488 begin
6489
6490         if oldURLs.Count <> newURLs.Count then begin
6491                 Exit;
6492         end;
6493         if FileExists(GikoSys.GetAppDir + 'tab.sav') then begin
6494                 TabList := TStringList.Create;
6495                 try
6496                         TabList.LoadFromFile(GikoSys.GetAppDir + Filename);
6497
6498                         //\82±\82±\82©\82ç\81AThread\82ÌURL\82Ì\95Ï\8dX
6499                         //\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
6500                         for i := 0 to oldURLs.Count - 1 do begin
6501                                         tmpURL                  := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1);
6502                                         oldHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6503                                         oldBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6504                                         tmpURL                  := Copy(newURLs[i], 1, Length(newURLs[i]) -1);
6505                                         newHost                 := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) );
6506                                         newBoardName    := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/';
6507
6508                                         for j := 0 to TabList.Count - 1 do begin
6509                                                         tempString := TabList[j];
6510                                                         if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin
6511                                                                 tempString := StringReplace(tempString, oldHost, newHost,[]);
6512                                                                 TabList[j] := tempString;
6513                                                         end;
6514                                         end;
6515                         end;
6516                         //\82±\82±\82Ü\82Å\81AThread\82ÌURL\82Ì\95Ï\8dX
6517
6518                         if FileExists( GikoSys.GetAppDir + Filename) then begin
6519                                 if FileExists( GikoSys.GetAppDir + bFilename) then
6520                                         DeleteFile(GikoSys.GetAppDir + bFilename);
6521
6522                                 //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
6523                                 RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
6524                         end;
6525
6526                         TabList.SaveToFile(GikoSys.GetAppDir + Filename);
6527                 finally
6528                         TabList.Free;
6529                 end;
6530         end;
6531
6532 end;
6533
6534 /// \8dÅ\8f¬\89»\82³\82ê\82é
6535 procedure TGikoForm.OnMinimize;
6536 begin
6537         if FActiveContent <> nil then begin
6538                 FIsMinimize := mtMinimizing;
6539                 FActiveContent.Thread.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
6540         end;
6541 end;
6542
6543 /// \8dÅ\8f¬\89»\82³\82ê\82½ (OnResized \82©\82ç\8cÄ\82Î\82ê\82é)
6544 procedure TGikoForm.OnMinimized;
6545 begin
6546         FIsMinimize := mtMinimized;
6547 end;
6548
6549
6550 procedure TGikoForm.BrowserTabResize(Sender: TObject);
6551 begin
6552         CoolBarResized( Sender, BrowserCoolBar );
6553 end;
6554
6555 // *************************************************************************
6556 // ExternalBoardPlugInMain
6557 // \83v\83\89\83O\83C\83\93\83\81\83j\83\85\81[\82Ì\8d\80\96Ú\82ª\8eÀ\8ds\82³\82ê\82½
6558 // *************************************************************************
6559 procedure TGikoForm.OnPlugInMenuItem( Sender : TObject );
6560 var
6561         item                            : TMenuItem;
6562         boardPlugIn     : TBoardPlugIn;
6563 begin
6564
6565         if not (Sender is TMenuItem) then
6566                 Exit;
6567
6568         item := TMenuItem( Sender );
6569         if not Assigned( Pointer( item.Tag ) ) then
6570                 Exit;
6571
6572         // \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·
6573         boardPlugIn := TBoardPlugIn( item.Tag );
6574         boardPlugIn.PlugInMenu( item.Handle );
6575
6576 end;
6577 // TreeView \82ª\83N\83\8a\83b\83N\82³\82ê\82½
6578 procedure TGikoForm.TreeClick( Node : TTreeNode );
6579 begin
6580
6581         if Node = nil then
6582                 Exit;
6583
6584         if FTreeType = gttHistory then begin
6585                 if Node <> nil then
6586                         if TObject( Node.Data ) is TFavoriteThreadItem then
6587                                 if GetActiveContent <> TFavoriteThreadItem( Node.Data ).Item then
6588                                         FavoriteClick( Node );
6589                 Exit;
6590         end;
6591     //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\82Ì\82Æ\93¯\82\82È\82ç\8dÄ\95`\89æ\82µ\82È\82¢
6592         if ActiveList = Node.Data then
6593                 Exit;
6594
6595         ActiveListColumnSave;
6596
6597         if TObject(Node.Data) is TBBS then begin
6598                 SetActiveList(Node.data);
6599         end else if TObject(Node.Data) is TCategory then begin
6600                 SetActiveList(Node.data);
6601         end else if TObject(Node.Data) is TBoard then begin
6602                 if not TBoard(Node.Data).IsThreadDatRead then begin
6603                         Screen.Cursor := crHourGlass;
6604                         try
6605                 if not TBoard(Node.Data).IsThreadDatRead then
6606                                         GikoSys.ReadSubjectFile(Node.Data);
6607                         finally
6608                                 Screen.Cursor := crDefault;
6609                         end;
6610                 end;
6611                 SetActiveList(Node.data);
6612         end;
6613
6614         if TObject( Node.Data ) is TBoard then begin // not TCategory
6615                 if GikoSys.Setting.ListOrientation = gloHorizontal then begin
6616                         if GikoSys.Setting.ListWidthState = glsMax then begin
6617                                 GikoDM.BrowserMinAction.Execute;
6618                                 if GikoForm.Visible then
6619                                         ListView.SetFocus;
6620                         end;
6621                 end else begin
6622                         if GikoSys.Setting.ListHeightState = glsMax then begin
6623                                 GikoDM.BrowserMinAction.Execute;
6624                                 if GikoForm.Visible then
6625                                         ListView.SetFocus;
6626                         end;
6627                 end;
6628         end;
6629
6630 end;
6631
6632 // TreeView \82ª\83_\83u\83\8b\83N\83\8a\83b\83N\82³\82ê\82½
6633 procedure TGikoForm.TreeDoubleClick( Node : TTreeNode );
6634 var
6635         Board                           : TBoard;
6636         ThreadItem      : TThreadItem;
6637         shiftDown       : Boolean;
6638 begin
6639
6640         if Node = nil then Exit;
6641
6642         shiftDown       := GetAsyncKeyState(VK_SHIFT) = Smallint($8001);
6643
6644         if FTreeType = gtt2ch then begin
6645                 if not (TObject(Node.Data) is TBoard) then Exit;
6646                 Board := TBoard(Node.Data);
6647                 DownloadList(Board, shiftDown);
6648         end else if FTreeType = gttHistory then begin
6649                 if not (TObject(Node.Data) is TFavoriteThreadItem) then Exit;
6650                 ThreadItem := TFavoriteThreadItem(Node.Data).Item;
6651                 DownloadContent(ThreadItem, shiftDown);
6652         end;
6653
6654 end;
6655 // *************************************************************************
6656 //! \83c\83\8a\81[\83r\83\85\81[\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
6657 // *************************************************************************
6658 procedure TGikoForm.TreeViewClick(Sender: TObject);
6659 begin
6660         FClickNode := TreeView.Selected;
6661         FMouseDownPos := TreeView.ScreenToClient(Mouse.CursorPos);
6662 end;
6663 procedure TGikoForm.TreeViewKeyDown(Sender: TObject; var Key: Word;
6664         Shift: TShiftState);
6665 begin
6666         if Key = VK_BACK then begin
6667 //              UpFolderButtonClick(Sender);
6668         end else if Key = VK_SPACE then begin
6669                 TreeDoubleClick( TreeView.Selected );
6670         end else if Key = VK_RETURN then begin
6671                 TreeClick( TreeView.Selected );
6672                 TreeView.Selected.Expanded := not TreeView.Selected.Expanded;
6673         end;
6674 end;
6675
6676 procedure TGikoForm.FavoriteTreeViewMouseDown(Sender: TObject;
6677         Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6678 var
6679         favItem                         : TTreeNode;
6680         favThreadItem   : TFavoriteThreadItem;
6681 begin
6682
6683         case Button of
6684 {       mbLeft:
6685                 begin
6686                         FMouseDownPos.X := X;
6687                         FMouseDownPos.Y := Y;
6688                 end;
6689 }       mbMiddle:
6690                 begin
6691                         favItem := FavoriteTreeView.GetNodeAt( X, Y );
6692                         if favItem = nil then Exit;
6693
6694                         if TObject( favItem.Data ) is TFavoriteThreadItem then begin
6695                                 favThreadItem := TFavoriteThreadItem( favItem.Data );
6696                                 if favThreadItem.Item <> nil then
6697                                         InsertBrowserTab( favThreadItem.Item, False );
6698                         end;
6699                 end;
6700         end;
6701
6702 end;
6703
6704 procedure TGikoForm.MessagePanelResize(Sender: TObject);
6705 begin
6706
6707         if FIsIgnoreResize <> rtNone then
6708                 Exit;
6709
6710         if GikoSys.Setting.ListOrientation = gloVertical then begin
6711                 if GikoSys.Setting.ListHeightState = glsMin then begin
6712                         // \8dÅ\8f¬\95\\8e¦\82É\82·\82é
6713                         ViewPanel.Height := ThreadMainPanel.Height - BrowserCoolBar.Height - 7;
6714                 end;
6715         end;
6716
6717 end;
6718
6719 procedure TGikoForm.OnResized;
6720 var
6721         doc                                             : Variant;
6722 begin
6723
6724         FOldFormWidth := Width;
6725         FIsIgnoreResize := rtNone;
6726
6727         case FIsMinimize of
6728         mtMinimizing:
6729                 begin
6730                         // \8dÅ\8f¬\89»\92\86\82Å\82 \82é
6731                         PostMessage( Handle, USER_MINIMIZED, 0, 0 );
6732                 end;
6733
6734         mtMinimized:
6735                 begin
6736                         // \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)
6737                         if FActiveContent <> nil then begin
6738                                 doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
6739                                 doc.Body.ScrollTop := FActiveContent.Thread.ScrollTop;
6740                         end;
6741                         FIsMinimize := mtNone;
6742                 end;
6743         end;
6744
6745 end;
6746 // *************************************************************************
6747 //! \82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83}\83E\83X\83A\83b\83v\83C\83x\83\93\83g
6748 // *************************************************************************
6749 procedure TGikoForm.FavoriteTreeViewMouseUp(Sender: TObject;
6750   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
6751 begin
6752         if (Button = mbLeft) and not (ssDouble  in Shift) then begin
6753                 if (FClickNode <> nil) and (FClickNode = FavoriteTreeView.GetNodeAt(X, Y)) then begin
6754                         FavoriteClick( TObject( FClickNode ) );
6755                 end;
6756         end;
6757 end;
6758
6759 function TGikoForm.WebBrowserClick(Sender: TObject): WordBool;
6760 var
6761         p : TPoint;
6762         e: IHTMLElement;
6763         AID: string;
6764         stlist : TStringList;
6765         i, count, rc : Integer;
6766         body : String;
6767     limited : boolean;
6768 begin
6769   result := true;
6770   try
6771         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then
6772                 FActiveContent.Browser.SetFocus;
6773                 try
6774                         GetCursorPos(p);
6775                         p.x := p.x - FActiveContent.Browser.ClientOrigin.x;
6776                         p.y := p.y - FActiveContent.Browser.ClientOrigin.y;
6777                         e := IHTMLDocument2(FActiveContent.Browser.Document).elementFromPoint(p.x, p.y);
6778                         if (Assigned(e)) then begin
6779                                 if (e.className = 'date') or (e.id = 'date') then begin
6780                                         AID := e.innerText;
6781                                         if AnsiPos('id', AnsiLowerCase(AID)) > 0 then begin
6782                                                 AID := Copy(AID, AnsiPos('id', AnsiLowerCase(AID)) - 1, 11);
6783                         if AnsiPos(' be:', AnsiLowerCase(AID)) > 0 then begin
6784                                 AID := Copy(AID, 1, AnsiPos(' BE:', AnsiLowerCase(AID)) - 1)
6785                         end;
6786                                         end else begin
6787                                                 stlist := TStringList.Create;
6788                                                 try
6789                                                         stList.DelimitedText := AID;
6790                                                         AID := '';
6791                                                         for i := 0 to stList.Count - 1 do
6792                                                                 if Length(WideString(stList[i])) = 8 then begin
6793                                                                         if GikoSys.NotDateorTimeString(stList[i]) then begin
6794                                                                                 AID := stList[i];
6795                                                                                 break;
6796                                                                         end;
6797                                                                 end;
6798                                                 finally
6799                                                         stList.Free;
6800                                                 end;
6801                                         end;
6802                     count := GikoSys.GetSameIDResCount(AID, FActiveContent.Thread);
6803                     limited := false;
6804                     if count > 20 then begin
6805                         rc := GikoUtil.MsgBox(Handle,
6806                                 '20\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
6807                                 'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
6808                                                                 MB_YESNO or MB_ICONQUESTION);
6809                         limited := rc <> ID_YES;
6810                     end;
6811                                         body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
6812                                         FActiveContent.IDAnchorPopup(body);
6813                                 end;
6814                         end;
6815                 except
6816                 end;
6817   except
6818   end;
6819 end;
6820
6821 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
6822 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
6823 begin
6824         SelectTimer.Interval := 0;
6825         if not (ListView.Selected = nil) then
6826                 if( FActiveContent = nil) or
6827                                 (GetActiveContent <> TThreadItem(ListView.Selected.Data) ) then begin
6828                         ListClick;
6829                 end;
6830 end;
6831
6832 function TGikoForm.GetTabURLs(AStringList: TStringList) : Boolean;
6833 var
6834   rec : TBrowserRecord;
6835   i, bound : Integer;
6836 begin
6837   bound := BrowserTab.Tabs.Count -1;
6838         if bound = -1 then begin
6839                 Result := False;
6840                 Exit; //for\82É\94ò\82Î\82È\82¢\82Å\91\80\8dì\82ð\94²\82¯\82é
6841   end;
6842
6843   for i := 0 to bound do begin
6844         rec := TBrowserRecord( BrowserTab.Tabs.Objects[ i ] );
6845         if( rec <> nil) and (rec.Thread <> nil) then
6846                 AStringList.Add( rec.Thread.URL );
6847   end;
6848   Result := True;
6849 end;
6850
6851 function TGikoForm.SaveTabURLs : Boolean;
6852 const
6853         Filename = 'tab.sav';
6854         bFilename = '~tab.sav';
6855 var
6856         SaveStringList: TStringList;
6857 begin
6858         Result := false;
6859
6860         SaveStringList := TStringList.Create;
6861         try
6862                 if GetTabURLs(SaveStringList) then begin
6863                         if FileExists( GikoSys.GetAppDir + Filename) then begin
6864                                 if FileExists( GikoSys.GetAppDir + bFilename) then
6865                                         DeleteFile(GikoSys.GetAppDir + bFilename);
6866
6867                                 //\83o\83b\83N\83A\83b\83v\82ð\8dì\82é\81B
6868                                 RenameFile(GikoSys.GetAppDir + Filename, GikoSys.GetAppDir + bFilename);
6869                         end;
6870                         SaveStringList.SaveToFile(GikoSys.GetAppDir + Filename);
6871                         Result := true;
6872                 end;
6873         finally
6874                 SaveStringList.Free;
6875         end;
6876 end;
6877
6878 function TGikoForm.LoadTabURLs : Boolean;
6879 var
6880         i, bound    : Integer;
6881         item        : TThreadItem;
6882         URLs                            : TStringList;
6883         GikoTab                 : TGikoTabAppend;
6884         fileName                : string;
6885 begin
6886
6887         fileName := ExtractFilePath(Application.ExeName) + 'tab.sav';
6888         URLs := TStringList.Create();
6889         GikoTab := GikoSys.Setting.BrowserTabAppend;
6890         try
6891                 try
6892                         Result := True;
6893                         if FileExists(fileName) then begin
6894                                 URLs.LoadFromFile(fileName);
6895                                 bound    := URLs.Count - 1;
6896                                 if bound > -1 then begin
6897                                         GikoSys.Setting.BrowserTabAppend := gtpLast;//TGikoTabAppend(1);
6898                                         for i := 0 to bound do begin
6899                                                 item := BBSsFindThreadFromURL( URLs[ i ] );
6900                                                 if item <> nil then
6901                                                         InsertBrowserTab( item, false );
6902                                         end;
6903                                 end else
6904                                         Result := False;
6905                         end else
6906                                 Result := False;
6907                 except
6908                         on EFOpenError do begin
6909                                 ShowMessage('\83^\83u\83t\83@\83C\83\8b\82ª\8aJ\82¯\82Ü\82¹\82ñ');
6910                         end;
6911                 end;
6912         finally
6913                 GikoSys.Setting.BrowserTabAppend := GikoTab;
6914                 URLs.Free;
6915         end;
6916
6917 end;
6918
6919
6920 /// ListView \82Ì\83J\83\89\83\80\95\9d\82¨\82æ\82Ñ\88Ê\92u\82Ì\95Û\91
6921 procedure TGikoForm.ActiveListColumnSave;
6922 var
6923         ActivListObj    : TObject;
6924         i, id, idx              : Integer;
6925         BBSOrder                        : TGikoBBSColumnList;
6926         CategoryOrder   : TGikoCategoryColumnList;
6927         BoardOrder              : TGikoBoardColumnList;
6928 begin
6929
6930         ActivListObj := ActiveList;
6931         if ActivListObj is TBBS then begin
6932                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
6933                 BBSOrder := TGikoBBSColumnList.Create;
6934                 try
6935                         for i := 0 to ListView.Columns.Count - 1 do begin
6936                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6937                                 idx := ListView.Column[ i ].Tag;
6938                                 id := Ord( GikoSys.Setting.BBSColumnOrder[ idx ] );
6939                                 BBSOrder.Add( TGikoBBSColumnID( id ) );
6940                                 // \95\9d\82Ì\95Û\91
6941                                 GikoSys.Setting.BBSColumnWidth[ id ] := ListView.Column[ i ].Width;
6942                         end;
6943                         for i := 0 to ListView.Columns.Count - 1 do
6944                                 // \8f\87\8f\98\82Ì\95Û\91
6945                                 GikoSys.Setting.BBSColumnOrder[ i ] := BBSOrder[ i ];
6946                 finally
6947                         BBSOrder.Free;
6948                 end;
6949         end else if ActivListObj is TCategory then begin
6950                 //===== \94Â\83\8a\83X\83g =====
6951                 CategoryOrder := TGikoCategoryColumnList.Create;
6952                 try
6953                         for i := 0 to ListView.Columns.Count - 1 do begin
6954                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6955                                 idx := ListView.Column[ i ].Tag;
6956                                 id := Ord( GikoSys.Setting.CategoryColumnOrder[ idx ] );
6957                                 CategoryOrder.Add( TGikoCategoryColumnID( id ) );
6958                                 // \95\9d\82Ì\95Û\91
6959                                 GikoSys.Setting.CategoryColumnWidth[ id ] := ListView.Column[ i ].Width;
6960                         end;
6961                         for i := 0 to ListView.Columns.Count - 1 do
6962                                 // \8f\87\8f\98\82Ì\95Û\91
6963                                 GikoSys.Setting.CategoryColumnOrder[ i ] := CategoryOrder[ i ];
6964                 finally
6965                         CategoryOrder.Free;
6966                 end;
6967         end else if ActivListObj is TBoard then begin
6968                 //===== \83X\83\8c\83\8a\83X\83g =====
6969                 BoardOrder := TGikoBoardColumnList.Create;
6970                 try
6971                         for i := 0 to ListView.Columns.Count - 1 do begin
6972                                 // \8f\87\8f\98\82Ì\8eæ\93¾
6973                                 idx := ListView.Column[ i ].Tag;
6974                                 id := Ord( GikoSys.Setting.BoardColumnOrder[ idx ] );
6975                                 BoardOrder.Add( TGikoBoardColumnID( id ) );
6976                                 // \95\9d\82Ì\95Û\91
6977                                 GikoSys.Setting.BoardColumnWidth[ id ] := ListView.Column[ i ].Width;
6978                         end;
6979                         for i := 0 to ListView.Columns.Count - 1 do
6980                                 // \8f\87\8f\98\82Ì\95Û\91
6981                                 GikoSys.Setting.BoardColumnOrder[ i ] := BoardOrder[ i ];
6982                 finally
6983                         BoardOrder.Free;
6984                 end;
6985         end;
6986
6987 end;
6988
6989 procedure TGikoForm.ListViewColumnRightClick(Sender: TObject;
6990         Column: TListColumn; Point: TPoint);
6991 var
6992         i, j    : Integer;
6993         item    : TMenuItem;
6994 begin
6995
6996         // \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82ð\83N\83\8a\83A
6997         for i := ListColumnPopupMenu.Items.Count - 1 downto 0 do
6998                 ListColumnPopupMenu.Items.Items[ i ].Free;
6999
7000         // \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¢)
7001         if TObject( FActiveList ) is TBBS then begin
7002
7003                 //===== \83J\83e\83S\83\8a\83\8a\83X\83g =====
7004                 for i := 1 to Length( GikoBBSColumnCaption ) - 1 do begin
7005                         item := TMenuItem.Create( ListColumnPopupMenu );
7006                         item.Caption := GikoBBSColumnCaption[ i ];
7007                         item.Tag := i;
7008                         item.OnClick := ListColumnPopupMenuOnClick;
7009                         for j := GikoSys.Setting.BBSColumnOrder.Count - 1 downto 0 do begin
7010                                 if GikoSys.Setting.BBSColumnOrder[ j ] = TGikoBBSColumnID( i ) then begin
7011                                         item.Checked := True;
7012                                         Break;
7013                                 end;
7014                         end;
7015                         ListColumnPopupMenu.Items.Add( item );
7016                 end;
7017
7018         end else if TObject( FActiveList ) is TCategory then begin
7019
7020                 //===== \94Â\83\8a\83X\83g =====
7021                 for i := 1 to Length( GikoCategoryColumnCaption ) - 1 do begin
7022                         item := TMenuItem.Create( ListColumnPopupMenu );
7023                         item.Caption := GikoCategoryColumnCaption[ i ];
7024                         item.Tag := i;
7025                         item.OnClick := ListColumnPopupMenuOnClick;
7026                         for j := GikoSys.Setting.CategoryColumnOrder.Count - 1 downto 0 do begin
7027                                 if GikoSys.Setting.CategoryColumnOrder[ j ] = TGikoCategoryColumnID( i ) then begin
7028                                         item.Checked := True;
7029                                         Break;
7030                                 end;
7031                         end;
7032                         ListColumnPopupMenu.Items.Add( item );
7033                 end;
7034
7035         end else if TObject( FActiveList ) is TBoard then begin
7036
7037                 //===== \83X\83\8c\83\8a\83X\83g =====
7038                 for i := 1 to Length( GikoBoardColumnCaption ) - 1 do begin
7039                         item := TMenuItem.Create( ListColumnPopupMenu );
7040                         item.Caption := GikoBoardColumnCaption[ i ];
7041                         item.Tag := i;
7042                         item.OnClick := ListColumnPopupMenuOnClick;
7043                         for j := GikoSys.Setting.BoardColumnOrder.Count - 1 downto 0 do begin
7044                                 if GikoSys.Setting.BoardColumnOrder[ j ] = TGikoBoardColumnID( i ) then begin
7045                                         item.Checked := True;
7046                                         Break;
7047                                 end;
7048                         end;
7049                         ListColumnPopupMenu.Items.Add( item );
7050                 end;
7051
7052         end;
7053
7054         // \83\81\83j\83\85\81[\82Ì\95\\8e¦
7055         Point := ListView.ClientToScreen( Point );
7056         if ListColumnPopupMenu.Items.Count > 0 then
7057                 ListColumnPopupMenu.Popup( Point.X, Point.Y );
7058
7059 end;
7060
7061 /// ListColumnPopupMenu \83A\83C\83e\83\80\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
7062 procedure       TGikoForm.ListColumnPopupMenuOnClick( Sender : TObject );
7063 var
7064         i                                       : Integer;
7065         orderList       : TList;
7066         item                    : TMenuItem;
7067 begin
7068
7069         if not (Sender is TMenuItem) then
7070                 Exit;
7071
7072         ActiveListColumnSave;
7073         item := TMenuItem( Sender );
7074
7075         if TObject( FActiveList ) is TBBS then
7076                 orderList := GikoSys.Setting.BBSColumnOrder
7077         else if TObject( FActiveList ) is TCategory then
7078                 orderList := GikoSys.Setting.CategoryColumnOrder
7079         else if TObject( FActiveList ) is TBoard then
7080                 orderList := GikoSys.Setting.BoardColumnOrder
7081         else
7082                 Exit;
7083
7084         if item.Checked then begin
7085                 // \83J\83\89\83\80\82Ì\8dí\8f\9c
7086                 for i := orderList.Count - 1 downto 0 do begin
7087                         if Integer( orderList[ i ] ) = item.Tag then begin
7088                                 orderList.Delete( i );
7089                                 Break;
7090                         end;
7091                 end;
7092         end else begin
7093                 // \83J\83\89\83\80\82Ì\92Ç\89Á
7094                 orderList.Add( Pointer( item.Tag ) );
7095         end;
7096
7097         SetActiveList( FActiveList );
7098
7099 end;
7100
7101 procedure TGikoForm.OnGestureStart(Sender: TObject);
7102 begin
7103 //
7104 end;
7105
7106 procedure TGikoForm.OnGestureMove(Sender: TObject);
7107 var
7108         s: string;
7109         Action: TAction;
7110         ActStr: string;
7111         P : TPoint;
7112 begin
7113         //\83}\83E\83X\88Ê\92u\82Ì\8eæ\93¾
7114         GetCursorPos(P);
7115         //\83R\83\93\83|\81[\83l\83\93\83g\96¼\8eæ\93¾
7116         s := MouseGesture.GetGestureStr;
7117         ActStr := '';
7118         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
7119         if Action <> nil then
7120                 ActStr := '\81i' + Action.Caption + '\81j';
7121         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
7122         StatusBar.Panels[1].Text := s;
7123 end;
7124
7125 procedure TGikoForm.OnGestureEnd(Sender: TObject);
7126 var
7127         s: string;
7128         Action: TAction;
7129 begin
7130         s := MouseGesture.GetGestureStr;
7131         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
7132         if Action <> nil then
7133                 Action.Execute;
7134         StatusBar.Panels[1].Text := '';
7135 end;
7136
7137 procedure TGikoForm.ListViewCustomDrawItem(Sender: TCustomListView;
7138   Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
7139 var
7140         ThreadItem: TThreadItem;
7141 begin
7142         DefaultDraw := true;
7143         if TObject(Item.Data) is TThreadItem then begin
7144                 ThreadItem := TThreadItem(Item.Data);
7145                 if ( FUseOddResOddColor ) and ( ThreadItem.Count <> 0 ) and ( ThreadItem.AllResCount <> ThreadItem.Count) then begin
7146                         ListView.Canvas.Brush.Color := FOddColor;
7147                         //\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
7148                         if (GikoSys.Setting.UnFocusedBold) and
7149                          (Item.Selected) and (not ListView.Focused) then begin
7150                                 ListView.Canvas.Font.Style := [fsBold];
7151                         end;
7152                 end else begin
7153                         ListView.Canvas.Brush.Color := FListViewBackGroundColor;
7154                 end;
7155
7156                 if ThreadItem.UnRead then
7157                         ListView.Canvas.Font.Style := [fsBold];
7158         end;
7159
7160 end;
7161
7162 procedure TGikoForm.FormActivate(Sender: TObject);
7163 begin
7164         if GikoSys.Setting.GestureEnabled then begin
7165                 GikoSys.Setting.Gestures.ClearGesture;
7166                 GikoSys.Setting.Gestures.LoadGesture(
7167                         GikoSys.Setting.GetGestureFileName, GikoDM.GikoFormActionList );
7168                 MouseGesture.UnHook;
7169                 MouseGesture.OnGestureStart := OnGestureStart;
7170                 MouseGesture.OnGestureMove := OnGestureMove;
7171                 MouseGesture.OnGestureEnd := OnGestureEnd;
7172                 MouseGesture.SetHook(Handle);
7173         end else begin
7174                 //MouseGesture.UnHook;
7175                 MouseGesture.OnGestureStart := nil;
7176                 MouseGesture.OnGestureMove := nil;
7177                 MouseGesture.OnGestureEnd := nil;
7178         end;
7179 end;
7180
7181 procedure TGikoForm.BrowserPanelResize(Sender: TObject);
7182 begin
7183         if (FActiveContent <> nil) and (FActiveContent.Browser <> nil) then begin
7184                 MoveWindow(FActiveContent.Browser.Handle, 0, 0, BrowserPanel.ClientWidth, BrowserPanel.ClientHeight, false);
7185         end;
7186
7187 end;
7188 procedure TGikoForm.CoolBarResized(Sender: TObject; CoolBar: TCoolBar);
7189 var
7190         coolSet                         : TCoolSet;
7191         toolbar                         : TToolBar;
7192         band                                    : TCoolBand;
7193         affectedBand    : TCoolBand;
7194         i                                                       : Integer;
7195 begin
7196         if (FOldFormWidth = Width) and not IsIconic( Handle ) and (FIsIgnoreResize = rtNone) then begin
7197                 FIsIgnoreResize := rtResizing;
7198                 PostMessage( Handle, USER_RESIZED, 0, 0 );
7199                 band := nil;
7200                 // \95Ï\8dX\82³\82ê\82½\83N\81[\83\8b\83o\81[\82Ì\92l\82ð\95Û\91
7201                 if CoolBar = MainCoolBar then begin
7202                         for i := 0 to MAIN_COOLBAND_COUNT - 1 do begin
7203                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7204                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7205                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7206                                 GikoSys.Setting.MainCoolSet[i] := CoolSet;
7207                         end;
7208                 end else if CoolBar = ListCoolBar then begin
7209                         for i := 0 to LIST_COOLBAND_COUNT - 1 do begin
7210                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7211                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7212                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7213                                 GikoSys.Setting.ListCoolSet[i] := CoolSet;
7214                         end;
7215                 end else if CoolBar = BrowserCoolBar then begin
7216                         for i := 0 to BROWSER_COOLBAND_COUNT - 1 do begin
7217                                 CoolSet.FCoolID := CoolBar.Bands[i].ID;
7218                                 CoolSet.FCoolWidth := CoolBar.Bands[i].Width;
7219                                 CoolSet.FCoolBreak := CoolBar.Bands[i].Break;
7220                                 GikoSys.Setting.BrowserCoolSet[i] := CoolSet;
7221                         end;
7222                 end;
7223                 if not (Sender is TToolBar) or (CoolBar = nil) then
7224                         Exit;
7225                 toolbar := TToolBar( Sender );
7226                 // \95\9d\82Ì\95Ï\8dX\82³\82ê\82½\83o\83\93\83h\82ð\8c©\82Â\82¯\82é
7227                 affectedBand := nil;
7228                 for i := CoolBar.Bands.Count - 1 downto 0 do begin
7229                         if CoolBar.Bands[ i ].Control.Handle = toolbar.Handle then begin
7230                                 band    := CoolBar.Bands[ i ];
7231                                 if band.Break or (i = 0) then begin
7232                                         if i + 1 < CoolBar.Bands.Count then
7233                                                 if not CoolBar.Bands[ i + 1 ].Break then
7234                                                         affectedBand := CoolBar.Bands[ i + 1 ];
7235                                 end else begin
7236                                         if i > 0 then
7237                                                 affectedBand := CoolBar.Bands[ i - 1 ];
7238                                 end;
7239                                 Break;
7240                         end;
7241                 end;
7242                 // \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·
7243                 if CoolBar = MainCoolBar then begin
7244                         coolSet := GikoSys.Setting.MainCoolSet[ band.ID ];
7245                         coolSet.FCoolWidth := toolbar.Width + 25;
7246                         GikoSys.Setting.MainCoolSet[ band.ID ] := coolSet;
7247                         if affectedBand <> nil then begin
7248                                 coolSet := GikoSys.Setting.MainCoolSet[ affectedBand.ID ];
7249                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7250                                 GikoSys.Setting.MainCoolSet[ affectedBand.ID ] := coolSet;
7251                         end;
7252                 end else if CoolBar = ListCoolBar then begin
7253                         coolSet := GikoSys.Setting.ListCoolSet[ band.ID ];
7254                         coolSet.FCoolWidth := toolbar.Width + 25;
7255                         GikoSys.Setting.ListCoolSet[ band.ID ] := coolSet;
7256                         if affectedBand <> nil then begin
7257                                 coolSet := GikoSys.Setting.ListCoolSet[ affectedBand.ID ];
7258                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7259                                 GikoSys.Setting.ListCoolSet[ affectedBand.ID ] := coolSet;
7260                         end;
7261                 end else if CoolBar = BrowserCoolBar then begin
7262                         coolSet := GikoSys.Setting.BrowserCoolSet[ band.ID ];
7263                         coolSet.FCoolWidth := toolbar.Width + 25;
7264                         GikoSys.Setting.BrowserCoolSet[ band.ID ] := coolSet;
7265                         if affectedBand <> nil then begin
7266                                 coolSet := GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ];
7267                                 coolSet.FCoolWidth := affectedBand.Control.Width + 25;
7268                                 GikoSys.Setting.BrowserCoolSet[ affectedBand.ID ] := coolSet;
7269                         end;
7270                 end;
7271         end;
7272 end;
7273
7274
7275 procedure TGikoForm.MenuToolBarResize(Sender: TObject);
7276 begin
7277         CoolBarResized( Sender, MainCoolBar );
7278 end;
7279
7280 procedure TGikoForm.ListToolBarResize(Sender: TObject);
7281 begin
7282         CoolBarResized( Sender, ListCoolBar );
7283 end;
7284
7285 procedure TGikoForm.BrowserToolBarResize(Sender: TObject);
7286 begin
7287         CoolBarResized( Sender, BrowserCoolBar );
7288 end;
7289
7290 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
7291 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
7292 var
7293         ThreadItem      : TThreadItem;
7294         ReadList                : TStringList;
7295         wordCount               : TWordCount;
7296 begin
7297         ThreadItem      := GetActiveContent;
7298         ReadList                := TStringList.Create;
7299         wordCount               := TWordCount.Create;
7300         try
7301                 ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7302 {$IFDEF SPAM_FILTER_ENABLED}
7303                 // \83X\83p\83\80\82É\90Ý\92è
7304                 ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7305                 GikoSys.SpamCountWord( ReadList[ ATag - 1 ], wordCount );
7306                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7307                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7308 {$ENDIF}
7309                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7310                 GikoSys.FAbon.AddIndividualAbon(Atag, Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7311         finally
7312                 wordCount.Free;
7313                 ReadList.Free;
7314         end;
7315         FActiveContent.Repaint := true;
7316         if ThreadItem <> nil then
7317                 InsertBrowserTab( ThreadItem, True );
7318 end;
7319
7320 //\93¯\88êID\82Ì\82 \82Ú\81`\82ñ
7321 procedure TGikoForm.IndividualAbonID(Atype : Integer);
7322 var
7323         ThreadItem : TThreadItem;
7324         i, No : Integer;
7325         body : TStringList;
7326         ReadList                : TStringList;
7327         wordCount               : TWordCount;
7328 begin
7329         No := KokoPopupMenu.Tag;
7330         if No = 0 then Exit;
7331         ThreadItem := GetActiveContent;
7332         if ThreadItem = nil then Exit;
7333         body := TStringList.Create;
7334         try
7335                 GikoSys.GetSameIDRes(No, ThreadItem, body);
7336
7337                 ReadList                := TStringList.Create;
7338                 wordCount               := TWordCount.Create;
7339                 try
7340                         ThreadItem.ScrollTop := OleVariant(IHTMLDocument2(FActiveContent.Browser.Document)).Body.ScrollTop;
7341 {$IFDEF SPAM_FILTER_ENABLED}
7342                         // \83X\83p\83\80\82É\90Ý\92è
7343                         ReadList.LoadFromFile( ThreadItem.GetThreadFileName );
7344 {$ENDIF}
7345                         for i := 0 to body.Count - 1 do begin
7346 {$IFDEF SPAM_FILTER_ENABLED}
7347                                 GikoSys.SpamCountWord( ReadList[ i ], wordCount );
7348                                 GikoSys.SpamForget( wordCount, False ); // \83n\83\80\82ð\89ð\8f\9c
7349                                 GikoSys.SpamLearn( wordCount, True );           // \83X\83p\83\80\82É\90Ý\92è
7350 {$ENDIF}
7351                                 // \82 \82Ú\81[\82ñ\82É\90Ý\92è
7352                                 GikoSys.FAbon.AddIndividualAbon(StrToInt(body[i]), Atype, ChangeFileExt(ThreadItem.GetThreadFileName, '.NG'));
7353                         end;
7354                 finally
7355                         wordCount.Free;
7356                         ReadList.Free;
7357                 end;
7358                 FActiveContent.Repaint := true;
7359                 if ThreadItem <> nil then
7360                         InsertBrowserTab( ThreadItem, True );
7361         finally
7362                 body.Free;
7363         end;
7364
7365 end;
7366
7367 procedure TGikoForm.KokoPopupMenuPopup(Sender: TObject);
7368 var
7369         firstElement: IHTMLElement;
7370         document: IHTMLDocument2;
7371 begin
7372         document := FActiveContent.Browser.Document as IHTMLDocument2;
7373         if Assigned(document) then
7374                 firstElement := document.all.item('idSearch', 0) as IHTMLElement;
7375                 if Assigned(firstElement) then
7376                         if firstElement.style.visibility <> 'hidden' then
7377                                 firstElement.style.visibility := 'hidden';
7378
7379 end;
7380
7381 procedure TGikoForm.RepaintAllTabsBrowser();
7382 var
7383         i : Integer;
7384         ThreadItem: TThreadItem;
7385 begin
7386         for i := BrowserTab.Tabs.Count - 1 downto 0 do
7387                 TBrowserRecord(BrowserTab.Tabs.Objects[i]).Repaint := true;
7388
7389         ThreadItem := GetActiveContent;
7390         if ThreadItem <> nil then
7391                 InsertBrowserTab( ThreadItem, True );
7392
7393 end;
7394
7395 //ListView\82Ì\91I\91ð\8fó\91Ô\82ð\89ð\8f\9c\82·\82é
7396 procedure TGikoForm.ListViewKeyUp(Sender: TObject; var Key: Word;
7397   Shift: TShiftState);
7398 begin
7399         //\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Ì
7400         //\96³\8cø\8e\9e\8aÔ\82ÌTimer\82Ì\8f\88\97\9d
7401         //\82Æ\82è\82 \82¦\82¸\81A\83^\83C\83}\81[\82ð\92â\8e~\82·\82é\81B
7402         SelectTimer.Interval := 0;
7403         if not (GikoSys.Setting.BrowserTabVisible) then begin
7404                 if (GetActiveList is TBoard) then begin
7405                         //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
7406                         if not ((ssShift in Shift) or (ssAlt in Shift) or (ssCtrl in Shift))  and
7407                                 (( Key = VK_LEFT) or (Key = VK_RIGHT) or
7408                                                 (Key = VK_UP) or (Key = VK_DOWN)) then
7409                                         SelectTimer.Interval := GikoSys.Setting.SelectInterval;
7410                 end;
7411         end;
7412 end;
7413 // *************************************************************************
7414 //! \82¨\8bC\82É\93ü\82è\82Ì\95Ò\8fW\8aJ\8en\83C\83x\83\93\83g
7415 // *************************************************************************
7416 procedure TGikoForm.FavoriteTreeViewEditing(Sender: TObject;
7417   Node: TTreeNode; var AllowEdit: Boolean);
7418 begin
7419         //\95Ò\8fW\91O\82Ì\95\8e\9a\97ñ\82ð\88ê\8e\9e\95Û\91\82·\82é
7420         FOrigenCaption := Node.Text;
7421 end;
7422 // *************************************************************************
7423 //! Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
7424 // *************************************************************************
7425 function TGikoForm.GetMainForm(): TComponent;
7426 begin
7427         Result := Application.MainForm;
7428 end;
7429 // *************************************************************************
7430 //! \8c»\8dÝ\82Ì\83J\81[\83\\83\8b\82ð\8eæ\93¾\82·\82é
7431 // *************************************************************************
7432 function TGikoForm.GetScreenCursor(): TCursor;
7433 begin
7434         Result := Screen.Cursor;
7435 end;
7436 // *************************************************************************
7437 //! \83J\81[\83\\83\8b\82ð\90Ý\92è\82·\82é
7438 // *************************************************************************
7439 procedure TGikoForm.SetScreenCursor(Cursor : TCursor);
7440 begin
7441         if (Screen.Cursor <> Cursor) then
7442                 Screen.Cursor := Cursor;
7443 end;
7444 // *************************************************************************
7445 //! \83X\83N\83\8a\81[\83\93\8fã\82ÉEditorForm\82ª\82¢\82é\82©
7446 // *************************************************************************
7447 function TGikoForm.EditorFormExists(): boolean;
7448 var
7449         i : Integer;
7450 begin
7451         Result := false;
7452         //\83X\83N\83\8a\81[\83\93\8fã\82Ì\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81AEditorForm\82ð\92T\82·
7453         for i := 0 to Screen.CustomFormCount - 1 do begin
7454                 if TObject(Screen.CustomForms[i]) is TEditorForm then begin
7455                         Result := true;
7456                         Break;
7457                 end;
7458         end;
7459 end;
7460 // *************************************************************************
7461 //! \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é
7462 // *************************************************************************
7463 procedure TGikoForm.AllEditroFormNameTextClearClear();
7464 var
7465         i : Integer;
7466 begin
7467         for i := 0 to Screen.CustomFormCount - 1 do begin
7468                 if TObject(Screen.CustomForms[i]) is TEditorForm then
7469                         TEditorForm(Screen.CustomForms[i]).NameComboBox.Items.Clear;
7470         end;
7471 end;
7472 // *************************************************************************
7473 //! \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é
7474 // *************************************************************************
7475 procedure TGikoForm.AllEditroFormMailTextClearClear();
7476 var
7477         i : Integer;
7478 begin
7479         for i := 0 to Screen.CustomFormCount - 1 do begin
7480                 if TObject(Screen.CustomForms[i]) is TEditorForm then
7481                         TEditorForm(Screen.CustomForms[i]).MailComboBox.Items.Clear;
7482         end;
7483 end;
7484 // *************************************************************************
7485 //! \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
7486 // *************************************************************************
7487 procedure TGikoForm.CabinetCloseSpeedButtonClick(Sender: TObject);
7488 begin
7489         //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Ì
7490         //\8cÄ\82Ñ\8fo\82µ\82É\82µ\82½\81@by \82à\82\82ã
7491         if GikoDM.CabinetVisibleAction.Enabled then begin
7492                 GikoDM.CabinetVisibleAction.Execute;
7493         end;
7494 end;
7495 // *************************************************************************
7496 //! \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
7497 // *************************************************************************
7498 procedure TGikoForm.FavoriteArrangeToolButtonClick(Sender: TObject);
7499 begin
7500         if GikoDM.FavoriteArrangeAction.Enabled then begin
7501                 GikoDM.FavoriteArrangeAction.Execute;
7502         end;
7503 end;
7504 // *************************************************************************
7505 //! \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
7506 // *************************************************************************
7507 procedure TGikoForm.GikoApplicationEventsMessage(var Msg: tagMSG;
7508   var Handled: Boolean);
7509 var
7510         wmMsg: TWMKey;
7511 begin
7512         //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ß
7513         if Self.Active then begin
7514                 case Msg.message of
7515                         //\83L\81[\93ü\97Í\82·\82×\82Ä
7516                         WM_KEYFIRST..WM_KEYLAST :
7517                         begin
7518                                 //\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ç
7519                                 if (Msg.message <> WM_KEYUP) and (Msg.message <> WM_CHAR) then begin
7520                                         wmMsg.Msg := Msg.message;
7521                                         wmMsg.CharCode := Word(Msg.wParam);
7522                                         wmMsg.KeyData := Msg.lParam;
7523                                         //\83t\83H\81[\83\80\82Ì\83V\83\87\81[\83g\83J\83b\83g\82Ì\8f\88\97\9d\82É\93]\91\97
7524                                         Self.OnShortCut(wmMsg, Handled);
7525                                 end;
7526                         end;
7527                 end;
7528         end;
7529 end;
7530 // *************************************************************************
7531 //! \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
7532 // *************************************************************************
7533 procedure TGikoForm.GikoApplicationEventsDeactivate(Sender: TObject);
7534 begin
7535         Application.ProcessMessages;
7536         if not Application.Terminated then begin
7537                 if PreviewTimer.Enabled then
7538                         PreviewTimer.Enabled := False;
7539                 //\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
7540                 if FHint <> nil then begin
7541                         FHint.ReleaseHandle;
7542                         FHint.ClearAllRes;
7543                 end;
7544                 //\83v\83\8c\83r\83\85\81[\82ð\89B\82·
7545                 if FPreviewBrowser <> nil then
7546                         ShowWindow(FPreviewBrowser.Handle, SW_HIDE);
7547         end;
7548
7549 end;
7550 // *************************************************************************
7551 //! \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
7552 // *************************************************************************
7553 procedure TGikoForm.GikoApplicationEventsException(Sender: TObject;
7554   E: Exception);
7555 var
7556         s : String;
7557 begin
7558         if (Sender <> nil) then begin
7559                 s := ' [' + Sender.ClassName + ']' + #13#10;
7560         end else begin
7561                 s := ' [ Sender is nil ] ' + #13#10;
7562         end;
7563         s := s + E.Message;
7564         MsgBox(Handle, s, '\8f\88\97\9d\82³\82ê\82È\82©\82Á\82½\97á\8aO', MB_OK or MB_ICONSTOP);
7565 end;
7566 // *************************************************************************
7567 //! \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¢
7568 // *************************************************************************
7569 procedure TGikoForm.InitActionChecked();
7570 begin
7571         //\83\8d\83O\83C\83\93\8fó\91Ô\82ð\8dÄ\90Ý\92è
7572         GikoDM.LoginAction.Checked := GikoDM.LoginAction.Checked;
7573         //\83~\83\85\81[\83g\82Ì\8fó\91Ô\82ð\90Ý\92è
7574         GikoDM.MuteAction.Checked := GikoSys.Setting.Mute;
7575         //\89æ\96Ê\82Ì\95ª\8a\84\82Ì\8fó\91Ô\82ð\8dÄ\90Ý\92è
7576         GikoDM.ArrangeAction.Checked := GikoDM.ArrangeAction.Checked;
7577
7578         //\83X\83\8c\91S\95\94\95\\8e¦\83{\83^\83\93\82ð\89\9f\82³\82ê\82½\8fó\91Ô\82É\82·\82é
7579         GikoDM.AllItemAction.Checked := True;
7580         GikoDM.AllResAction.Checked := True;
7581
7582         // \83\8c\83X\95\\8e¦\94Í\88Í
7583         FResRangeMenuSelect := GikoSys.ResRange;
7584         case GikoSys.ResRange of
7585         Ord( grrAll ):
7586                 begin
7587                         GikoDM.AllResAction.Execute;
7588                 end;
7589         Ord( grrSelect ):
7590                 begin
7591                         SelectComboBox.Text := SelectComboBox.Items[ 1 ];
7592                         GikoDM.SelectResAction.Checked := True;
7593                 end;
7594         else
7595                 case FResRangeMenuSelect of
7596                 Ord( grrKoko ): GikoDM.OnlyKokoResAction.Checked        := True;
7597                 Ord( grrNew ):  GikoDM.OnlyNewResAction.Checked := True;
7598                 100:                    GikoDM.OnlyAHundredResAction.Checked            := True;
7599                 end;
7600         end;
7601
7602         // \83X\83\8c\83b\83h\88ê\97\97\95\\8e¦\94Í\88Í
7603         case GikoSys.Setting.ThreadRange of
7604         gtrAll:
7605                 begin
7606                         GikoDM.AllItemAction.Checked := True;
7607                         ViewType := gvtAll;
7608                 end;
7609         gtrLog:
7610                 begin
7611                         GikoDM.LogItemAction.Checked := True;
7612                         ViewType := gvtLog;
7613                 end;
7614         gtrNew:
7615                 begin
7616                         GikoDM.NewItemAction.Checked := True;
7617                         ViewType := gvtNew;
7618                 end;
7619         end;
7620 end;
7621 // *************************************************************************
7622 //! \82¨\8bC\82É\93ü\82è\83c\83\8a\81[\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
7623 // *************************************************************************
7624 procedure TGikoForm.FavoriteTreeViewClick(Sender: TObject);
7625 begin
7626         //\8c»\8dÝ\91I\91ð\82³\82ê\82Ä\82¢\82é\83A\83C\83e\83\80\82ð\95Û\91
7627         FClickNode := FavoriteTreeView.Selected;
7628         FMouseDownPos := FavoriteTreeView.ScreenToClient(Mouse.CursorPos);
7629 end;
7630 // *************************************************************************
7631 //! \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
7632 // *************************************************************************
7633 procedure TGikoForm.FavoriteTreeViewCollapsing(Sender: TObject;
7634   Node: TTreeNode; var AllowCollapse: Boolean);
7635 begin
7636         //\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
7637         FClickNode := nil;
7638 end;
7639 // *************************************************************************
7640 //! \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
7641 // *************************************************************************
7642 procedure TGikoForm.FavoriteTreeViewExpanding(Sender: TObject;
7643   Node: TTreeNode; var AllowExpansion: Boolean);
7644 begin
7645         //\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
7646         FClickNode := nil;
7647 end;
7648 // *************************************************************************
7649 //! \83c\83\8a\81[\83r\83\85\81[\82Ì\83A\83C\83e\83\80\82Ì\8fk\8f¬\8e\9e\83C\83x\83\93\83g
7650 // *************************************************************************
7651 procedure TGikoForm.TreeViewCollapsing(Sender: TObject; Node: TTreeNode;
7652   var AllowCollapse: Boolean);
7653 begin
7654         FClickNode := nil;
7655 end;
7656 // *************************************************************************
7657 //! \83c\83\8a\81[\83r\83\85\81[\82Ì\83A\83C\83e\83\80\82Ì\93W\8aJ\8e\9e\83C\83x\83\93\83g
7658 // *************************************************************************
7659 procedure TGikoForm.TreeViewExpanding(Sender: TObject; Node: TTreeNode;
7660   var AllowExpansion: Boolean);
7661 begin
7662         FClickNode := nil;
7663 end;
7664 // *************************************************************************
7665 //! \83c\83\8a\81[\83r\83\85\81[\82Ì\83}\83E\83X\83A\83b\83v\83C\83x\83\93\83g
7666 // *************************************************************************
7667 procedure TGikoForm.TreeViewMouseUp(Sender: TObject; Button: TMouseButton;
7668   Shift: TShiftState; X, Y: Integer);
7669 begin
7670         if (Button = mbLeft) and not (ssDouble in Shift) then begin
7671                 if (FClickNode <> nil) and (FClickNode = TreeView.GetNodeAt(X, Y)) then begin
7672                         TreeClick(FClickNode);
7673                 end;
7674         end;
7675 end;
7676 // *************************************************************************
7677 //! \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¬
7678 // *************************************************************************
7679 procedure TGikoForm.CreateControlThread();
7680 begin
7681         //\83_\83E\83\93\83\8d\81[\83h\83I\83u\83W\83F\83N\83g
7682         FControlThread := TThreadControl.Create(True);
7683         FControlThread.MaxThreadCount := 1;
7684         FControlThread.Resume;
7685         FControlThread.OnDownloadEnd := DownloadEnd;
7686         FControlThread.OnDownloadMsg := DownloadMsg;
7687         FControlThread.OnWork := Work;
7688         FControlThread.OnWorkBegin := WorkBegin;
7689         FControlThread.OnWorkEnd := WorkEnd;
7690 end;
7691 // *************************************************************************
7692 //! \83u\83\89\83E\83U\82Ì\90\90¬
7693 // *************************************************************************
7694 procedure TGikoForm.CreateBrowsers(count: Integer);
7695 var
7696         i: Integer;
7697         newBrowser: TWebBrowser;
7698 begin
7699         BrowserNullTab := TBrowserRecord.Create;
7700         BrowserNullTab.Browser := Browser;
7701         BrowserNullTab.Browser.Navigate(BLANK_HTML);
7702         FBrowsers := TList.Create;
7703         for i := 0 to count -1 do begin
7704                 FBrowsers.Add(TWebBrowser.Create(BrowserPanel));
7705                 newBrowser := FBrowsers[FBrowsers.Count - 1];
7706                 TOleControl(newBrowser).Parent := BrowserPanel;
7707                 TOleControl(newBrowser).Align := alNone;
7708                 TOleControl(newBrowser).Left    := 0;
7709                 TOleControl(newBrowser).Top     := 0;
7710                 newBrowser.OnDocumentComplete   := BrowserDocumentComplete;
7711                 newBrowser.OnBeforeNavigate2    := BrowserBeforeNavigate2;
7712                 newBrowser.OnEnter                              := BrowserEnter;
7713                 newBrowser.OnNewWindow2                 := BrowserNewWindow2;
7714                 newBrowser.OnStatusTextChange   := BrowserStatusTextChange;
7715                 newBrowser.Navigate(BLANK_HTML);
7716                 ShowWindow(newBrowser.Handle, SW_HIDE);
7717         end;
7718         BrowserNullTab.Browser.BringToFront;
7719         ShowWindow(BrowserNullTab.Browser.Handle, SW_SHOW);
7720         //\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Ì
7721         //\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Å
7722         //\82±\82±\82Å\8fI\82í\82ç\82¹\82Ä\82¨\82­
7723         while (Browser.ReadyState <> READYSTATE_COMPLETE) and
7724                 (Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
7725                 Application.ProcessMessages;
7726         end;
7727 end;
7728 // *************************************************************************
7729 //! \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é
7730 // *************************************************************************
7731 procedure TGikoForm.SetSelectComboBox();
7732 const
7733         DUMMYCOMPNAME = 'SelectComboBoxDummy';
7734 var
7735         i: Integer;
7736         ToolButton: TToolButton;
7737 begin
7738         //ListToolBar\82É\82¢\82é\82©\82à\82µ\82ê\82È\82¢\8di\8d\9e\82ÝComboBox\82ð\94z\92u
7739         SelectComboBoxPanel.Visible := False;
7740         try
7741                 for i := ListToolBar.ControlCount - 1 downto 0 do
7742                 begin
7743                         if ListToolBar.Controls[ i ].Action = GikoDM.SelectItemAction then
7744                         begin
7745                                 SelectComboBoxPanel.Left := ListToolBar.Controls[ i ].Left;
7746                                 SelectComboBoxPanel.Width := GikoSys.Setting.SelectComboBoxWidth;
7747                                 SelectComboBoxPanel.Parent := ListToolBar;
7748                                 SelectComboBoxPanel.Visible := True;
7749
7750                                 SelectComboBox.Left := 0;
7751                                 SelectComboBox.Top  := 0;
7752                                 SelectComboBox.Height := SelectComboBoxPanel.ClientHeight;
7753                                 SelectComboBox.Width := SelectComboBoxPanel.Width -
7754                                                                                 SelectComboBoxSplitter.Width;
7755
7756                                 //\88ê\82Â\8c©\82¦\82È\82¢\83{\83^\83\93\82ð\93Ë\82Á\8d\9e\82Þ
7757                                 ToolButton := TToolButton(ListToolBar.FindComponent(DUMMYCOMPNAME));
7758                                 if ToolButton = nil then begin
7759                                         ToolButton := TToolButton.Create(ListToolBar);
7760                                         ToolButton.Name := DUMMYCOMPNAME;
7761                                 end;
7762                                 ToolButton.Style := tbsSeparator;
7763                                 ToolButton.Width := 0;
7764                                 ToolButton.Left  := ListToolBar.Controls[ i ].Left;
7765                                 ListToolBar.InsertControl(ToolButton);
7766                                 ToolButton.Visible := False;
7767
7768                                 // \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·
7769                                 if (i + 1) < ListToolBar.ControlCount then
7770                                         if ListToolBar.Controls[ i + 1 ] is TToolButton then
7771                                                 if TToolButton( ListToolBar.Controls[ i + 1 ] ).Style = tbsSeparator then
7772                                                         ListToolBar.Controls[ i + 1 ].Visible := False;
7773
7774
7775                                 // \83X\83\8c\83b\83h\8di\8d\9e\83{\83^\83\93\82ð\89B\82·
7776                                 ListToolBar.Controls[ i ].Visible := False;
7777
7778                                 break;
7779                         end;
7780                 end;
7781         except
7782         end;
7783 end;
7784
7785 initialization
7786                                 OleInitialize(nil);
7787 finalization
7788                                 OleUninitialize;
7789
7790 end.