Recent

Author Topic: Event Assignment not working  (Read 5273 times)

slukacs

  • New Member
  • *
  • Posts: 11
Event Assignment not working
« on: February 14, 2005, 03:58:58 pm »
hello,

i am trying to create an analog of TPageProducer.  when i try to compile i get the error:

Error: Wrong number of parameter specified.

but that makes no sense because i declare the event (THTMLTagEvent ) and its assignment as:

(there is more code here because i don't want anything to be missing.)
>>>
interface

uses
  Classes, SysUtils;

type
  THTMLTag = (tgCustom,tgLink,tgImage,tgTable,tgImageMap,tgObject,tgEmbed);

  THTMLTagEvent = procedure(s : TObject; aHTMLTag : THTMLTag; const aTagString : string; aTagParams : TStrings; var ReplaceText : string) of object;

  TCustomPageProducer = class(TComponent)
  private
    zFilename : TFileName;
    zDocument : TStrings;
    zOnHTMLTag : THTMLTagEvent;
    procedure SetFilename(const v : string);
    procedure SetDocument(const v : TStrings);
    function GetContent : string;
    function GetText : string;
    procedure SetText(const v : string);
  protected
    function ProcessContent : string; virtual;
    property OnHTMLTag : THTMLTagEvent read zOnHTMLTag write zOnHTMLTag;
  public
    constructor Create(o : TComponent); override;
    destructor Destroy; override;
    property Content : string read GetContent;
    property Text : string read GetText write SetText;
    property Document : TStrings read zDocument write SetDocument;
    property Filename : TFileName read zFilename write SetFilename;
  published
    end;
   
  TPageProducer = class(TCustomPageProducer)
  published
    property OnHTMLTag;
    property Content;
    property Text;
    property Document;
    property Filename;
    end;
<<<

and then in my main module, i use the TPageProducer as
>>>
constructor TLocalObj.Create(o : TComponent);
begin
inherited Create(o);
ppg := TPageProducer.Create(self);
with ppg do begin
  with Document do begin
    Clear;
    Add('<#HEAD>');
        Add('<#TOP>');
        Add('<#BODY>');
        Add('<#BOTTOM>');
        end;
  OnHTMLTag := ppgTag;
  end;
pps := TPageProducer.Create(self);
pps.OnHTMLTag := ppsTag;
end;
<<<
where TLocalObj is declared locally in the module and its type is mapped under the implementation section.  TLocalObj has the declaration of

procedure ppgTag(s : TObject; aTag : THTMLTag; const aTagString : string; aTagParams : TStrings; var ReplaceText : string);

procedure ppsTag(Sender : TObject; aTag : THTMLTag; const TagString : string; TagParams : TStrings; var ReplaceText : string);

where both procedure have the exact number and type of parameters as the declaring in the TPageProducer unit.  now i have developed many components in delphi and i can not figure out what is going with this one.  please help.

lucas

slukacs

  • New Member
  • *
  • Posts: 11
Event Assignment not working
« Reply #1 on: February 27, 2005, 08:06:39 am »
i figured it out.  i didn't have the @ symbol when i assigned the event to the procedure or

OnHTMLTag := @ppgTag;

so i am a bit dumb.

lucas

 

TinyPortal © 2005-2018