Recent

Author Topic: how can i change hint edit ??  (Read 3202 times)

majid.ebru

  • Hero Member
  • *****
  • Posts: 502
how can i change hint edit ??
« on: May 11, 2017, 06:46:35 pm »
Hi
i make a project and put a TEdit in form and i set true the "NumberOnly"!
.
when i type a char in Edit , show "you can only type a number here"
.
how can i change it and show an other string, like:"Error input"?
.
Thank you

Bart

  • Hero Member
  • *****
  • Posts: 5289
    • Bart en Mariska's Webstek
Re: how can i change hint edit ??
« Reply #1 on: May 11, 2017, 06:50:08 pm »
Sounds like you are on Windows then.
You cannot change that, it's the OS that does this.

Bart

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: how can i change hint edit ??
« Reply #2 on: May 11, 2017, 07:12:39 pm »
If you change your TEdit to accept any string input then you can program your own error message:

Code: Pascal  [Select][+][-]
  1.   BadNumber := -9999;  // depending on your needs, you can set this to any number that wouldn't make sense in your app
  2.   n := StrtoIndDef(TEdit1.text, BadNumber);
  3.   if n = BadNumber then
  4.     ShowMessage("Error input")
  5.   else
  6.     your code
  7. ;
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14367
  • Sensorship about opinions does not belong here.
Re: how can i change hint edit ??
« Reply #3 on: May 11, 2017, 09:05:12 pm »
Sounds like you are on Windows then.
You cannot change that, it's the OS that does this.

Bart
Yes you can. Handle OnKeyDown.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Bart

  • Hero Member
  • *****
  • Posts: 5289
    • Bart en Mariska's Webstek
Re: how can i change hint edit ??
« Reply #4 on: May 11, 2017, 11:12:13 pm »
Yes you can. Handle OnKeyDown.

That might prevent the hint, but you cannot alter the text of the Windows balloon tip AFAIK.
You would also have to handle pasteing into the control to avoid the balloon tip.
If you want to go to that hassle better use a TMaskEdit (and see how difficult it is to prevent unwanted pasting).

You might want to consider using a TSpinEdit(Ex) or a TFloatSpinEdit(Ex). These are specifically designed to handle numeric input, and they have a property Value, whic will give you an integer (or float) right away.

Bart

 

TinyPortal © 2005-2018