Solved

Porting components to Delphi 2009...

Posted on 2009-05-11
3
1,817 Views
Last Modified: 2013-11-23
Hello,

I have recently made the jump from Delphi 2005, and would like to port my applications to Delphi 2009. Unfortunately Dream Components have shut their doors to component development and support although you can still buy them. I think they got as far as supporting Delphi 7. I use some of their components which are in my opinion irreplaceable; I have the source so I started porting the components, although porting might be a flattering description of what I am doing.  I have no interest in any earlier versions of Delphi.

See attached original unhacked code...

I have got stuck fiddling about here...

  TFormDesigner = IDesigner;
  IFormDesigner=IDesigner;

  TTypeToString = function(Designer: TFormDesigner; TypeCode: integer): string;

  {$IFDEF ver200}
  IDCFDesigner = interface(IFormDesigner)
    ['{37CFFCE1-1BB2-11D2-B4E3-0000E8DC209E}']
    function GetOwnerControl: TComponent;
    procedure SetOwnerControl(C: TComponent);

    function GetLimitControl: TWinControl;
    procedure SetLimitControl(val: TWinControl);
    function CanBeSelected(Instance: TPersistent): boolean;

    function AllowEdit(Instance: TComponent; const PropName: string): boolean;
    function AllowEditList(Comps: TList; const PropName: string): boolean;

    function AllowPropShow(Instance: TComponent; const PropName: string): boolean;
    function AllowPropShowList(Comps: TList; const PropName: string): boolean;

    function IsSelected(Instance : TPersistent) : boolean;

    procedure DeSelectComponent(Instance : TPersistent);

    property LimitControl: TWinControl read GetLimitControl write SetLimitControl;
    property OwnerControl: TComponent read GetOwnerControl write SetOwnerControl;

  end;
  {$ENDIF}


//  TFDesigner = class(TInterfacedObject, IDesigner,IDesignerHook)
//  TFDesigner = class(TInterfacedObject, IDCDesignerFormAccess, IDCFDesigner, TFormDesigner, IDesignerHook)
  TFDesigner = class(TInterfacedObject, IDesignerHook)
... etc.,

You can see I have been busy experimenting. That compiles OK until the compiler reaches the method  IsDesignMsg...
[DCC Error] dcGen.pas(460): E2137 Method 'IsDesignMsg' not found in base class

As if the function prototyped in Forms::IDesignerHook is not visible.

Quoting from the on-line help section 'Interfaces and Interface Implementations'... An interface is actually a contract that consists of a group of related function prototypes whose usage is defined but whose implementation is not.

Hence the presence of prototypes in the interface declaration must be fully satisfied by declarations in the class, which in the case of TFDesigner  they are. But it looks like I have it wrong :-)

Any help will be gratefully received.

Best regards, Paul.
{$IFDEF D6}

  IFormDesigner=IDesigner;

  {$ENDIF}
 

  {$IFDEF D4}

  TFormDesigner = IFormDesigner;

  {$ENDIF}
 

  TTypeToString = function(Designer: TFormDesigner; TypeCode: integer): string;
 

  {$IFDEF D4}

  IDCFDesigner = interface(IFormDesigner)

    ['{37CFFCE1-1BB2-11D2-B4E3-0000E8DC209E}']

    function GetOwnerControl: TComponent;

    procedure SetOwnerControl(C: TComponent);
 

    function GetLimitControl: TWinControl;

    procedure SetLimitControl(val: TWinControl);

    function CanBeSelected(Instance: TPersistent): boolean;
 

    function AllowEdit(Instance: TComponent; const PropName: string): boolean;

    function AllowEditList(Comps: TList; const PropName: string): boolean;
 

    function AllowPropShow(Instance: TComponent; const PropName: string): boolean;

    function AllowPropShowList(Comps: TList; const PropName: string): boolean;
 

    function IsSelected(Instance : TPersistent) : boolean;
 

    procedure DeSelectComponent(Instance : TPersistent);
 

    property LimitControl: TWinControl read GetLimitControl write SetLimitControl;

    property OwnerControl: TComponent read GetOwnerControl write SetOwnerControl;
 

  end;

  {$ENDIF}
 

  TFDesigner = class({$IFDEF D4}TInterfacedObject, IDCDesignerFormAccess, IDCFDesigner, {$ENDIF}TFormDesigner{$IFDEF D6},IDesignerHook{$ENDIF})

  private

    fOwnerControl: TComponent;

    fLimitWinControl: TWinControl;

    {$IFDEF D4}

    fform: TCustomForm;

    {$ENDIF}

    fSelection: TList;

    function GetSelection: TList;

    procedure ValidateSelection;

  protected

    procedure SelectionChanged;

    function GetOwnerControl: TComponent; virtual;

    procedure SetOwnerControl(C: TComponent);

    function GetLimitControl: TWinControl;

    procedure SetLimitControl(val: TWinControl);
 

  public

    function InUpdate : boolean; virtual;

    constructor Create;

    destructor Destroy; override;

    function CanBeSelected(Instance: TPersistent): boolean; virtual;

    function AllowEdit(Instance: TComponent; const PropName: string): boolean; virtual;

    function AllowEditList(Comps: TList; const PropName: string): boolean;
 

    function AllowPropShow(Instance: TComponent; const PropName: string): boolean; virtual;

    function AllowPropShowList(Comps: TList; const PropName: string): boolean;
 

    function IsDesignMsg(Sender: TControl; var Message: TMessage): Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure Modified;

    {$IFNDEF D4}override;

    {$ENDIF}

    {$IFNDEF D4}

    procedure Notification(AComponent: TComponent; Operation: TOperation); override;

    {$ELSE}

    procedure Notification(AnObject: TPersistent; Operation: TOperation);

    {$ENDIF}

    procedure PaintGrid;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure ValidateRename(AComponent: TComponent; const CurName, NewName: string);

    {$IFNDEF D4}override;

    {$ENDIF}

    function CreateMethod(const Name: string; TypeData: PTypeData): TMethod;

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetMethodName(const Method: TMethod): string;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure GetMethods(TypeData: PTypeData; Proc: TGetStrProc);

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetPrivateDirectory: string;

    {$IFNDEF D4}override;

    {$ENDIF}

    {$IFNDEF D4}

    procedure GetSelections(List: TComponentList); override;

    procedure SetSelections(List: TComponentList); override;

    {$ELSE}

    procedure GetSelections(const List: IDesignerSelections);

    procedure SetSelections(const List: IDesignerSelections);

    {$ENDIF}

    function MethodExists(const Name: string): Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure RenameMethod(const CurName, NewName: string);

    {$IFNDEF D4}override;

    {$ENDIF}

    {$IFDEF D3}

    procedure SelectComponent(Instance: TPersistent);

    {$IFNDEF D4}override;

    {$ENDIF}

    {$ELSE}

    procedure SelectComponent(Component: TComponent); override;

    {$ENDIF}

    procedure ShowMethod(const Name: string);

    {$IFNDEF D4}override;

    {$ENDIF}

    function UniqueName(const BaseName: string): string;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure GetComponentNames(TypeData: PTypeData; Proc: TGetStrProc);

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetComponent(const Name: string): TComponent;

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetComponentName(Component: TComponent): string;

    {$IFNDEF D4}override;

    {$ENDIF}

    function MethodFromAncestor(const Method: TMethod): Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    function CreateComponent(ComponentClass: TComponentClass; Parent: TComponent;

      Left, Top, Width, Height: Integer): TComponent;

    {$IFDEF D4}virtual;

    {$ELSE}override;

    {$ENDIF}

    function IsComponentLinkable(Component: TComponent): Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure MakeComponentLinkable(Component: TComponent);

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetRoot: TComponent;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure Revert(Instance: TPersistent; PropInfo: PPropInfo);

    {$IFNDEF D4}override;

    {$ENDIF}

    {$IFDEF D3}

    function GetObject(const Name: string): TPersistent;

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetObjectName(Instance: TPersistent): string;

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure GetObjectNames(TypeData: PTypeData; Proc: TGetStrProc);

    {$IFNDEF D4}override;

    {$ENDIF}

    function GetIsDormant: Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    function HasInterface: Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    function HasInterfaceMember(const Name: string): Boolean;

    {$IFNDEF D4}override;

    {$ENDIF}

    {$IFNDEF CPB3}

    procedure AddInterfaceMember(const MemberText: string); override;

    {$ELSE}

    procedure AddToInterface(InvKind: Integer; const Name: string; VT: Word;

      const TypeInfo: string);

    {$IFNDEF D4}override;

    {$ENDIF}

    procedure GetProjectModules(Proc: TGetModuleProc);

    {$IFNDEF D4}override;

    {$ENDIF}

    {$ENDIF}

    {$ENDIF}

    {$IFDEF D4}

    function GetCustomForm: TCustomForm;

    procedure SetCustomForm(Value: TCustomForm);

    function GetIsControl: Boolean;

    procedure SetIsControl(Value: Boolean);
 

    function GetAncestorDesigner: IFormDesigner;
 

    function IsSourceReadOnly: Boolean;
 

    property Form: TCustomForm read GetCustomForm write SetCustomForm;

    {$ENDIF}
 

    {$IFDEF D5}

    function GetContainerWindow: TWinControl;

    procedure SetContainerWindow(const NewContainer: TWinControl);

    function GetScrollRanges(const ScrollPosition: TPoint): TPoint;
 

    {$IFDEF D6}

    procedure Edit(const Component: TComponent);

    {$ELSE}

    procedure Edit(const Component: IComponent);

    {$ENDIF}
 

    {$IFNDEF D6}

    function BuildLocalMenu(Base: TPopupMenu; Filter: TLocalMenuFilters): TPopupMenu;

    {$ENDIF}
 

    procedure ChainCall(const MethodName, InstanceName, InstanceMethod: string;

      TypeData: PTypeData);
 

    function CanPaste: Boolean;

    procedure CopySelection; virtual;

    procedure CutSelection; virtual;

    procedure PasteSelection; virtual;
 

    {$IFDEF D6}

    procedure DeleteSelection(ADoAll: Boolean = False);virtual;

    {$ELSE}

    procedure DeleteSelection; virtual;

    {$ENDIF}
 

    procedure ClearSelection; virtual;
 

    procedure NoSelection;

    procedure ModuleFileNames(var ImplFileName, IntfFileName, FormFileName: string);

    function GetRootClassName: string;

    {$ENDIF}
 

    {$IFDEF D6}

    function IsComponentHidden(Component: TComponent): Boolean;

    {

    procedure PaintComponentIcon(ComponentClass: TComponentClass;

      ACanvas: TCanvas; X, Y: Integer; AStyle: TPaintItemStyle);

    }

    {$ENDIF}
 

    function IsSelected(Instance : TPersistent) : boolean;
 

    procedure DeselectComponent(Instance : TPersistent);
 

    {$IFDEF D6}

    function GetBaseRegKey: string;

    function GetIDEOptions: TCustomIniFile;

    function GetPathAndBaseExeName: string;

    procedure Activate;

    function CreateCurrentComponent(Parent: TComponent; const Rect: TRect): TComponent;

    function GetShiftState: TShiftState;

    procedure ModalEdit(EditKey: Char; const ReturnWindow: IActivatable);

    procedure SelectItemName(const PropertyName: string);

    procedure Resurrect;

    {$ENDIF}

    {$IFDEF D7}

    function GetActiveClassGroup: TPersistentClass;

    function FindRootAncestor(const AClassName: string): TComponent;

    {$ENDIF}

    property LimitControl: TWinControl read GetLimitControl write SetLimitControl;

    property OwnerControl: TComponent read GetOwnerControl write SetOwnerControl;

    property Selection: TList read GetSelection;

  end;

Open in new window

0
Comment
Question by:paul_ingram
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
developmentguru earned 250 total points
ID: 24356297
 The error message you are getting is not due to an interface you are using.  According to the Embarcadero web site the error occurs when you try to override a method that does not exist in the base class.  I would be careful to not the line the error occurs on.  It seems obvious that you did not give us the entire file or I would have looked it up for you.  Here is the link.

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/delphimessagespart_xml.html

One thing I noticed is that there is a great deal of conditional defines in the code.  In situations in the past where I have had to try to come up with an updated version on my own, I found that experimenting by setting conditional defines (starting with newer ones and working backwards) has made things easier at times.

Let me know if you need more.
0
 

Author Comment

by:paul_ingram
ID: 24356797
Hi developmentguru,

Useful page, I am not yet used to Embarcadero's resources. A couple of items:-
1/ for some obscure reason (age?) I lied - I upgraded from Delphi 5
2/ I felt uncomfortable uploading their code in it's entirety as it's not mine to share.

E2137: Method '%s' not found in base class (Delphi) : You have applied the 'override' directive to a method, but the compiler is unable to find a procedure of the same name in the base class.

The mist is clearing. I think considering that  'an interface is actually a contract that consists of a group of related function prototypes whose usage is defined but whose implementation is not' means that the override directive is not relevant.

It looks from previous versions it must have been relevant. However commenting out the override removes the compilation error.

So your advice helped me fix it! Thanks!

I am sure I'll be back - I am not finding this easy.

Best regards, Paul.
0
 

Author Closing Comment

by:paul_ingram
ID: 31580130
Thanks for taking the trouble to look at a question with incomplete supporting information. You pointed me in the right direction.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now