Thema: Delphi Probleme mit TRichEdit

Einzelnen Beitrag anzeigen

xaromz

Registriert seit: 18. Mär 2005
1.682 Beiträge
 
Delphi 2006 Enterprise
 
#10

Re: Probleme mit TRichEdit

  Alt 14. Jan 2006, 20:53
Hallo,

versuch doch mal folgendes:
Delphi-Quellcode:
unit gsticky;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls;

type
  Tsticky = class(TCustomControl)
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Paint; override;
  private
    FirstDraw: boolean;
    stickynote: TRichEdit;
    procedure SetParent(AParent: TWinControl); override; // <--------
  public
  end;

constructor Tsticky.Create(AOwner: TComponent);
begin
inherited Create(Aowner);
imageresDLL := LoadLibrary(PChar('imageres.dll'));
  stickynote := TRichEdit.Create(self);
  stickynote.Parent := Self;
end;

procedure Tsticky.SetParent(AParent: TWinControl);
begin
  inherited SetParent(AParent);

  if (AParent = nil) then
    Exit;

  stickynote.Enabled := true;
  stickynote.Left := 60;
  stickynote.Top := 10;
  stickynote.Width := 80;
  stickynote.Height := 45;
  stickynote.Color := clLime;
  stickynote.BorderStyle := BsNone;
end;
Damit setzt Du die Eigenschaften erst, wenn Deine Komponente TSticky wirklich ein Parent-Control hat.

Gruß
xaromz
// Edit: Fehler korrigiert
  Mit Zitat antworten Zitat