I have a shape, when i click OnMouseDown in Object inspecter / Events tab. I would like for it to do the procedure “SelectMessage” But its not showing up as an option. Also if i manually type in “SelectMessage” I get error Property and method Selectmessage are not compatible.
Selectmessage
procedure TFZone1Mod7.Selectmessage(sender: TObject);
var
ShapeOrderNo: Integer;
begin
if TryStrToInt(copy(TShape(Sender).Name,6,MaxInt),ShapeOrderNo) then
begin
LookUpMessage(ShapeOrderNo);
end;
end;
If i do
procedure TFZone1Mod7.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
selectmessage(sender);
end;
then it will work. but easier to select from events if i can.
thanks
The event handler for an
OnMouseEventmust have a signature of this form:The component is going to call your event handler passing all those parameters, and your event handler must be of the expected form.
You have no control over this. The component has a pre-determined, hard-coded form for its event handlers. You simply have to fit in. Your current solution is the correct one.
Having said that,
SelectMessagecan only work when it is passed aTShape. So declare the function that way:And call it like this: