I'm trying to create a TIWCGJQButton in a TIWCGJQRegion everything at runtime.
Following my code :
- Code: Select all
function TMainForm.CreateMyRegion: TIWCGJQRegion;
var
b: TIWCGJQButton;
NewName: string;
begin
if (CGIsCallBackProcessing) then
CGCallBackDisableAjaxResponse;
NewName:= CGFindUniqueComponentName(self, 'region');
Result := TIWCGJQRegion.Create(Self);
Result.Parent := ForumRegion;
Result.Height := 100;
Result.Align := alTop;
Result.Name := NewName;
Result.Color := clWebLIGHTCYAN;
Result.Top := t;
NewName:= CGFindUniqueComponentName(self, 'button');
b := TIWCGJQButton.Create(Self);
b.Parent := Result;
b.Top := 20;
b.Left := 8;
b.Name := NewName;
b.Caption := 'Press me';
b.JQButtonOptions.OnClick.OnEvent := OnMyButtonClick;
end;
procedure TMainForm.OnMyButtonClick(Sender: TObject; AParams: TStringList);
begin
WebApplication.ShowMessage(TIWCGJQButton(Sender).Caption + ' Pressed');
end;
When I try to click the button I receive an "Access violation" message and in fact the Sender parameter of the OnMyButtonClick function is empty.
What am I doing wrong?
I'm using XE5, IW 14.0.22, IWCGJQuery 1.8.0.3232.
Thank you,
Davide