Incompatible type: isethod pointer and regular procedure

1

I have a calendar with only month / year and I created an "event" so that, when it was selected, the month could be treated and the fields filled in.

type
  TonAnoMesSelecionadoEvent = procedure(Sender,Parent:TObject;Mes,Ano:Integer);

  TCalendario = class(TwinControl)
    ....
    Procedure pnlMesClick(Sender:tobject);
  private
    FMes,FAno:Word;

  protected
     //FonAnoMesSelecionado :TonAnoMesSelecionadoEvent;
  public
    FonAnoMesSelecionado:TonAnoMesSelecionadoEvent;{tem a propriet mas removi ela pois achei que o erro era esse}
    constructor Create(AOnwer: TComponent);  overload; override;
    constructor Create(AOnwer: TComponent;X,Y:integer);overload;
    constructor Create(AOnwer: TComponent;X,Y,ano:integer);overload;
    procedure pShowCalendar(AOnwer: TComponent;X,Y:integer);
  end;

  .....

  procedure TfrmCalendario.pnlMesClick(Sender: TObject);
  begin
    if Assigned(FonAnoMesSelecionado) then
      FonAnoMesSelecionado(Self,Owner,TPanel(Sender).Tag,btnAnos.Tag);
  end;

The problem occurs when trying to associate my procedure with this Field :

 Tform1 = Class(Tform)
  ....
   procedure FormClick(Sender: TObject);
   procedure onSelect(Sender,Parent:TObject;Mes,Ano:Integer) ;
 end;



   Procedure tform1.btnClick(sender:tObject);
   var
    lCalendar:TCalendario;
  begin
    lCalendar:TCalendario.Create(self);
    lCalendar.FonAnoMesSelecionado := OnSelect;//<- erro ocorre nessa linha
    //lCalendar.pShowCalendar(.....);
    //......
  end

  procedure tform1.onSelect(Sender, Parent: TObject; Mes, Ano: Integer);
  begin
    ShowMessage(IntToStr(Mes)+'/'+IntToStr(Ano));
  end;

I do not know how I can do this, what's wrong ???

    
asked by anonymous 08.04.2016 / 19:31

1 answer

2

The type definition must be TonAnoMesSelecionadoEvent = procedure(Sender,Parent:TObject;Mes,Ano:Integer) of object;

    
08.04.2016 / 19:41