Home RAP

Rap event won't fire

edited October 2002 in RAP
Hi there, I created a component that has an OnDrawColumn event. The event
can be use in RAP. The parameters are correct but the event isn't called in
Rap. I've put a simple showmessage in it but it won't display.

Here's a bit of code of the component.

////////////////////////////////////////////////////////////////////////////
///////////////////////
const
ciDrawColumn = 101;


TraTWGridLinesRTTI = class(TraTppComponentRTTI)
public
class function GetParams(const aMethodName: String): TraParamList;
override;
class procedure GetPropList(aClass: TClass; aPropList: TraPropList);
override;
class function GetPropRec(aClass: TClass; const aPropName: String;
var aPropRec: TraPropRec): Boolean; override;
class function GetPropValue(aObject: TObject; const aPropName:
String; var aValue): Boolean; override;
class function RefClass: TClass; override;
class function SetPropValue(aObject: TObject; const aPropName:
String; var aValue): Boolean; override;
end;


class function TraTWGridLinesRTTI.GetParams(
const aMethodName: String): TraParamList;
begin
if (CompareText(aMethodName, 'OnDrawColumn') = 0) then
begin
Result := TraParamList.Create;
Result.AddParam('ColLeft', daInteger, nil, '', True, False);
Result.AddParam('ColTop', daInteger, nil, '', True, False);
Result.AddParam('ColWidth', daInteger, nil, '', True, False);
Result.AddParam('ColHeight', daInteger, nil, '', True, False);
end
else
Result := inherited GetParams(aMethodName);
end;

class procedure TraTWGridLinesRTTI.GetPropList(aClass: TClass;
aPropList: TraPropList);
begin
inherited GetPropList(aClass, aPropList);
end;

class function TraTWGridLinesRTTI.GetPropRec(aClass: TClass;
const aPropName: String; var aPropRec: TraPropRec): Boolean;
begin
Result := True;
if (CompareText(aPropName, 'OnDrawColumn') = 0) then
EventToRec(aPropName, ciDrawColumn, True, aPropRec)
else
Result := inherited GetPropRec(aClass, aPropName, aPropRec);
end;

class function TraTWGridLinesRTTI.GetPropValue(aObject: TObject;
const aPropName: String; var aValue): Boolean;
begin
Result := inherited GetPropValue(aObject, aPropName, aValue);
end;

class function TraTWGridLinesRTTI.RefClass: TClass;
begin
Result := TppTWGridLines;
end;

class function TraTWGridLinesRTTI.SetPropValue(aObject: TObject;
const aPropName: String; var aValue): Boolean;
begin
Result := inherited SetPropValue(aObject, aPropName, aValue);
end;

here's how I call the event in the component

lParams := TraTWGridLinesRTTI.GetParams('OnDrawColumn');
lParams.CreateValuePointer(0, colleft);
lParams.CreateValuePointer(1, coltop);
lParams.CreateValuePointer(2, colwidth);
lParams.CreateValuePointer(3, colheight);

SendEventNotify(Self, ciDrawColumn, lParams);

lParams.Free;
////////////////////////////////////////////////////////////////////////////
///////////////////////

Any idea if I'm missing something or doing too much things?

Thanks

Daniel

Comments

  • edited January 2003
    Did you register the TraTWGridLinesRTTI class?

    initialization
    raRegisterRTTI(TraTWGridLinesRTTI);
    finalization
    raUnRegisterRTTI(TraTWGridLinesRTTI);


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2003
    Yes I did register it. Just forgot to paste that part. I'll try to send the
    complete code instead since the component will be free anyway I don't mind
    having the source code distributed on the web. Just need to get some things
    worked out before sending it.

    Thanks

    Daniel
  • edited January 2003
    I remember coding an event for the paint box component, before adding the
    canvas parameter, but I can't seem to find that project. I have moved from
    two machines since I worked on that project.

    If you place breakpoints in the methods of the RTTI class you have, do those
    fire?

    You have the SendEventNotify and a new eventID. That's good. Everything is
    registered. And the RTTI class is complete. It should work. Place a
    breakpoint in the initialization section for your register calls to make
    sure that unit is getting linked in.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2003
    Found the problemof the event not firing. I've send the component for you in the
    friend section. It's a quite simple component but makes it easier to create grid
    lines and my development team just hate to use lines or shapes to draw a grid so
    I hope it helps others too.


    Cheers and thanks again for your help.

    --
    Daniel Lemire
  • edited January 2003
    Cool! We'll put it on the website


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.