Integer-only
Edit control
Implementing an integer-only edit control
requires little coding, and indeed does not require you to handle the OnKey*
events to check the contents to allow only digits. Windows introduces
the style ES_NUMBER for such occasions. To specify this style, you
can either derive a component from TEdit and override the CreateParams
method, or alternatively, use the GetWindowLong() / SetWindowLong() comination
as demonstrated below.
KEYWORDS: ES_NUMBER, CreateParams,
GetWindowLong, SetWindowLong
|