title: CEdit numeric validation event C++ MFC
body: <p>I have a CEdit text box which is a part of a property pane and only allows numeric values (positive integers).  The box works fine when people enter non-numeric values, but when they delete the value in the box a dialog pops up saying:
  "Please enter a positive integer."</p>
  
  <p>Here is the situation:<br>
  1. I have a number (say 20) in the box.<br>
  2. I delete the number.<br>
  3. I get the error dialog.<br>
  Could anybody tell me how I can intercept this event and put a default value in there?</p>
  
  <p>Here is what my property pane looks like:</p>
  
  <pre><code>
  const int DEFAULT_VALUE = 20;
  
  class MyPropertyPane:public CPropertyPane
  {
      //....
  private:
      CEdit m_NumericBox;
      int   m_value;
  
      //....
  public:
      afx_msg void OnEnChangeNumericBox();
  
      //....
  }
  void MyPropertyPane::MyPropertyPane()
  {
     // Set a default value
     m_value = DEFAULT_VALUE;
  }
  
  //....
  void MyPropertyPane::DoDataExchange(CDataExchange* pDX)
  {
      DDX_Control(pDX, IDC_NUMERIC_BOX, m_NumericBox);
  
      // this sets the displayed value to 20
      DDX_Text(pDX, IDC_NUMERIC_BOX, m_value);
  }
  
  //....
  void MyPropertyPane::OnEnChangeNumericBox()
  {
      // Somebody deleted the value in the box and I got an event
      // saying that the value is changed.
  
      // I try to get the value from the box by updating my data
      UpdateData(TRUE);
  
      // m_value is still 20 although the value is 
      // deleted inside the text box.
  }
  
  </code></pre>