Board index » delphi » Help with TEdit (D1)

Help with TEdit (D1)

Hi,
I have a problem with the TEdit component, and I wonder if anybody can help
me.

What I'm trying to do, is to evaluate the text entered in the edit-box. If
the text is wrong, i.e. not an integer, a message is show that notifies the
user. A message may also be shown in some other cases. After the message has
been shown, I try to focus a special component on my form, most often the
edit-box, but in some cases a TMemo. What happens then, is that the cursor
disappears, even though I have set the focus. I have also tried to set
ActiveControl but nothing helps. I have also tried to Refresh the form, but
it doesn't help. Can anybody help me on this one?

Thanks in advance

/Fredrik

 

Re:Help with TEdit (D1)


i think there is an easy way :)

Assume the Edit1 is the edit box u want to evaluate..

onChange, onExit events (this is your choice)

If {my evaluation not ok} then edit1.setfocus; {or any object you want}

Hope this helps..
MAH

Re:Help with TEdit (D1)


On Tue, 13 May 1997 05:47:31 GMT, fr...@ida.liu.seREMOVE_THIS (Fredrik

Quote
?berg) wrote:
>What I'm trying to do, is to evaluate the text entered in the edit-box. If
>the text is wrong, i.e. not an integer, a message is show that notifies the
>user. A message may also be shown in some other cases. After the message has
>been shown, I try to focus a special component on my form, most often the
>edit-box, but in some cases a TMemo. What happens then, is that the cursor
>disappears, even though I have set the focus.

If your code is executing during a Windows focus change, there is an
icky Windows issue -- when Windows is in the process of changing the
focus (e.g. when the user presses Tab to move to another control),
your attempts to change the focus don't work.

One way around this is to keep a TTimer component available.  Normally
it's not active.  When you've discovered a problem, show your error
message, set the TTimer to active, with a very short Duration, and
don't try to move the focus.   Windows will then finish moving the
focus, at which point the TTimer will run; it will determine which
control is to be focussed as the result of an error (you'll have
recorded this in your error check routine) and set the focus.

There are other ways but this one will work.  (Oh yes, make sure the
TTimer turns itself off as part of its handler.)
J. Merrill / Analytical Software Corp

Re:Help with TEdit (D1)


Quote
Fredrik ?berg (fr...@ida.liu.seREMOVE_THIS) wrote:

: What I'm trying to do, is to evaluate the text entered in the edit-box. If
: the text is wrong, i.e. not an integer, a message is show that notifies the
: user. A message may also be shown in some other cases. After the message has
: been shown, I try to focus a special component on my form, most often the
: edit-box, but in some cases a TMemo. What happens then, is that the cursor
: disappears, even though I have set the focus. I have also tried to set
: ActiveControl but nothing helps. I have also tried to Refresh the form, but
: it doesn't help. Can anybody help me on this one?

Try the SelLength, SelStart, and SelText properties. They are not read-only,
but you can also write to them.

Ulrich Kroener
EIBA

Other Threads