Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reader callback not working from child form #7

Open
jeanvdr opened this issue Aug 10, 2023 · 0 comments
Open

reader callback not working from child form #7

jeanvdr opened this issue Aug 10, 2023 · 0 comments

Comments

@jeanvdr
Copy link

jeanvdr commented Aug 10, 2023

Hi,
I'm trying to launch a dynamically created demoEid form (from samples) from another form, like this:

procedure TForm1.Button1Click(Sender: TObject);
var
 feid: TForm;
begin
 feid := tfrmMain.Create(self);
 try
  feid.ShowModal;
 finally
  feid.Free;
 end;
end;

Doing so, the reader callback of frmMain is called but not working.

procedure HandleReaderCallBack(var ReaderNumber : DWORD; var EventType : DWORD; UserContext : Pointer); stdcall;
begin
  if Assigned(frmMain) then
    begin
      case EventType of
        1 : begin
              frmMain.Events.Items.Add(DateTimeToStr(Now) + ' card inserted');
              ActivateCardEx(ReaderNumber);
              frmMain.btnReadCard.Enabled := true;
              frmMain.ReadIDCard;
            end;
        2 : begin
              frmMain.Events.Items.Add(DateTimeToStr(Now) + ' card removed');
              DeactivateCardEx(ReaderNumber);
              frmMain.btnReadCard.Enabled := false;
              frmMain.ClearIDData;
            end;
        3:  begin
              frmMain.Events.Items.Add(DateTimeToStr(Now) + ' readers list changed');
              frmMain.btnReadCard.Enabled := false;
              SetCallback(HandleReaderCallBack, nil);
            end;
      end;
    end;
end;

Assigned(frmMain) is false but even if I bypass this test, ActivatedCardEx doesn't work either.
Probably more a Delphi callback problem than a swelio, but can anyone help me on this ?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant