[Lazarus] Setting String Properties of Custom Component = AV

Lee Jenkins lee at datatrakpos.com
Fri May 2 03:58:20 CEST 2008


Funky Beast wrote:
> Lee Jenkins wrote:
>>>>> Also, I'm having another problem with this component.  It's a
>>>>> TShape descendant and I have hooked up mousedown and mouseup events
>>>>> to change Pen.color and Brush.Color properties to different values
>>>>> in order to indicate visual feedback.
>>> MousDown and MouseUp events are handled by the IDE (designer).
>>>
>>>
>> Sorry Mattias, I wasn't clear enough.  When I site the component at *design 
>> time*, the mouse down events do not fire at *runtime*.  In the create event, I 
>> have this:
>>
>> constructor TPOSButton.Create(AOwner: TComponent);
>> begin
>>    inherited Create(AOwner);
>>    Self.OnMouseDown := HandleMouseDown;  // <== handlers with correct signatures.
>>    self.OnMouseUp := HandleMouseUp;
>> end;
>>
>>>> Setting Mode to Delphi fixed it, but I'm curious as to how to get
>>>> this to work in FPC mode.
> Hi,
> 
> In FPC mode, your event assignments should prefix with '@' like this:
> 
> constructor TPOSButton.Create(AOwner: TComponent);
> begin
>    inherited Create(AOwner);
>    Self.OnMouseDown := @HandleMouseDown;  // <== handlers with correct signatures.
>    self.OnMouseUp := @HandleMouseUp;
> end;
> 
> HTH,
> Funky Beast

They were, but I had to change the mode to Delphi to get the String properties 
from throwing an AV when I tried to set them at design time.

Thanks,

-- 

Warm Regards,

Lee



More information about the Lazarus mailing list