title: Override OnClose()
body: <p>I got this class</p>
  
  <pre><code>class CWebBrowser2 : public CWnd
  </code></pre>
  
  <p>And i want to override OnClose What i have done so far is in the header file I added  void OnClose(); and in the .cpp file i added </p>
  
  <pre><code>void CWebBrowser2::OnClose ()
  {
          int i=0;
          i++;
  }
  </code></pre>
  
  <p>But the OnClose is never called.</p>
  
  <p>Then I tried to to modify the header file to</p>
  
  <pre><code>afx_msg void OnClose();
  DECLARE_MESSAGE_MAP()
  </code></pre>
  
  <p>And added this to the .cpp file</p>
  
  <pre><code>BEGIN_MESSAGE_MAP(CWebBrowser2, CWnd)
      //{{AFX_MSG_MAP(CBrowserDlg)
      ON_WM_CLOSE()
      //}}AFX_MSG_MAP
  END_MESSAGE_MAP()
  </code></pre>
  
  <p>But still OnClose is never called. I have tried to Change to OnClose to OnDestroy but that isnt called either.</p>
  
  <p>any ideas on what Im doing wrong?</p>