Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-25-2017, 10:33 PM
delphi159 delphi159 is offline
Junior Member
 
Join Date: Oct 2015
Posts: 3
Question How to get good's barcode without TEdit?

I'm scanning barcodes and get it into an TEdit and it populates the edit box with the good's barcode. I use the onkeypress event and I get goods with this barcodes from my db:
Code:
Query1.text:='select * from Goods where barcode=:Edit1';
Query1.parambyname('Edit1'). asstring:=Edit1.text;


procedure TForm1.EditBarcodeKeyPress(Sender: TObject; var Key: Char)
begin
    if key=#13 then begin
    keyfield:='barcode';
    keyvalues:=editbarcode.Text;
    options:=[lopartialkey];
    Form1.Query1.Locate(keyfield,keyvalues,options);                                   
    DBGrid1.setfocus;
    EditBarcode.Clear;
end;
I don't use any third-party components for this.
How can I get barcodes without previous focusing TEdit? Which event have to use for this?
I'm using delphi 10.2 and a USB scanner.

Last edited by delphi159; 05-25-2017 at 10:50 PM.
Reply With Quote
  #2  
Old 05-29-2017, 08:47 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,203
Default

When do you want this???

When the form shows: Use the Form.OnFormShow
When you press escape (or any other key): Use the Form.OnKeyPress
When you do nothing for 30 seconds: Use a TTimer

As you can see, you provide too little information to answer this
Reply With Quote
  #3  
Old 06-03-2017, 02:08 PM
delphi159 delphi159 is offline
Junior Member
 
Join Date: Oct 2015
Posts: 3
Default

Quote:
Originally Posted by Norrit View Post
When do you want this???

When the form shows: Use the Form.OnFormShow
When you press escape (or any other key): Use the Form.OnKeyPress
When you do nothing for 30 seconds: Use a TTimer

As you can see, you provide too little information to answer this
Norrit, thanks for your answer. I want use scanner when I do nothing, when an application is idle. What do you mean in these words: "When you do nothing for 30 seconds: Use a TTimer". May you go in detail, please?
Reply With Quote
  #4  
Old 06-05-2017, 04:04 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 166
Default

Quote:
I want use scanner when I do nothing
How to you intend to implement something like this? You have an INFINITE number of idle moments within your application (not quite infinite but you get the idea), do you intend to launch an INFINITE number of scans????

You have to trigger the scan based on SOMETHING, like a button click for example.
Reply With Quote
Reply

Tags
delphi 10

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:41 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.