fcdemorichedit.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit fcDemoRichEdit;
  2. {
  3. //
  4. // Components : TfcDemoRichEdit
  5. //
  6. // Copyright (c) 1999 by Woll2Woll Software
  7. //
  8. }
  9. interface
  10. {$i fcIfDef.pas}
  11. uses
  12.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   StdCtrls, ComCtrls;
  14. type
  15.   TfcDemoRichEdit = class(TCustomRichEdit)
  16.   private
  17.      ReloadStream: TStream;
  18.      UseReloadStream: boolean;
  19.   protected
  20.     procedure GetLines(Stream: TStream); virtual;
  21.     procedure SetLines(Stream: TStream); virtual;
  22.     procedure DefineProperties(Filer: TFiler); override;
  23.     procedure CreateWnd; override;
  24.     procedure DestroyWnd; override;
  25.   public
  26.     destructor Destroy; override;
  27.   published
  28.     property Align;
  29.     property Alignment;
  30.     property BorderStyle;
  31.     property Color;
  32.     property Ctl3D;
  33.     property DragCursor;
  34.     property DragMode;
  35.     property Enabled;
  36.     property Font;
  37.     property HideSelection;
  38.     property HideScrollBars;
  39.     property ImeMode;
  40.     property ImeName;
  41. //    property Lines;
  42.     property MaxLength;
  43.     property ParentColor;
  44.     property ParentCtl3D;
  45.     property ParentFont;
  46.     property ParentShowHint;
  47.     property PlainText;
  48.     property PopupMenu;
  49.     property ReadOnly;
  50.     property ScrollBars;
  51.     property ShowHint;
  52.     property TabOrder;
  53.     property TabStop default True;
  54.     property Visible;
  55.     property WantTabs;
  56.     property WantReturns;
  57.     property WordWrap;
  58.     property OnChange;
  59.     property OnDragDrop;
  60.     property OnDragOver;
  61.     property OnEndDrag;
  62.     property OnEnter;
  63.     property OnExit;
  64.     property OnKeyDown;
  65.     property OnKeyPress;
  66.     property OnKeyUp;
  67.     property OnMouseDown;
  68.     property OnMouseMove;
  69.     property OnMouseUp;
  70.     property OnResizeRequest;
  71.     property OnSelectionChange;
  72.     property OnStartDrag;
  73.     property OnProtectChange;
  74.     property OnSaveClipboard;
  75.   end;
  76. implementation
  77. procedure TfcDemoRichEdit.DefineProperties(Filer: TFiler);
  78. begin
  79.   inherited;
  80.   Filer.DefineBinaryProperty('RichEditLines', GetLines, SetLines, True);
  81. end;
  82. procedure TfcDemoRichEdit.GetLines(Stream: TStream);
  83. begin
  84.   Lines.LoadFromStream(Stream);
  85. end;
  86. procedure TfcDemoRichEdit.SetLines(Stream: TStream);
  87. begin
  88.   Lines.SaveToStream(Stream);
  89. end;
  90. procedure TfcDemoRichEdit.CreateWnd;
  91. begin
  92.   inherited CreateWnd;
  93.   { Stream in after setting ole callback routines }
  94.   if (useReloadStream) and (ReloadStream<>nil) then begin
  95.      ReloadStream.position:= 0;
  96.      Lines.LoadFromStream(ReloadStream);
  97.   end;
  98. end;
  99. procedure TfcDemoRichEdit.DestroyWnd;
  100. begin
  101.    useReloadStream:= False;
  102.    if not (csDestroying in ComponentState) then
  103.    begin
  104.       if ReloadStream=Nil then ReloadStream:= TMemoryStream.create
  105.       else ReloadStream.position:= 0;
  106.       Lines.SaveToStream(ReloadStream);
  107.       useReloadStream:= True;
  108.    end;
  109.    inherited DestroyWnd;
  110. end;
  111. destructor TfcDemoRichEdit.Destroy;
  112. begin
  113.    ReloadStream.Free;
  114.    inherited Destroy;
  115. end;
  116. end.