Detect CR

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
lcrltd
Junior Coder
Posts: 35
Joined: Thu Nov 16, 2006 8:23 am

Detect CR

Post by lcrltd » Mon Jul 11, 2011 10:25 am

I have a dialog with an edit box which I populate from a card swipe. The card swipe enters the details fine, but I want the code to detect when the card is entered and pop up a message.

The card swipe automatically enters an end carriage return , but how can I get this CR to trigger a message box.?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jul 11, 2011 12:58 pm

One way would be to add a button and make it a default. do Adddialoghandler> on the button's OnClick event and spawn your message.

Another way, if you have control of the card swipe wold be to change the enter to a tab then use the OnExit event for the edit box.

Here's a sample for the first method, note that the button must be visible to catch the enter press so if you want it to be unseen move it off dialog.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  object Edit1: TEdit
    Left = 15
    Top = 21
    Width = 121
    Height = 21
  end
  object MSButton1: tMSButton
    Left = -1000
    Default = True
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,MSG

SRT>MSG
  MDL>ok
END>MSG

Show>Dialog1,res1

lcrltd
Junior Coder
Posts: 35
Joined: Thu Nov 16, 2006 8:23 am

Post by lcrltd » Mon Jul 11, 2011 1:35 pm

Perfect , thank you.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts