2

I have my own class (CMyEdit) subclassed from CEdit with own validation procedure.

I hook events ON_CHAR and ON_UPDATE and validate user input.

If the input is valid, attribute CMyEdit::isOk is switched to true. CMyEdit confirms validity during each change of EditBox content.

Dialog could confirm validity by CMyEdit::isOk.

I have overridden CEdit::SetWindowText()

inline void CMyEdit::SetWindowText(LPCTSTR lsText)
{
    CEdit::SetWindowText(lsText);
    Validate(); //set isOk true or false
}

But if dialog uses DDX_Text, no method is running (Nor EN_CHANGE, neither SetWindowText).

The same problem is, when user put value from clipboard (WM_PASTE).

How to hook this change of EditBox content?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Michal Hadraba
  • 347
  • 1
  • 11
  • Have you read this [document](https://stackoverflow.com/questions/42123991/why-does-updatedata-not-work-in-en-change-handler-for-mfc-cedit-control)? And there is a piece of code in the definition of UpdateData that prevents scheduling control notifications, so the Windows procedure of the edit control's parent window does not receive EN_UPDATE and EN_CHANGE notifications. – Yujian Yao - MSFT Jan 10 '22 at 08:29

0 Answers0