Jump to content

Code doesn't get executed after "Showmessage"


Int3g3r

Recommended Posts

Hello,

I have a formular with a TUnimEditField on it.
I'm scanning barcodes with this application. The EditField contains the scanned barcode.
After scanning i need to to some checks for no duplications in the database and some other tasks.

I the database already contains the scanned barcode i need to create a ShowMessageDialog.
This works just fine. I already set the "TUniGUIMainModule.EnableSynchronousOperations" to true.

I want to clear the EditField after the message was showed. But this doesn't work correctly.
I already created a sample application but on there it works just fine. On my real application the EditField doesn't get cleared.

procedure TfrmEkScan.edtScanChange(Sender: TObject);
begin
  if edtScan.Text <> '' then
  begin
    if Length(edtScan.Text) = 12 then
    begin
      if Pos('0756',edtScan.Text) = 0 then
      begin
        edtScan.Text := '0756'+edtScan.Text;
      end;
    end;

    if Length(edtScan.Text) = 16 then
    begin
      if isOmScanned then
      begin
        ShowMessage('MyMessage!');
        edtScan.Clear;                      //This Clear doesn't get updated screen. The scanned number gets still displayed
      end
      else
      begin
        agateAbfragen;
        edtScan.Clear;
        btnCancel.SetFocus;
        sc.Visible := true;
        btnCancel.Enabled := true;
        btnAdd.Enabled := true;
      end;
    end;
  end;
end;


function TfrmEkScan.isOmScanned: boolean;
var OmScan: String;
begin
  Result := false;
  OmScan := edtScan.Text;
  dmMain.qryPool.First;
  while not dmMain.qryPool.Eof do
  begin
    if dmMain.qryPoolSTRICHCODE_OM.AsString = OmScan then
    begin
      Result := true;
      edtScan.Clear;
      Break;
    end;
    dmMain.qryPool.Next;
  end;
end;

If i run this application with a breakpoint on the "edtScan.Clear;" it just work.
It seems like that the display doesn't get updated.

Can anyone tell me what the problem might could be ?

Regards Int3g3r

Link to comment
Share on other sites

I believe above should work, so must be something different between your sample app and real app that makes the problem. Are you sure you're not getting in the code again (late) or that the scanner also sends CR/return that affects it?) (I assume you have tested with manual entry as well.... ). But believe problem is something else than above. Doesn't above work if you enter the code manually?

Link to comment
Share on other sites

The problem occures in both cases, manual and with the scanner.
It seems like that some background process is not finished, because of that it cannot clear the field.
If i add a short delay then the edtScan gets correctly cleared.
I don't know what is exactly causing this problem but it's a temporary workaround.

Thank you for the Help.

      if isOmScanned then
      begin
	Sleep(500);				//Added
        ShowMessage('MyMessage!');
        edtScan.Clear;                      //This Clear doesn't get updated screen. The scanned number gets still displayed
      end
Link to comment
Share on other sites

×
×
  • Create New...