次のように、フォームで定義されたプロシージャをデータソースのイベント OnStateChange に割り当てようとしています。
unit SDIMAIN;
interface
uses Windows, ....., DB ;
type
TSDIAppForm = class(TForm)
....
procedure datasourceOnStateChange(Sender: TObject);
private
stateChange : TNotifyEvent;
....
var
SDIAppForm: TSDIAppForm;
...
end;
procedure TSDIAppForm.FormCreate(Sender: TObject);
begin
DataModule1.AdsTable1.Active := true;
DataModule1.AdsTable2.Open;
stateChange := SDIAppForm.datasourceOnStateChange(DataModule1.AdsTable1);
DataModule1.DataSource1.OnStateChange := stateChange;
.
.
.
procedure TSDIAppForm.datasourceOnStateChange(Sender: TObject);
begin...end;
最初に上記を実行しようとしたときに、エラーが発生しました! 互換性のない型: 'TNotifyEvent' および 'procedure, untyped pointer or untyped parameter'
I tried changing
stateChange := SDIAppForm.datasourceOnStateChange(DataModule1.AdsTable1); to
stateChange := SDIAppForm.datasourceOnStateChange;
Now I don't get the error but it doesn't work. The OnStateChange event is not fired at all.
I tried with other methods like using
var
Method : TMethod;
.
.
.
Method.Data := Pointer(Self);
Method.Code := MethodAddress('datasourceOnStateChange'); and using pointers but it doesn't work.
私はデルファイが初めてで、現在学習中です。私は正確に何をすべきかを理解していなかったかもしれません。誰かがこの問題について私を助けることができれば、それは本当に役に立ちます.
Thanks.