Scalabium Software |
|
| Knowledge for your independence. | |
|
Every developer needs any editbox where end-user can enter only numbers. This is very popular task and you may find a lot of such topics in the public forums/newsgroups. But most answers in forums are incorrect as I see, because they suggest
to write some code in OnKeyPress handler and to check there what is a
character pressed. Today I want to post a simple code that allow to solve this task without
any problems. var defstyle: dWord; begin defstyle := GetWindowLong(Edit1.Handle, GWL_STYLE); SetWindowLong(Edit1.Handle, GWL_STYLE, defstyle or ES_NUMBER) end; If you also want to have a right aligned number, send additionally the ES_RIGHT flag there It's all - only numeric characters are possible and this is controled on OS level. Hope that you'll like this tip... |
|
||||||||||||||||||||||||||||||||||||
![]() |
Copyrightc 1998-2008, Scalabium
Software. All rights reserved. |
December 2, 2003 |