Units(.pas만 있는 폼)에서
Type은 전혀 없이
function안에서 콤포넌트를 생성하여 그 콤퍼넌트에 이벤트를 연동시킬 방법은 없나요?
아래와 같이 했더니 에러가 발생하더라구요..
function gf_Make : Boolean;
procedure AddReports;
begin
// 코딩
end;
Var
QRCR_FO: TQRCompositeReport;
begin
Try
QRCR_FO := TQRCompositeReport.Create(nil);
QRCR_FO.OnAddReports := AddReports;// Method pointer and regular procedure 에러발생
Finally
QRCR_FO.Free;
end;
end;
고수님들의 답변 부탁드립니다.
이벤트메소드 함수들인 Method Procedural 변수형은 함수호출될때 Self인자를 필요로합
니다. 그러므로 일반적인 Procedural변수형과는 호환이 되지 않습니다. 또 Self인자를
필요로 하므로 반드시 객체내부에 선언이 되어야 합니다.
procedure AddReports를 객체 내부로 옮기고, 파라매터도 TNotifyEvent형에 맞게써주세요.
^^ 항상 즐코하세요.
한현정 wrote:
> Units(.pas만 있는 폼)에서
> Type은 전혀 없이
> function안에서 콤포넌트를 생성하여 그 콤퍼넌트에 이벤트를 연동시킬 방법은 없나요?
> 아래와 같이 했더니 에러가 발생하더라구요..
>
> function gf_Make : Boolean;
> procedure AddReports;
> begin
> // 코딩
> end;
> Var
> QRCR_FO: TQRCompositeReport;
> begin
> Try
> QRCR_FO := TQRCompositeReport.Create(nil);
> QRCR_FO.OnAddReports := AddReports;// Method pointer and regular procedure 에러발생
> Finally
> QRCR_FO.Free;
> end;
> end;
>
> 고수님들의 답변 부탁드립니다.
>
>