Checking CEdit without subclassing

Is there a way to check the contents of a CEdit field without subclassing it?

I want to check for invalid filenames in the CEdit field and not let the user enter it at all (the key press should not be recorded, if pasted into the field, invalid characters should just not get into the edit window) ..

Is there an easy way to do this?

On the side of the note, how do I make a variable bound to this field? If I add a variable that is not a control variable, will that variable always contain what is in the edit control?

Thanks..

+1


a source to share


3 answers


Per http://msdn.microsoft.com/en-us/library/f7yhsd2b(VS.80).aspx , "If you want to process Windows notification messages sent by an edit control to its parent (usually derived from a class from CDialog), add a map entry and message handler member function to the parent class for each message. " and "ON_EN_UPDATE. The edit control displays modified text. Dispatched after the control has formatted the text, but before it escapes the text, to resize the window if necessary." - so, without subclassing CEdit, you can check and possibly block updates via the message-message-window / message-handler in the parent.



0


a source


I created this one a while ago . Of course this is very dated, but the ideas still persist:



alt text

+1


a source


Override PreTranslateMessage in your dialog. When mesage WM_KEYDOWN and GetFocus () returns the HWND of your edit control, there is a message when you don't like the key.

0


a source







All Articles