OSDN Git Service

書き込み機能の復旧 & ローカルルール取得の隠蔽
[gikonavigoeson/gikonavi.git] / Editor.pas
1 unit Editor;
2
3 interface
4
5 uses
6         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7         Dialogs, StdCtrls, ComCtrls, ExtCtrls, ToolWin, Menus, OleCtrls, Registry,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10 {$ELSE}
11         SHDocVw_TLB,
12 {$IFEND}
13         ActiveX, {HTTPApp,} YofUtils, Trip, IniFiles, StrUtils,
14         GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
15         IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
16         IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
17         IdLogBase, IdLogDebug, IdException, DateUtils, MojuUtils, bmRegExp;
18
19 type
20 //      TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
21         //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
22         TGikoResultType = (grtOK, grtCookie, grtCheck, grtError);
23
24         TEditorForm = class(TForm)
25                 MainMenu: TMainMenu;
26                 FileMenu: TMenuItem;
27                 PostMessage: TMenuItem;
28                 SaveMessage: TMenuItem;
29                 CloseMenu: TMenuItem;
30                 N01: TMenuItem;
31                 StatusBar: TStatusBar;
32                 EditorPage: TPageControl;
33                 EditorTab: TTabSheet;
34                 PreviewTab: TTabSheet;
35                 Browser: TWebBrowser;
36                 EditMenu: TMenuItem;
37                 UndoMenu: TMenuItem;
38                 CutMenu: TMenuItem;
39                 CopyMenu: TMenuItem;
40                 PasteMenu: TMenuItem;
41                 N02: TMenuItem;
42                 ToolBarImageList: TImageList;
43                 HotToobarImageList: TImageList;
44                 BodyEdit: TMemo;
45                 NameBasePanel: TPanel;
46                 NameLabel: TLabel;
47                 MailLabel: TLabel;
48                 NameComboBox: TComboBox;
49                 MailComboBox: TComboBox;
50                 ToolBar: TToolBar;
51                 SendToolButton: TToolButton;
52                 OutBoxToolButton: TToolButton;
53                 ToolButton5: TToolButton;
54                 UndoToolButton: TToolButton;
55                 CutToolButton: TToolButton;
56                 CopyToolButton: TToolButton;
57                 PasteToolButton: TToolButton;
58                 ToolButton3: TToolButton;
59                 TransToolButton: TToolButton;
60                 TopToolButton: TToolButton;
61                 Indy: TIdHTTP;
62                 IdAntiFreeze: TIdAntiFreeze;
63                 ToolButton1: TToolButton;
64                 ToolButton2: TToolButton;
65                 ActionList: TActionList;
66                 SendAction: TAction;
67                 SaveAction: TAction;
68                 CloseAction: TAction;
69                 UndoAction: TAction;
70                 CutAction: TAction;
71                 CopyAction: TAction;
72                 PasteAction: TAction;
73                 AbortAction: TAction;
74                 TopAction: TAction;
75                 Show1: TMenuItem;
76                 T1: TMenuItem;
77                 N1: TMenuItem;
78                 S1: TMenuItem;
79                 SageCheckBox: TCheckBox;
80                 IdLogDebug: TIdLogDebug;
81                 TransAction: TAction;
82                 A1: TMenuItem;
83                 KotehanCheckBox: TCheckBox;
84                 TitlePanel: TPanel;
85                 Label1: TLabel;
86                 TitleEdit: TEdit;
87                 SelectAllAction: TAction;
88                 N2: TMenuItem;
89                 SelectAll1: TMenuItem;
90     Timer1: TTimer;
91     QuotePasteAction: TAction;
92     QuotePasteMenuItem: TMenuItem;
93     C1: TMenuItem;
94     SpaceToNBSPAction: TAction;
95     AmpToCharRefAction: TAction;
96     SpaceTabnbsp1: TMenuItem;
97     amp1: TMenuItem;
98                 procedure EditorPageChange(Sender: TObject);
99                 procedure FormCreate(Sender: TObject);
100                 procedure BrowserStatusTextChange(Sender: TObject;
101                         const Text: WideString);
102                 procedure FormClose(Sender: TObject; var Action: TCloseAction);
103                 procedure FormDestroy(Sender: TObject);
104                 procedure SendActionExecute(Sender: TObject);
105                 procedure SaveActionExecute(Sender: TObject);
106                 procedure AbortActionExecute(Sender: TObject);
107                 procedure CloseActionExecute(Sender: TObject);
108                 procedure UndoActionExecute(Sender: TObject);
109                 procedure CutActionExecute(Sender: TObject);
110                 procedure CopyActionExecute(Sender: TObject);
111                 procedure PasteActionExecute(Sender: TObject);
112                 procedure SendActionUpdate(Sender: TObject);
113                 procedure SaveActionUpdate(Sender: TObject);
114                 procedure CloseActionUpdate(Sender: TObject);
115                 procedure UndoActionUpdate(Sender: TObject);
116                 procedure CutActionUpdate(Sender: TObject);
117                 procedure CopyActionUpdate(Sender: TObject);
118                 procedure PasteActionUpdate(Sender: TObject);
119                 procedure TopActionExecute(Sender: TObject);
120                 procedure TopActionUpdate(Sender: TObject);
121                 procedure SageCheckBoxClick(Sender: TObject);
122                 procedure MailComboBoxChange(Sender: TObject);
123                 procedure TransActionExecute(Sender: TObject);
124                 procedure TransActionUpdate(Sender: TObject);
125                 procedure IdLogDebugReceive(ASender: TIdConnectionIntercept;
126                         AStream: TStream);
127                 procedure IdLogDebugSend(ASender: TIdConnectionIntercept;
128                         AStream: TStream);
129                 procedure SelectAllActionExecute(Sender: TObject);
130     procedure StatusBarResize(Sender: TObject);
131     procedure Timer1Timer(Sender: TObject);
132     procedure FormActivate(Sender: TObject);
133     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
134                 procedure QuotePasteActionExecute(Sender: TObject);
135     procedure SpaceToNBSPActionExecute(Sender: TObject);
136     procedure AmpToCharRefActionExecute(Sender: TObject);
137         private
138                 FThreadItem: TThreadItem;
139                 FBoard: TBoard;
140                 FNameComboEdit: THandle;
141                 FMailComboEdit: THandle;
142                 FAbort: Boolean;
143                 FWork: Boolean;
144                 FStatusCode: Integer;
145                 FDebugStrReceive: string;
146                 FDebugStrSend: string;
147         FSambaTime: TDateTime;
148         FHost: string;
149                 FNow: TDateTime;
150                 procedure Preview;
151                 function RepHtml(s: string): string;
152                 function Check: Boolean;
153                 procedure SetNameList(sName, sMail: string);
154 //              procedure Send(SendType: TGikoSendType; SPID: string; PON: string; FirstWriting: Boolean);
155                 procedure Send(SPID: string; PON: string; FirstWriting: Boolean);
156
157                 function GetActiveControlHandle: THandle;
158 //              function GetSendData: string;
159 //              procedure GetSendData(Source: TStringStream);
160                 procedure GetSendData(Source: TStringStream);
161                 procedure SaveSendFile;
162                 procedure SetContent(Content: string);
163                 function GetSPID(CookieLine: string): string;
164                 function GetPON(CookieLine: string): string;
165                 function GetResultType(ResponseText: string): TGikoResultType;
166         procedure ReadSambaTime(const AHost: string);
167         procedure WriteSambaTime(const AHost: string; ATime: TDateTime);
168         function ReadSettingTime(const AHost: string): Integer;
169         function CheckSambaTime(const AHost: string; ATime: TDateTime): Boolean;
170                                 procedure SetSamba24(AURL: string);
171                 /// \88ø\97p\95\84\82Ì\8eæ\93¾
172                 function GetOEIndentChar : string;
173                 /// \96{\95\82Ì\8eæ\93¾
174                 function GetBody : string;
175         protected
176                 procedure CreateParams(var Params: TCreateParams); override;
177         public
178                 procedure SetFont;
179                 procedure SetThreadItem(Item: TThreadItem);
180                 procedure SetBoard(Item: TBoard);
181         end;
182
183 implementation
184
185 uses
186         Giko, ItemDownload;
187 const
188         CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
189         CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
190
191     // \83G\83f\83B\83b\83g\83E\83B\83\93\83h\83E\82ð\89E\89º\82É\82¸\82ç\82µ\82Ä\8aJ\82­\88Ú\93®\97Ê
192     WINDOWMOVE_H = 30;
193     WINDOWMOVE_V = 30;
194
195         //DAX\82³\82ñ±Ø¶ÞÄ!(\81L\81¤\81M)
196         READCGI_ERR                     = '-ERR';
197         READCGI_INCR            = '-INCR';
198         READCGI_OK                      = '+OK';
199         READCGI_PARTIAL = '+PARTIAL';
200         READCGI_ERR_FOUND_KAKO  = '-ERR \89ß\8b\8e\83\8d\83O\91q\8cÉ\82Å\94­\8c©';
201         READCGI_ERR_NOT_HTML            = '-ERR html\89»\91Ò\82¿';
202         READCGI_ERR_NOT_FOUND           = '-ERR \82»\82ñ\82È\94Âor\83X\83\8c\83b\83h\82È\82¢\82Å\82·\81B';
203         READCGI_ERR_ABONE                               = '-ERR \82Ç\82±\82©\82Å\82 \82Ú\81[\82ñ\82ª\82 \82Á\82½\82Ý\82½\82¢\82Å\82·\81B';
204         READCGI_ERR_TIMEOUT                     = '-ERR \8ew\92è\8e\9e\8aÔ\82ª\89ß\82¬\82Ü\82µ\82½\81B';
205         READCGI_ERR_CANTUSE                     = '-ERR \82à\82¤\81@\82Â\82©\82¦\82Ü\82¹\82ñ';
206         RES2CH_TRUE                             = '<!-- 2ch_X:true -->';
207         RES2CH_FALSE                    = '<!-- 2ch_X:false -->';
208         RES2CH_ERROR                    = '<!-- 2ch_X:error -->';
209         RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
210         RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
211
212
213 type
214         TSelection = record
215                 StartPos, EndPos: Integer;
216         end;
217
218 {$R *.DFM}
219
220 {constructor TEditorForm.Create(AOwner: TComponent; Item: TBoard);
221 begin
222         inherited Create(AOwner);
223 end;}
224
225 procedure TEditorForm.CreateParams(var Params: TCreateParams);
226 begin
227         inherited;
228         if FormStyle in [fsNormal, fsStayOnTop] then
229                 if BorderStyle in [bsSingle, bsSizeable] then begin
230                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
231                         Params.WndParent := 0;
232                 end;
233 end;
234
235 {procedure TEditorForm.CreateParams(var Params: TCreateParams);
236 begin
237         inherited CreateParams(Params);
238         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
239 end;}
240
241 procedure TEditorForm.FormCreate(Sender: TObject);
242 var
243         wp: TWindowPlacement;
244                 hUser32 : HINST;
245 begin
246         FWork := False;
247         Browser.Navigate('about:blank');
248
249         FBoard := nil;
250         FThreadItem := nil;
251
252         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
253         wp.length := sizeof(wp);
254         wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
255         wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
256
257         wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
258         wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
259         wp.showCmd := SW_HIDE;
260         SetWindowPlacement(Handle, @wp);
261
262         if GikoSys.Setting.EditWindowMax then
263                 WindowState := wsMaximized;
264
265         //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
266         if (Left + Width) > Screen.Width then
267 //              Left := Screen.Width - Width;
268                 Left := 0;
269         if (Top + Height) > Screen.Height then
270 //              Top := Screen.Height - Height;
271                 Top := 0;
272         if Left < 0 then
273                 Left := 0;
274         if Top < 0 then
275                 Top := 0;
276
277     //\8c»\8dÝ\82Ì\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82ð\95Û\91
278     GikoSys.Setting.EditWindowTop := Top  + WINDOWMOVE_V;   // \8e\9f\82É\8aJ\82­\83E\83B\83\93\83h\83E\82Í
279     GikoSys.Setting.EditWindowLeft := Left + WINDOWMOVE_H;  // \81@\81@\81@\89E\8eÎ\82ß\89º\82É\82¸\82ç\82·
280     //\83E\83B\83\93\83h\83E\82Ì\95\9d\82Æ\8d\82\82³\82ª\8f¬\82³\82·\82¬\82¢\82ê\82Î\8c³\82É\96ß\82·
281         if GikoSys.Setting.EditWindowHeight < 144 then
282                 Height := 400;
283         if GikoSys.Setting.EditWindowWidth < 144 then
284                 Width := 640;
285
286         EditorPage.ActivePage := EditorTab;
287         FNameComboEdit := GetWindow(NameComboBox.Handle, GW_CHILD);
288         FMailComboEdit := GetWindow(MailComboBox.Handle, GW_CHILD);
289         NameComboBox.Items.Assign(GikoSys.Setting.NameList);
290         MailComboBox.Items.Assign(GikoSys.Setting.MailList);
291         SetFont;
292         hUser32 := 0;
293         try
294                 try
295                         hUser32 := LoadLibrary('User32.dll');
296                         if hUser32 <> 0 then
297                                 TransAction.Enabled := true
298                         else
299                                 TransAction.Enabled := false;
300                 except
301                 TransAction.Enabled := false;
302                 end;
303         finally
304                 FreeLibrary(hUser32);
305         end;
306
307     // \83E\83B\83\93\83h\83E\82Ì\83X\83e\83C\8fó\91Ô
308         if GikoSys.Setting.EditWindowStay then begin    // \83X\83e\83C\8fó\91Ô
309                 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
310                 TopAction.Checked := true;
311                 TopToolButton.Down := true;
312         end else begin                                  // \83X\83e\83C\82µ\82È\82¢
313                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
314                 TopAction.Checked := false;
315                 TopToolButton.Down := false;
316         end;
317
318     // \83E\83B\83\93\83h\83E\82Ì\94¼\93§\96¾\8fó\91Ô
319         if(GikoSys.Setting.EditWindowTranslucent) and (TransAction.Enabled) then begin // \94¼\93§\96¾\81i\83g\83\89\83\93\83X\83\8b\81[\83Z\83\93\83g\81j\8fó\91Ô
320         AlphaBlend := true;
321         TransAction.Checked := true;
322         TransToolButton.Down := true;
323     end else begin                                      // \95s\93§\96¾
324         AlphaBlend := false;
325         TransAction.Checked := false;
326         TransToolButton.Down := false;
327     end;
328         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
329         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
330
331         SpaceToNBSPAction.Checked               := GikoSys.Setting.SpaceToNBSP;
332         AmpToCharRefAction.Checked      := GikoSys.Setting.AmpToCharRef;
333 end;
334
335 procedure TEditorForm.SetBoard(Item: TBoard);
336 begin
337         FBoard := Item;
338         Caption := CAPTION_NAME_NEW + ' - [' + Item.Title + ']';
339         NameComboBox.Text := FBoard.KotehanName;
340         MailComboBox.Text := FBoard.KotehanMail;
341         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
342         TitlePanel.Visible := True;
343     SetSamba24('');
344 end;
345
346 procedure TEditorForm.SetThreadItem(Item: TThreadItem);
347 begin
348         FThreadItem := Item;
349         Caption := CAPTION_NAME_RES + ' - [' + FThreadItem.Title + ']';
350         NameComboBox.Text := FThreadItem.ParentBoard.KotehanName;
351         MailComboBox.Text := FThreadItem.ParentBoard.KotehanMail;
352         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
353         TitlePanel.Visible := False;
354     SetSamba24(FThreadItem.ParentBoard.URL);
355 end;
356
357 function TEditorForm.GetBody : string;
358 var
359         body            : string;
360         regexp  : TAWKStr;
361 begin
362
363         body := BodyEdit.Text;
364         if AmpToCharRefAction.Checked then
365                 // & \82Ì\92u\8a·\82Í\88ê\94Ô\8dÅ\8f\89\82É\82â\82é\82±\82Æ
366                 body := CustomStringReplace( body, '&', '&amp;' );
367         if SpaceToNBSPAction.Checked then begin
368                 body := CustomStringReplace( body, #09, '&nbsp;&nbsp;&nbsp;&nbsp;' );
369                 body := CustomStringReplace( body, '  ', '&nbsp;&nbsp;' );
370                 body := CustomStringReplace( body, '&nbsp; ', '&nbsp;&nbsp;' );
371                 regexp := TAWKStr.Create( nil );
372                 try
373                         regexp.RegExp := '^ ';
374                         regexp.GSub( '\&nbsp;', body );
375                 finally
376                         regexp.Free;
377                 end;
378         end;
379
380         Result  := body;
381
382 end;
383
384 procedure TEditorForm.SetFont;
385 begin
386         BodyEdit.Font.Name := GikoSys.Setting.EditorFontName;
387         BodyEdit.Font.Size := GikoSys.Setting.EditorFontSize;
388         BodyEdit.Font.Color := GikoSys.Setting.EditorFontColor;
389         BodyEdit.Color := GikoSys.Setting.EditorBackColor;
390 end;
391
392 procedure TEditorForm.Preview;
393 var
394         Title: string;
395         No: string;
396         Mail: string;
397         Namae: string;
398         DateTime: string;
399         Body: string;
400         s: string;
401
402                                 posTrip : Integer;
403                                 tripOrigin : string;
404 begin
405         if FThreadItem = nil then begin
406                 No := '1';
407                 Title := RepHtml(TitleEdit.Text);
408         end else begin
409                 No := IntToStr(FThreadItem.Count + 1);
410                 Title := RepHtml(FThreadItem.Title);
411         end;
412
413         body := GetBody;
414
415         Namae := RepHtml(NameComboBox.Text);
416         Mail := RepHtml(MailComboBox.Text);
417         Body := RepHtml(body);
418         Body := StringReplace(Body, #13#10, '<br>', [rfReplaceAll]);
419         DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', now);
420
421         if Trim(Namae) = '' then
422                 Namae := '\96¼\96³\82µ\82³\82ñ';
423
424         s := '<HTML><HEAD>' + #13#10
425                         + '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">' + #13#10
426                         + '<TITLE>' + title + '</TITLE>' + #13#10
427 //                      + '<STYLE><!--BODY{font-size : 9pt;font-family : "\82l\82\82o\83S\83V\83b\83N";}--></STYLE>' + #13#10
428                         + '</HEAD>' + #13#10
429                         + '<BODY text="#000000" bgcolor="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">' + #13#10
430                         + '<FONT COLOR="#FF0000">' + title + '</FONT>' + #13#10
431                         + '<DL>' + #13#10;
432                                 posTrip := AnsiPos( '#', Namae );
433                                 if posTrip > 0 then
434                                 begin
435                                                                 tripOrigin := Copy( Namae, posTrip + 1, Length( Namae ) );
436                                                                 Namae :=
437                                                                                                 Copy( Namae, 1, posTrip - 1 ) + '</B> \81\9f' +
438                                                                                                 get_2ch_trip( PChar( tripOrigin ) ) + '<B>';
439                                 end;
440         if Mail = '' then
441                 s := s + '<DT>' + No + ' \81F <FONT color="forestgreen"><B>' + Namae + '</B></FONT> \81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10
442         else
443                 s := s + '<DT>' + No + ' \81F <A href="mailto:' + Mail + '"><B>' + Namae + '</B></A> [' + Mail + ']\81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10;
444         s := s + '</BODY></HTML>';
445         SetContent(s);
446 end;
447
448 function TEditorForm.RepHtml(s: string): string;
449 begin
450 //      s := StringReplace(s, '&', '&amp;', [rfReplaceAll]);
451         s := StringReplace(s, '<', '&lt;', [rfReplaceAll]);
452         s := StringReplace(s, '>', '&gt;', [rfReplaceAll]);
453 //      s := StringReplace(s, ' ', '&nbsp;', [rfReplaceAll]);   //\8ed\97l\95Ï\8dX\82É\82æ\82è&nbsp;\8eg\97p\95s\89Â
454         s := StringReplace(s, '"', '&quot;', [rfReplaceAll]);
455         Result := s;
456 end;
457
458 procedure TEditorForm.EditorPageChange(Sender: TObject);
459 begin
460         if EditorPage.ActivePage = PreviewTab then begin
461                 Preview;
462         end else begin
463                 Browser.Navigate('about:blank');
464         end;
465 end;
466
467 procedure TEditorForm.BrowserStatusTextChange(Sender: TObject;
468         const Text: WideString);
469 begin
470         if EditorPage.ActivePage = PreviewTab then begin
471                 StatusBar.Panels[0].Text := Text;
472         end else begin
473                 StatusBar.Panels[0].Text := '';
474         end;
475 end;
476
477 function TEditorForm.Check: Boolean;
478 var
479         Msg: string;
480         rc: Integer;
481         Board: TBoard;
482 begin
483         Result := True;
484         if FThreadItem = nil then
485                 Board := FBoard
486         else
487                 Board := FThreadItem.ParentBoard;
488
489         if (not GikoSys.Setting.UseMachineTime) and
490                  ((Board.LastGetTime = 0) or
491                         (Board.LastGetTime = ZERO_DATE)) then begin
492                 Msg := '\83T\81[\83o\82Ì\8e\9e\8d\8f\82ª\95ª\82©\82ç\82È\82¢\82½\82ß\81A\91\97\90M\8fo\97\88\82Ü\82¹\82ñ'#13#10
493                                  + '\83X\83\8c\83b\83h\82ð\8dX\90V\81i\8eæ\93¾\81j\8cã\81A15\95b\91Ò\82Á\82Ä\82©\82ç\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢';
494                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
495                 Result := False;
496         end else if BodyEdit.Text = '' then begin
497                 Msg := '\96{\95\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
498                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
499                 Result := False;
500         end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
501                 Msg := '\83^\83C\83g\83\8b\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
502                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
503                 Result := False;
504         end else begin
505                 if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
506                         Msg := '\83\8d\83O\83C\83\93\82µ\82Ä\82¢\82È\82¢\82Ì\82Å\81\9c\82Ì\8b@\94\\82Í\97\98\97p\8fo\97\88\82Ü\82¹\82ñ\81B'#13#10
507                                          + '\82±\82Ì\82Ü\82Ü\91\97\90M\82µ\82Ä\82à\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
508                         rc := MsgBox(Handle, Msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION);
509                         Result := (rc = IDYES);
510                 end;
511         end;
512 end;
513
514 procedure TEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
515 begin
516         Action := caFree;
517 end;
518
519 procedure TEditorForm.FormDestroy(Sender: TObject);
520 var
521         wp: TWindowPlacement;
522 begin
523         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
524         wp.length := sizeof(wp);
525         GetWindowPlacement(Handle, @wp);
526
527         GikoSys.Setting.EditWindowTop := wp.rcNormalPosition.Top;
528         GikoSys.Setting.EditWindowLeft := wp.rcNormalPosition.Left;
529         GikoSys.Setting.EditWindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
530         GikoSys.Setting.EditWindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
531         GikoSys.Setting.EditWindowMax := WindowState = wsMaximized;
532         //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;      // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
533         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;   // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
534
535 end;
536
537 procedure TEditorForm.SetNameList(sName, sMail: string);
538 begin
539         if Trim(sName) <> '' then begin
540                 if GikoSys.Setting.NameList.IndexOf(sName) = -1 then
541                         GikoSys.Setting.NameList.Insert(0, sName);
542         end;
543         if Trim(sMail) <> '' then begin
544                 if GikoSys.Setting.MailList.IndexOf(sMail) = -1 then
545                         GikoSys.Setting.MailList.Insert(0, sMail);
546         end;
547 end;
548
549 function TEditorForm.GetActiveControlHandle: THandle;
550 begin
551         if EditorPage.ActivePage = EditorTab then begin
552                 if ActiveControl = NameComboBox then
553                         Result := FNameComboEdit
554                 else if ActiveControl = MailComboBox then
555                         Result := FMailComboEdit
556                 else if ActiveControl = BodyEdit then
557                         Result := BodyEdit.Handle
558                 else if ActiveControl = TitleEdit then
559                         Result := TitleEdit.Handle
560                 else
561                         Result := 0;
562         end else
563                 Result := 0;
564 end;
565
566 procedure TEditorForm.SetContent(Content: string);
567 var
568         doc : Variant;
569 begin
570         if Browser.Document <> nil then begin
571                 doc := Browser.Document;
572                 doc.Clear;
573                 doc.open;
574                 doc.charset := 'Shift_JIS';
575                 doc.Write(Content);
576                 doc.Close;
577         end;
578 end;
579
580 procedure TEditorForm.Send(SPID: string; PON: string; FirstWriting: Boolean);
581 var
582         TextStream: TStringStream;
583         Source: TStringStream;
584         ResponseText: string;
585         URL: string;
586         RefURL: string;
587         State: TGikoDownloadState;
588         ResultType: TGikoResultType;
589         MsgResult: Integer;
590         Cookie: string;
591         Board: TBoard;
592         sysMenu : HMENU;
593         //fusianasan\83g\83\89\83b\83v by\92è\8aú\95Ö
594         Namae: String;
595         SettingTxt: String;
596         RefeURL: string;
597         RuleURL: String;
598         RuleTxt: String;
599 begin
600         FAbort := False;
601         State := gdsError;
602         Namae := RepHtml(NameComboBox.Text);
603         if FThreadItem = nil then
604                 Board := FBoard
605         else
606                 Board := FThreadItem.ParentBoard;
607
608         Indy.Request.Clear;
609         Indy.ProxyParams.BasicAuthentication := False;
610         if GikoSys.Setting.WriteProxy then begin
611                 Indy.ProxyParams.ProxyServer := GikoSys.Setting.WriteProxyAddress;
612                 Indy.ProxyParams.ProxyPort := GikoSys.Setting.WriteProxyPort;
613                 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.WriteProxyUserID;
614                 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.WriteProxyPassword;
615                 if GikoSys.Setting.ReadProxyUserID <> '' then
616                         Indy.ProxyParams.BasicAuthentication := True;
617         end else begin
618                 Indy.ProxyParams.ProxyServer := '';
619                 Indy.ProxyParams.ProxyPort := 80;
620                 Indy.ProxyParams.ProxyUsername := '';
621                 Indy.ProxyParams.ProxyPassword := '';
622         end;
623         if FThreadItem = nil then begin
624                 URL := FBoard.GetSendURL;
625                 RefURL := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
626         end else begin
627                 URL := FThreadItem.GetSendURL;
628                 RefURL := FThreadItem.URL;
629         end;
630         Indy.Request.UserAgent := GikoSys.GetUserAgent;
631         Indy.Request.Referer := RefURL;
632         Indy.Request.AcceptEncoding := '';
633
634         Cookie := '';
635         if SPID <> '' then
636                 Cookie := Cookie + 'SPID=' + SPID + '; ';
637         if PON <> '' then
638                 Cookie := Cookie + 'PON=' + PON + '; ';
639         Cookie := 'Cookie: ' + Cookie + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
640
641         sysMenu := GetSystemMenu( Handle, false );
642         EnableMenuItem( sysMenu, SC_CLOSE, MF_GRAYED );
643 {
644   EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
645   DrawMenuBar(Handle);
646 }
647         Indy.Request.CustomHeaders.Clear;
648 //      Indy.Request.CacheControl := 'no-cache';
649         Indy.Request.CustomHeaders.Add('Pragma: no-cache');
650         Indy.Request.AcceptLanguage := 'ja';
651         Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
652         Indy.Request.ContentType := 'application/x-www-form-urlencoded';
653         Indy.Request.CustomHeaders.Add(Cookie);
654         TextStream := TStringStream.Create('');
655         Source := TStringStream.Create('');
656         try
657                 try
658                         FDebugStrReceive := '';
659                         FDebugStrSend := '';
660                         GetSendData(Source);
661                         Indy.Post(URL, Source, TextStream);
662                         ResponseText := TextStream.DataString;
663
664                         ResultType := GetResultType(ResponseText);
665
666                         //MsgResult\8f\89\8aú\89»
667                         MsgResult := IDNO;
668                         //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
669                         if ((Namae = '\8eR\8dè\8fÂ') or (Namae = 'fusianasan')) and (FirstWriting) then begin
670                                 MsgResult := MsgBox(
671                                                 Handle,
672                                         '\83\8a\83\82\81[\83g\83z\83X\83g\82ð\95\\8e¦\82·\82é\8b@\94\\82ª\8eg\82í\82ê\82Ä\82¢\82Ü\82·' + #13#10 +
673                                         '\82à\82µ\82à\8aÔ\88á\82Á\82Ä\82±\82Ì\95û\96@\82Å\83z\83X\83g\82ª\95\\8e¦\82³\82ê\82½\82Æ\82µ\82Ä\82à\81A\8e©\8cÈ\90Ó\94C\82È\82Ì\82Å\8dí\8f\9c\88Ë\97\8a\82É\82Í\89\9e\82\82Ü\82¹\82ñ\81B' + #13#10#13#10 +
674                                         '\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
675                                         '\8fî\95ñ',
676                                         MB_YESNO or MB_ICONQUESTION);
677                                 if MsgResult = IDNO  then begin
678                                         Board.SPID := '';
679                                         Board.PON := '';
680                                         FWork := false;
681                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
682                                         DrawMenuBar(Handle);
683                                         Exit;
684                                 end;
685                         end;
686                         {
687                         //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(SETTING.TXT Mode) by \92è\8aú\95Ö
688                         RefURL := GikoSys.UrlToServer(FBoard.URL)
689                                 + GikoSys.UrlToID(FBoard.URL)
690                                 + '/';
691                         //RefURL\82ð\8c³\82ÉSETTING.TXT\83A\83h\83\8c\83X\8ew\92è
692                         RefeURL := RefURL
693                                 + 'SETTING.TXT';
694
695                                                 //\8e\8e\82µ\82É\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\82à
696                                                 RuleURL := RefURL
697                                                                 + 'head.txt';
698                                                 //\8eæ\93¾\81`
699                         Settingtxt := Indy.Get(RefeURL);
700                                                 RuleTxt := Indy.Get(RuleURL);
701
702                                                 //SETTING.TXT In DebugOnly
703                                                 if Settingtxt = '' then begin
704                                                                 ShowMessage('\8eæ\93¾\8e¸\94s');
705                                                                 Exit;
706                                                 end else begin
707                                                                 ShowMessage('\8eæ\93¾\90¬\8c÷' + #13#10 + Settingtxt);
708                                                                 Exit;
709                                                 end;
710
711                                                 //RocalRule In Debug Only
712                                                 if RuleTxt = '' then begin
713                                                                 ShowMessage('\8eæ\93¾\8e¸\94s');
714                                                                 Exit;
715                                                 end else begin
716                                                                 ShowMessage('\8eæ\93¾\90¬\8c÷' + #13#10 + RuleTxt);
717                                                 end;
718                         }
719                         if ResultType = grtOK then begin
720                                 WriteSambaTime(FHost, Now());
721                                 State := gdsComplete;
722                         end else if ResultType = grtCookie then begin
723                                 //\83\8b\81[\83v\96h\8e~
724                                 if not FirstWriting then
725                                         raise Exception.Create('');
726                                 MsgResult := MsgBox(
727                                         Handle,
728                                         '\81E\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81A\95Û\91\81A\88ø\97p\81A\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
729                                         '\81E\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10#13#10 +
730                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
731                                         '\8fî\95ñ',
732                                         MB_YESNO or MB_ICONQUESTION);
733                                 if MsgResult = IDYES then begin
734                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
735                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
736                                         if (Board.SPID = '') and (Board.PON = '') then
737                                                 raise Exception.Create('');
738                                         //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
739                                         Send(Board.SPID, Board.PON, False);
740                                         Exit;
741                                 end else begin
742                                         Board.SPID := '';
743                                         Board.PON := '';
744                                         FWork := false;
745                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
746                                         DrawMenuBar(Handle);
747                                         Exit;
748                                 end;
749                         end else if ResultType = grtCheck then begin
750                                 //
751                                 //\83\8b\81[\83v\96h\8e~
752                                 if not FirstWriting then
753                                         raise Exception.Create('');
754
755                                 MsgResult := MsgBox(
756                                         Handle,
757                                         '\8f\91\82«\8d\9e\82Ý\82É\8aÖ\82µ\82Ä\82Í\97l\81X\82È\83\8d\83O\8fî\95ñ\82ª\8bL\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B' + #13#10 +
758                                         '\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10 +
759                                         '\8cö\8f\98\97Ç\91­\82É\94½\82µ\82½\82è\81A\91¼\90l\82É\96À\98f\82ð\82©\82¯\82é\8f\91\82«\8d\9e\82Ý\82Í\8dT\82¦\82Ä\89º\82³\82¢\81B' + #13#10 +
760                                         '\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81E\95Û\91\81E\88ø\97p\81E\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
761                                         #13#10 +
762                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
763                                         '\8am\94F',
764                                         MB_YESNO or MB_ICONQUESTION);
765
766                                 if MsgResult = IDYES then begin
767                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
768                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
769                                         if (Board.SPID = '') and (Board.PON = '') then
770                                                 raise Exception.Create('');
771                                         Send(Board.SPID, Board.PON, False);
772                                         Exit;
773                                 end else begin
774                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
775                                         DrawMenuBar(Handle);
776                                         Board.SPID := '';
777                                         Board.PON := '';
778                                         FWork := false;
779                                         Exit;
780                                         end;
781                         end else begin
782                 WriteSambaTime(FHost, Now());
783                                 State := gdsError;
784                                 raise Exception.Create('');
785                         end;
786
787                 except
788                         on E: EIdConnectException do begin
789                                 State := gdsError;
790                                 ResponseText := '<html><body>'
791                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
792                                                                                         + '\89ñ\90ü\82â\83v\83\8d\83L\83V\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
793                                                                                         + '<br><br><div>' + E.Message + '</div>'
794                                                                                         + '</body></html>';
795                         end;
796                         on E: Exception do begin
797                                 State := gdsError;
798
799                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
800                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
801                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
802                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
803
804                                 ResponseText := '<html><body>' + TextStream.DataString;
805                                 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
806                                 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
807                                 ResponseText := ResponseText + '<hr><div align="left"><pre>';
808                                 ResponseText := ResponseText + '<b>\82±\82±\82©\82ç\83M\83R\83i\83r\82Ì\8fî\95ñ</b>'#13#10;
809                                 ResponseText := ResponseText + #13#10'\81\9c\91\97\90M'#13#10;
810                                 ResponseText := ResponseText + FDebugStrSend;
811                                 ResponseText := ResponseText + #13#10'\81\9c\8eó\90M'#13#10;
812                                 ResponseText := ResponseText + FDebugStrReceive;
813                                 ResponseText := ResponseText + '</pre></div></body></html>';
814                         end;
815                 end;
816                 FStatusCode := Indy.ResponseCode;
817                 if FAbort then
818                         State := gdsAbort;
819         finally
820                 Source.Free;
821                 TextStream.Free;
822                 //sysMenu := GetSystemMenu( Handle, true );
823                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
824                 DrawMenuBar(Handle);
825         end;
826         FWork := false;
827         //\94ñ\8cö\8e®\83M\83R\83i\83r\94Â\82È\82Ç\82Ì\83X\83N\83\8a\83v\83g\97p
828         //ResponceCode\82ª302Found\82Å\8f\91\82«\8d\9e\82Ý\8a®\97¹
829         if FStatusCode = 302 then begin
830                 GikoForm.PlaySound('ResEnd');
831                 SaveSendFile;
832                 if FThreadItem = nil then
833                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
834                 else
835                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
836                 Close;
837         end;
838         if State = gdsComplete then begin
839                 GikoForm.PlaySound('ResEnd');
840                 SaveSendFile;
841                 if FThreadItem = nil then
842                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
843                 else
844                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
845                 Close;
846         end else if State = gdsError then begin
847                 if FThreadItem = nil then
848                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG)
849                 else
850                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
851                 EditorPage.ActivePage := PreviewTab;
852                 SetContent(ResponseText);
853         end else if State = gdsAbort then begin
854                 GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
855         end;
856 end;
857
858 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
859 begin
860         if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
861                 Result := grtOK
862         else if (AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
863                                         (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
864                                         (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0)        or
865                                         //(AnsiPos('\83N\83b\83L\81[\8am\94F', ResponseText) > 0) or
866                                         (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)      then
867                 Result := grtCookie
868         else if (AnsiPos('<font size=+2 color=#FF0000>\8f\91\82«\8d\9e\82Ý\83`\83F\83b\83N\81I </font>', ResponseText) > 0)   or
869                                         (AnsiPos('<title>\81¡ \8f\91\82«\8d\9e\82Ý\8am\94F\82µ\82Ü\82· \81¡</title>', ResponseText) > 0)  or
870                                         (AnsiPos('<title>\93\8a\8de\8am\94F</title>', ResponseText) > 0)  or
871                                         (AnsiPos('<b>\8f\91\82«\82±\82Ý\8am\94F</b>', ResponseText) > 0)      or
872                                         (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0)   or
873                                         (AnsiPos(RES2CH_FALSE, ResponseText) > 0)       then
874                 Result := grtCheck
875         else
876                 Result := grtError;
877 end;
878
879
880 procedure TEditorForm.GetSendData(Source: TStringStream);
881 var
882         SessionID: string;
883         s: string;
884         SendTime: Integer;
885         Adjust: Integer;
886         Board: TBoard;
887         body            : string;
888 begin
889         if FThreadItem = nil then
890                 Board := FBoard
891         else
892                 Board := FThreadItem.ParentBoard;
893
894         if GikoSys.Setting.UseMachineTime then begin
895                 if GikoSys.Setting.TimeAdjust then
896                         Adjust := Gikosys.Setting.TimeAdjustSec
897                 else
898                         Adjust := GikoSys.Setting.TimeAdjustSec * -1;
899                 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
900         end else begin
901                 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
902                         SendTime := GikoSys.DateTimeToInt(Now)
903                 else
904                         SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
905         end;
906
907         body := GetBody;
908
909         SessionID := GikoSys.Dolib.SessionID;
910         if SessionID <> '' then
911                 s := 'sid=' + HttpEncode(SessionID) + '&'
912         else
913                 s := '';
914         s := s + 'subject=&'
915                                  + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
916                                  + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
917                                  + 'MESSAGE=' + HttpEncode(body) + '&'
918                                  + 'bbs=' + Board.BBSID + '&'
919                                  + 'time=' + IntToStr(SendTime) + '&';
920         if FThreadItem = nil then begin
921                 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
922                 s := s + 'submit=' + HttpEncode('\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Þ') + #13#10;
923         end else begin
924                 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
925                 s := s + 'submit=' + HttpEncode('\8f\91\82«\8d\9e\82Þ') + #13#10;
926         end;
927         Source.WriteString(s);
928 end;
929
930 procedure TEditorForm.SaveSendFile;
931 var
932         sDate: string;
933         ini: TMemIniFile;
934 begin
935         ini := TMemIniFile.Create(GikoSys.GetSentFileName);
936         try
937                 sDate := IntToStr(GikoSys.DateTimeToInt(Now));
938
939                 ini.WriteString(sDate, 'Name', NameComboBox.Text);
940                 ini.WriteString(sDate, 'EMail', MailComboBox.Text);
941                 ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
942                 ini.WriteInteger(sDate, 'Status', FStatusCode);
943                 ini.WriteDateTime(sDate, 'Date', Now);
944                 if FThreadItem = nil then begin
945                         ini.WriteString(sDate, 'Title', TitleEdit.Text);
946                         ini.WriteString(sDate, 'BBS', FBoard.BBSID);
947                         ini.WriteInteger(sDate, 'NewThread', 1);
948                 end else begin
949                         ini.WriteString(sDate, 'Title', FThreadItem.Title);
950                         ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
951                         ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
952                 end;
953
954                 ini.UpdateFile;
955         finally
956                 ini.Free;
957         end;
958 end;
959
960 procedure TEditorForm.SendActionExecute(Sender: TObject);
961 var
962         Board: TBoard;
963         rc: Integer;
964         state : TGikoDownloadState;
965         body            : string;
966 begin
967         if FWork then
968                 Exit;
969         try
970                 FWork := True;
971                 SendAction.Enabled := False;
972                 Application.ProcessMessages;
973                 if not Check then Exit;
974
975                 if FThreadItem = nil then
976                         Board := FBoard
977                 else
978                         Board := FThreadItem.ParentBoard;
979
980                 if FThreadItem = nil then begin
981                         rc := GikoUtil.MsgBox(Handle,
982                                                                                                         '\81u' + Board.Title + '\81v\94Â\82É\90V\82µ\82¢\83X\83\8c\83b\83h\97§\82Ä\82Ü\82·'#13#10#13#10
983                                                                                                         + '\81E\94Â\82Ì\83\8b\81[\83\8b\82ð\8eç\82Á\82½\8f\91\82«\8d\9e\82Ý\82Å\82 \82é\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10
984                                                                                                         + '\81E\91¼\82É\93¯\82\82æ\82¤\82È\83X\83\8c\83b\83h\82ª\96³\82©\82Á\82½\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10#13#10
985                                                                                                         + '\81u\82Í\82¢\81v\82ð\89\9f\82·\82Æ\91\97\90M\82µ\82Ü\82·',
986                                                                                                         '\8am\94F',
987                                                                                                         MB_ICONQUESTION or MB_YESNO);
988                         if rc <> ID_YES then
989                                 Exit;
990                 end;
991
992                 SetNameList(NameComboBox.Text, MailComboBox.Text);
993                 if KotehanCheckBox.Checked then begin
994                         Board.KotehanName := NameComboBox.Text;
995                         Board.KotehanMail := MailComboBox.Text;
996                 end;
997
998                 if Board.IsBoardPlugInAvailable then begin
999                         body := GetBody;
1000
1001                         if FThreadItem = nil then begin
1002                                 // \83X\83\8c\97§\82Ä
1003                                 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
1004                                         DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
1005
1006                                 if state = gdsComplete then begin
1007                                         GikoForm.PlaySound('ResEnd');
1008                                         SaveSendFile;
1009                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK);
1010                                         FWork := False;
1011                                         Close;
1012                                 end else if State = gdsError then begin
1013                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG);
1014                                 end else if State = gdsAbort then begin
1015                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
1016                                 end;
1017                         end else begin
1018                                 // \83\8c\83X
1019                                 state := TGikoDownloadState( FThreadItem.BoardPlugIn.WriteThread(
1020                                         DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
1021
1022                                 if state = gdsComplete then begin
1023                                         GikoForm.PlaySound('ResEnd');
1024                                         SaveSendFile;
1025                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
1026                     FWork := False;
1027                                         Close;
1028                                 end else if State = gdsError then begin
1029                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
1030                                 end else if State = gdsAbort then begin
1031                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
1032                                 end;
1033                         end;
1034                 end else begin
1035                         if not Timer1.Enabled then
1036                                 Send(Board.SPID, Board.PON, True)
1037                         else begin
1038                                 if not CheckSambaTime(FHost, Now()) then begin
1039                                         rc := GikoUtil.MsgBox(Handle,
1040                                                                 'Samba24\82Ì\8bK\92è\92l\96¢\96\9e\82Ì\95b\90\94\82µ\82©\8co\89ß\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B'#13#10
1041                                                                 + '\91\97\90M\82ð\92\86\8e~\82µ\82Ü\82·\82©\81H' + #13#10
1042                                                                 + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', 'Samba24\8cx\8d\90',
1043                                                                 MB_YESNO or MB_ICONQUESTION);
1044                                         if rc = IDYES then begin
1045                                                 FWork := false;
1046                                                 Exit;
1047                                         end;
1048                                 end;
1049                                 Send(Board.SPID, Board.PON, True);
1050                         end;
1051                 end;
1052         finally
1053                 FWork := False;
1054                 if Timer1.Enabled then
1055                         ReadSambaTime(FHost);
1056         end;
1057 end;
1058
1059 procedure TEditorForm.SaveActionExecute(Sender: TObject);
1060 begin
1061 //
1062 end;
1063
1064 procedure TEditorForm.CloseActionExecute(Sender: TObject);
1065 begin
1066         Close;
1067 end;
1068
1069 procedure TEditorForm.UndoActionExecute(Sender: TObject);
1070 begin
1071         SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
1072 end;
1073
1074 procedure TEditorForm.CutActionExecute(Sender: TObject);
1075 begin
1076         SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
1077 end;
1078
1079 procedure TEditorForm.CopyActionExecute(Sender: TObject);
1080 begin
1081         SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
1082 end;
1083
1084 procedure TEditorForm.PasteActionExecute(Sender: TObject);
1085 begin
1086         SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
1087 end;
1088
1089 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
1090 begin
1091         SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
1092 end;
1093
1094 procedure TEditorForm.TopActionExecute(Sender: TObject);     // \83E\83B\83\93\83h\83E\8dÅ\91O\96Ê(Stay)\83{\83^\83\93\82Ì\8f\88\97\9d
1095 begin
1096         if not (fsShowing in Self.FormState) then begin
1097                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
1098                         SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1099                         GikoSys.Setting.EditWindowStay := true;
1100                 end     else begin   // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
1101                         SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1102                         GikoSys.Setting.EditWindowStay := false;
1103                 end;
1104                 // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
1105                 //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;
1106         end;
1107 end;
1108
1109 procedure TEditorForm.AbortActionExecute(Sender: TObject);
1110 begin
1111         FAbort := True;
1112 end;
1113
1114 procedure TEditorForm.SendActionUpdate(Sender: TObject);
1115 begin
1116         SendAction.Enabled := not FWork;
1117 end;
1118
1119 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
1120 begin
1121         SaveAction.Enabled := False;
1122 end;
1123
1124 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
1125 begin
1126         CloseAction.Enabled := not FWork;
1127 end;
1128
1129 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
1130 begin
1131         UndoAction.Enabled := (GetActiveControlHandle <> 0)
1132                                                                                                 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
1133                                                                                                 and (not FWork);
1134 end;
1135
1136 procedure TEditorForm.CutActionUpdate(Sender: TObject);
1137 var
1138         Selection: TSelection;
1139         AHandle: THandle;
1140 begin
1141         AHandle := GetActiveControlHandle;
1142         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1143         CutAction.Enabled := (AHandle <> 0)
1144                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1145                                                                                 and (not FWork);
1146 end;
1147
1148 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
1149 var
1150         Selection: TSelection;
1151         AHandle: THandle;
1152 begin
1153         AHandle := GetActiveControlHandle;
1154         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1155         CopyAction.Enabled := (AHandle <> 0)
1156                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1157                                                                                 and (not FWork);
1158 end;
1159
1160 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
1161 begin
1162         PasteAction.Enabled := (GetActiveControlHandle <> 0)
1163                                                                                         and (Clipboard.HasFormat(CF_TEXT))
1164                                                                                         and (not FWork);
1165 end;
1166
1167 procedure TEditorForm.TopActionUpdate(Sender: TObject);
1168 begin
1169         TopAction.Enabled := not FWork;
1170 end;
1171
1172 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
1173 begin
1174         if SageCheckBox.Checked then begin
1175                 if AnsiPos('sage', MailComboBox.Text) = 0 then
1176                         MailComboBox.Text := 'sage' + MailComboBox.Text;
1177         end else begin
1178                 if AnsiPos('sage', MailComboBox.Text) <> 0 then
1179                         MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
1180         end;
1181 end;
1182
1183 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
1184 begin
1185         if AnsiPos('sage', MailComboBox.Text) = 0 then
1186                 SageCheckBox.Checked := False
1187         else
1188                 SageCheckBox.Checked := True;
1189 end;
1190
1191
1192 function TEditorForm.GetSPID(CookieLine: string): string;
1193 var
1194         s: string;
1195         i: Integer;
1196 begin
1197         Result := '';
1198         i := 0;
1199         while True do begin
1200                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1201                 if s = '' then
1202                         Break
1203                 else begin
1204                         if Pos('SPID=', s) = 1 then begin
1205                                 Result := Trim(Copy(s, 6, Length(s)));
1206                                 Break;
1207                         end;
1208                 end;
1209                 inc(i);
1210         end;
1211 end;
1212
1213 function TEditorForm.GetPON(CookieLine: string): string;
1214 var
1215         s: string;
1216         i: Integer;
1217 begin
1218         Result := '';
1219         i := 0;
1220         while True do begin
1221                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1222                 if s = '' then
1223                         Break
1224                 else begin
1225                         if Pos('PON=', s) = 1 then begin
1226                                 Result := Trim(Copy(s, 5, Length(s)));
1227                                 Break;
1228                         end;
1229                 end;
1230                 inc(i);
1231         end;
1232 end;
1233
1234 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1235         AStream: TStream);
1236 var
1237         StringStream: TStringStream;
1238 begin
1239         StringStream := TStringStream.Create('');
1240         try
1241                 StringStream.CopyFrom(AStream, AStream.Size);
1242                 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1243         finally
1244                 StringStream.Free;
1245         end;
1246 end;
1247
1248 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1249         AStream: TStream);
1250 var
1251         StringStream: TStringStream;
1252 begin
1253         StringStream := TStringStream.Create('');
1254         try
1255                 StringStream.CopyFrom(AStream, AStream.Size);
1256                 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1257         finally
1258                 StringStream.Free;
1259         end;
1260 end;
1261
1262 procedure TEditorForm.TransActionExecute(Sender: TObject);
1263 begin
1264         AlphaBlend := TransAction.Checked;
1265         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
1266         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
1267 end;
1268
1269 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1270 begin
1271         TransAction.Enabled := not FWork;
1272 end;
1273 //StatusBar\82ÌPanels[0]\82Ì\95\9d\82ð\89Â\95Ï\81B\8ec\82è\82ð\8cÅ\92è\82É\82·\82é
1274 procedure TEditorForm.StatusBarResize(Sender: TObject);
1275 begin
1276         StatusBar.Panels[0].Width := StatusBar.Width
1277                                                                         - StatusBar.Panels[1].Width - StatusBar.Panels[2].Width;
1278
1279 end;
1280
1281 procedure TEditorForm.Timer1Timer(Sender: TObject);
1282 begin
1283         if FSambaTime = ZERO_DATE then
1284                 StatusBar.Panels[1].Text := '\8f\89\8f\91'
1285         else begin
1286                 FNow := IncMilliSecond(FNow, 500);
1287                 StatusBar.Panels[1].Text := Format('%8.0f\95b\8co\89ß', [SecondSpan(FNow, FSambaTime)]);
1288         end;
1289
1290 end;
1291 //Samba.ini\82Ì\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1292 procedure TEditorForm.ReadSambaTime(const AHost: string);
1293 var
1294         ini :TMemIniFile;
1295         tmp: string;
1296 begin
1297         Timer1.Enabled := false; //\8co\89ß\95b\90\94\95\\8e¦Timer\82ðOff\82É\82·\82é\81i\82±\82ê\82ªON\82Ì\82Æ\82«Samba24\91Î\8dôOn\81j
1298         FNow := Now();   //\8c»\8dÝ\8e\9e\8aÔ\82ð\8eæ\93¾\81iTimer\95\\8e¦\97p\82Å\81ACheck\82·\82é\82Æ\82«\82Í\8dÄ\82ÑNow()\82ð\8cÄ\82Ô\81j
1299         Timer1.Enabled := true; //\8co\89ß\95b\90\94\95\\8e¦Timer\82ðOn\82É\82·\82é\81i\82±\82ê\82ªON\82Ì\82Æ\82«Samba24\91Î\8dôOn\81j
1300         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1301         try
1302                  //\95\8e\9a\97ñ\82Å\93Ç\82Ý\8eæ\82Á\82Ä\81A\95Ï\8a·\8aÖ\90\94\82ÅTDateTime\82Ö
1303                  tmp := ini.ReadString('Send', AHost, DateTimeToStr(ZERO_DATE));
1304                  FSambaTime := ConvertDateTimeString(tmp);
1305         finally
1306                 ini.Free;
1307         end;
1308 end;
1309 //Samba.ini\82É\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\8f\91\82«\8d\9e\82Þ
1310 procedure TEditorForm.WriteSambaTime(const AHost: string; ATime: TDateTime);
1311 var
1312         ini :TMemIniFile;
1313 begin
1314         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1315         try
1316                 ini.WriteDateTime('Send', AHost, ATime);
1317                 ini.UpdateFile;
1318         finally
1319                 ini.Free;
1320         end;
1321 end;
1322 //\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82Æ\8c»\8dÝ\8e\9e\82ð\94ä\8ar\82·\82é\81i\90^\81F\8bK\92è\92l\88È\8fã\81@\8bU\81F\8bK\92è\92l\96¢\96\9e\81j
1323 function TEditorForm.CheckSambaTime(const AHost: string; ATime: TDateTime): Boolean;
1324 var
1325         pastsec: double;
1326         SettingTime: Integer;
1327 begin
1328         SettingTime := ReadSettingTime(AHost);
1329         ReadSambaTime(AHost);
1330         pastsec := SecondSpan(ATime, FSambaTime);
1331         if pastsec > SettingTime then
1332                 Result := true
1333         else
1334                 Result := false;
1335 end;
1336 //AHost\81i\8eI\96¼\81j\82ÌSamba\82Ì\8bK\92è\92l\82ð\93Ç\82Ý\8d\9e\82Þ
1337 function TEditorForm.ReadSettingTime(const AHost: string): Integer;
1338 var
1339         ini :TMemIniFile;
1340 begin
1341         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1342         try
1343                 Result := ini.ReadInteger('Setting', AHost, 0);
1344                 //\8bK\92è\92l\82ª\82O\82Ì\82Æ\82«\81A\82à\82µ\82­\82Í\90Ý\92è\82³\82ê\82Ä\82¢\82È\82¢\82Æ\82«\82Í\81A\83t\83@\83C\83\8b\82É\8f\91\82«\82½\82·\81B
1345                 if Result = 0 then begin
1346                         ini.WriteInteger('Setting', AHost, 0);
1347                         ini.UpdateFile;
1348                 end;
1349         finally
1350                 ini.Free;
1351         end;
1352 end;
1353 //Form\82ªActive\82É\82È\82Á\82½\82ç\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1354 procedure TEditorForm.FormActivate(Sender: TObject);
1355 begin
1356         if ( Timer1.Enabled ) and ( FThreadItem <> nil )then
1357                 ReadSambaTime(FHost);
1358 end;
1359 //Samba24\91Î\8dô\82ð\8eg\82¤\82©\82Ç\82¤\82©\8c\88\82ß\82é\8aÖ\90\94
1360 //ReadSambaTime \82ð\8cÄ\82Ñ\8fo\82·\82ÆTimer\82ªOn\82É\82È\82é
1361 procedure TEditorForm.SetSamba24(AURL: string);
1362 var
1363         Protocol, Host, Path, Document, Port, Bookmark : string;
1364 begin
1365         //Samba24\91Î\8dô\82ð\82µ\82È\82¢\82È\82ç\8fI\97¹
1366         if not GikoSys.Setting.UseSamba then
1367                 Exit;
1368         //Host\82ÌURL\82É'.2ch.'\82©'.bbspink.'\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82½\82çSamba24\91Î\8dô\82ð\82·\82é
1369         GikoSys.ParseURI( AURL, Protocol,Host, Path, Document, Port, Bookmark );
1370         if GikoSys.Is2chHost(Host) then begin
1371                 Host := Copy(Host, 1, AnsiPos('.', Host) - 1);
1372                 FHost := Host;   //FHost=\8eI\96¼
1373                 ReadSambaTime(FHost); //\88È\91O\82Ì\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1374                 //StatusBar\82É\82±\82Ì\8eI\82Ì\8bK\92è\92l\82ð\95\\8e¦\82·\82é
1375                 StatusBar.Panels[2].Text := 'Samba24\8bK\92è\92l' + IntToStr(ReadSettingTime(FHost));
1376         end;
1377 end;
1378 procedure TEditorForm.FormCloseQuery(Sender: TObject;
1379   var CanClose: Boolean);
1380 begin
1381         CanClose := not FWork;
1382 end;
1383
1384 function TEditorForm.GetOEIndentChar : string;
1385 var
1386         regKey                  : TRegistry;
1387         Identities      : string;
1388         IndentChar      : DWORD;
1389 const
1390         DEFAULT_CHAR    = '> ';
1391         OE_MAIL_PATH    = '\Software\Microsoft\Outlook Express\5.0\Mail';
1392         INDENT_CHAR             = 'Indent Char';
1393 begin
1394
1395         Result  := DEFAULT_CHAR;
1396         regKey  := TRegistry.Create;
1397         try
1398                 try
1399                         regKey.RootKey  := HKEY_CURRENT_USER;
1400                         if not regKey.OpenKey( 'Identities', False ) then
1401                                 Exit;
1402                         Identities                      := regKey.ReadString( 'Default User ID' );
1403                         if Identities = '' then
1404                                 Exit;
1405                         if not regKey.OpenKey( Identities + OE_MAIL_PATH, False ) then
1406                                 Exit;
1407                         IndentChar := regKey.ReadInteger( INDENT_CHAR );
1408                         Result := Char( IndentChar ) + ' ';
1409                 except
1410                 end;
1411         finally
1412                 regKey.Free;
1413         end;
1414
1415 end;
1416
1417 procedure TEditorForm.QuotePasteActionExecute(Sender: TObject);
1418 var
1419         s                       : TStringList;
1420         i                       : Integer;
1421         quote   : string;
1422 begin
1423
1424         quote   := GetOEIndentChar;
1425         s                       := TStringList.Create;
1426         try
1427                 s.Text  := Clipboard.AsText;
1428
1429                 for i := s.Count - 1 downto 0 do
1430                         s[ i ]  := quote + s[ i ];
1431
1432                 BodyEdit.SelText        := s.Text;
1433         finally
1434                 s.Free;
1435         end;
1436
1437 end;
1438
1439 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
1440 begin
1441         GikoSys.Setting.SpaceToNBSP := SpaceToNBSPAction.Checked;
1442         if EditorPage.ActivePage = PreviewTab then
1443                 Preview;
1444 end;
1445
1446 procedure TEditorForm.AmpToCharRefActionExecute(Sender: TObject);
1447 begin
1448         GikoSys.Setting.AmpToCharRef := AmpToCharRefAction.Checked;
1449         if EditorPage.ActivePage = PreviewTab then
1450                 Preview;
1451 end;
1452
1453 end.
1454