Einzelnen Beitrag anzeigen

Benutzerbild von MaBuSE
MaBuSE

Registriert seit: 23. Sep 2002
Ort: Frankfurt am Main (in der Nähe)
1.837 Beiträge
 
Delphi 10 Seattle Enterprise
 
#42

Re: Lösung: Das leidige Problem mit der DsgnIntf bzw. Proxy.

  Alt 11. Okt 2006, 06:39
Zitat von mandoki:
Delphi-Quellcode:
unit ALSTDlg;

interface

uses
  {$IFDEF WIN32}Windows,{$ELSE}WinTypes, WinProcs,{$ENDIF}
  Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, INIFiles{$IFDEF WIN32}, Registry{$ENDIF};

type
  TALSShowPos = (posScreenCenter, posFormCenter);
  TTipLocation = (locEmbeded, {$IFDEF WIN32}locRegistry,{$ENDIF} locINIFile);
  TRegRoot = (CURRENT_USER,LOCAL_MACHINE,CURRENT_CONFIG);

  TALSTipDlg = class(TComponent)
  private
    FAbout : TAbout;
    FDlgCaption : string;
    FTipTitle : string;
    FTips : TStrings;
    FTipTitleFont : TFont;
    FTipFont : TFont;
    FRegRoot : TRegRoot;
    FRegKey : string;
    FINIFile : string;
    FINISection : string;
    FTipsLocation : TTipLocation;
    FPanelColor : TColor;
    FCRLFSubst : string;
    FRandomTips : boolean;
    FShowAtStartup: boolean;
    FPosition : TALSShowPos;
  protected
    {$IFDEF WIN32}
    function ReadFromRegistry : boolean;
    {$ENDIF}
    function ReadFromINIFile : boolean;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure SetTipValues(Value: TStrings);
    procedure SetTitleFont(Value: TFont);
    procedure SetTipFont(Value: TFont);
    function Execute : boolean;
  published
    property About: TAbout read FAbout write FAbout;
    property DlgCaption: string read FDlgCaption write FDlgCaption;
    property TipTitle: string read FTipTitle write FTipTitle;
    property Tips: TStrings read FTips write SetTipValues;
    property TipTitleFont: TFont read FTipTitleFont write SetTitleFont;
    property TipFont: TFont read FTipFont write SetTipFont;
    {$IFDEF WIN32}
    property RegistryRoot: TRegRoot read FRegRoot write FRegRoot default CURRENT_USER;
    property RegistryKey: string read FRegKey write FRegKey;
    {$ENDIF}
    property INIFile: string read FINIFile write FINIFile;
    property INISection: string read FINISection write FINISection;
    property TipsLocation: TTipLocation read FTipsLocation write FTipsLocation default locEmbeded;
    property PanelColor: TColor read FPanelColor write FPanelColor default
                         {$IFDEF VER120}clInfoBk {$ELSE} TColor($00E1FFFF){$ENDIF};
    property CRLFSubstitute : string read FCRLFSubst write FCRLFSubst;
    property RandomTips: boolean read FRandomTips write FRandomTips default False;
    property ShowAtStartup: boolean read FShowAtStartup write FShowAtStartup default True;
    property Position: TALSShowPos read FPosition write FPosition;
  end;

procedure Register;

implementation

uses TipFrm;
{$IFDEF WIN32}
  {$R ALSTDLG.R32}
{$ELSE}
  {$R ALSTDLG.R16}
{$ENDIF}

procedure Register;
begin
  RegisterComponents('Samples', [TALSTipDlg]);
end;
und
Delphi-Quellcode:
unit ALSTDlg_Design;

interface

uses
  ALSTDlg, SysUtils, Classes, Forms, DesignIntf, DesignEditors;

type
  TTipDialogEditor = class(TDefaultEditor)
  public
    procedure ExecuteVerb(Index : Integer); override;
    function GetVerb(Index : Integer): string; override;
    function GetVerbCount : Integer; override;
    procedure Edit; override;
  end;

  TAbout = class(TPropertyEditor)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
  end;

  TFileNameProperty = class (TStringProperty)
  public
      function getattributes: TPropertyattributes; override;
      procedure Edit; override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponentEditor(TALSTipDlg, TTipDialogEditor);
  RegisterPropertyEditor(TypeInfo(TAbout), TALSTipDlg, 'ABOUT', TAbout);
  RegisterPropertyEditor(Typeinfo(string), TALSTipDlg, 'INIFile', TFileNameProperty);
end;
Welche Teile müssten den nun in den dsgn teil ausgelagert werden?
Ich habe Dir oben mal Deinen Quellcode geändert
Wie Bernhard schon geschrieben hat, kommt alles was nichts mit der Laufzeit zu tun hat, sondern nur in der IDE verwendet wird in eine eigene Unit. In der Unit bindest Du natürlich die unit ALSTDlg ein (uses).
Wenn Du dir nicht sicher bist, dann entferne doch einfach mal die DesignIntf und DesignEditors aus der uses Zeile und versuch zu kompilieren. Er wird über alle Property Editoren und sonstiges stolpern. Diese Dinge kannst Du dann einfach in die andere Unit verlagern
In der Unit der eigentlichen Komponente darf DesignIntf und DesignEditors dann eh nicht mehr enthalten sein.
Du bist also fertig, wenn die Komponente sich ohne diese ToolsAPI (OTA) Units kompilieren lässt.
(°¿°) MaBuSE - proud to be a DP member
(°¿°) MaBuSE - proud to be a "Rüsselmops" ;-)
  Mit Zitat antworten Zitat