Solved

tabbing from one mask edit to another automatically

Posted on 1998-07-01
12
146 Views
Last Modified: 2010-04-04
the users of my application have to enter 2 numbers in two separate mask edit fields. These are numeric values. I would like the focus to jump to the second mask edit when the first one is filled with digits (sort of like the Windows 95 authentication code.
0
Comment
Question by:sharons
12 Comments
 
LVL 1

Expert Comment

by:michaue
Comment Utility
Set the MaxLength property of MaskEdit1 (at design time) to the maximum number of digits you want entered into the field.

And on the OnKeyUp event of MaskEdit1 put the following code

if Length(MaskEdit1.Text) = MaskEdit1.MaxLength then
  MaskEdit2.SetFocus;
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
michaue, Did you check it?
0
 
LVL 1

Expert Comment

by:michaue
Comment Utility
Yes, Why?  :)
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Because if you put some mask then it's not working. Put the following mask:
MaskEdit1.EditMask:='!\(999\)000-0000);1;_'
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Expert Comment

by:michaue
Comment Utility
Sorry, I didn't check it with the mask ....
0
 
LVL 1

Expert Comment

by:michaue
Comment Utility
Here's the sollution with mask edit characters included:

You have to declare a variable to hold the character count, and initialize it with the value of mask characters for which the user won't enter anything (like spaces etc)

You don't have to set the MaxLenght property when you add and EditMask to MaskEdit1, because it will put the value in as soos as you change the EditMask property.

Then in the KeyPress event of MaskEdit1 put the following code ...

Count := Count + 1;
if Count = MaskEdit1.MaxLenght then
  MaskEdit2.SetFocus;
0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
But then if you are pressing the left arrow key, meaning going back, then the Count will not have the right value of the cursor position, so in this case it will not work properly.
0
 
LVL 1

Expert Comment

by:michaue
Comment Utility
Any suggestions ?
0
 
LVL 3

Accepted Solution

by:
vladika earned 50 total points
Comment Utility
Try it

procedure TForm1.MaskEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if MaskEdit1.SelStart = MaskEdit1.MaxLength then MaskEdit2.SetFocus;
end;

0
 

Author Comment

by:sharons
Comment Utility
It works great.  Thank you.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now