Hi!
I am jammed with a problem:
- created a custom edit control for float values
- the control filters the WM_KEYDOWN and WM_CHAR messages
- on PGUP/PGDN it increases/decreases the value associated to it
- it allows digits ('0'..'9') and the dot ('.') only, coma (',') is transformed into dot
- other control keys (HOME,END,DEL,ENTER...) are passed to the default proc
Here comes my question:
I want to edit control to monitor the inserted/entered value to keep it in a given range. (The edit control is a text control, so a text-to-float conversion is done before anything else.)
Example (the desired behavior):
Range is [0,100] and the user enters 200 (hits the keys 2,0,0). When the 2nd '0' is hitted the value is automatically changed to the biggest allowed value, that is 100.
So far I found that only the parent window of the edit control can keep track of such value changes via the EN_CHANGE message. But with this solution I had to the EN_CHANGE processing code to every single window possessing such custom edit control, though this is a general feature of the edit control.
What message should I capture in the window proc of the edit control? Any ideas appreciated!
Greets, Gábor
ps.: Sorry, if someone's already posted stuff about this...
Isn't Up-Down (http://msdn2.microsoft.com/en-us/library/ms649973.aspx) a better choice ?
call SendMessage function with WM_GETTEXT message , some like this :
lResult = SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) WM_GETTEXT, // message ID
(WPARAM) wParam, // = (WPARAM) () wParam;
(LPARAM) lParam // = (LPARAM) () lParam;
);
then conver buffer to float,check for max/min values and
call SetDlgItemInt function with proper value...
hope it helps...
Use EM_GETHANDLE to get a pointer to the actual contents of the edit box.
Then you will be able to convert/filter the value on each keypress to check and make sure it's within the correct range.