{ *************************************************************************** }
{                                                                             }
{ EControl Localizer                                                          }
{                                                                             }
{ Copyright (c) 2004 - 2006 EControl Ltd., Zaharov Michael                    }
{     www.econtrol.ru                                                         }
{     support@econtrol.ru                                                     }
{                                                                             }
{ *************************************************************************** }
unit ecEditText;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdActns, ActnList, StdCtrls, ExtCtrls, ImgList, ComCtrls,
  ToolWin;

type
  TTextEditDlg = class(TForm)
    ToolBar1: TToolBar;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton11: TToolButton;
    ImageList1: TImageList;
    ActionList1: TActionList;
    Panel1: TPanel;
    Button2: TButton;
    Button1: TButton;
    Memo1: TMemo;
    EditCut1: TEditCut;
    EditCopy1: TEditCopy;
    EditPaste1: TEditPaste;
    EditUndo1: TEditUndo;
    EditDelete1: TEditDelete;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function EditTextDlg(var AText: string; ACharset: TFontCharset = DEFAULT_CHARSET; Flags: Cardinal = 0): Boolean;

implementation

{$R *.dfm}

function EditTextDlg(var AText: string; ACharset: TFontCharset; Flags: Cardinal): Boolean;
begin
  with TTextEditDlg.Create(nil) do
    try
      Memo1.Font.Charset := ACharset;
      Memo1.Lines.Text := AText;
      Memo1.Modified := False;
      Result := ShowModal = mrOk;
      if Result then
        AText := Memo1.Lines.Text;
    finally
      Free;
    end;
end;

procedure TTextEditDlg.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  if (ModalResult = mrCancel) and Memo1.Modified then
    case MessageDlg('Do you want to save changes?', mtConfirmation, mbYesNoCancel, 0) of
      mrYes:    ModalResult := mrOk;
      mrCancel: CanClose := False;
    end;
end;

end.
