title: Is this a memory leak in MFC
body: <pre><code>// CMyDialog inherits from CDialog 
  void CMyFrame::OnBnClickedCreate()
  {
      CMyDialog* dlg = new CMyDialog();
      dlg-&gt;Create( IDD_MYDIALOG, m_thisFrame );
      dlg-&gt;ShowWindow( SW_SHOW );
  }
  </code></pre>
  
  <p>I'm pretty sure this leaks.  What I'm really asking is: is there any "magic" in MFC that does dialog cleanup when the dialog is destroyed.  How would it work if dlg wasn't a pointer but declared on the stack - wouldn't the destructor destroy the window when dlg goes out of scope.</p>