title: A Dialog derived from CDialog returns -1 after DoModal (MFC/C++)
body: <p>I have created a Dialog which it's derived from CDialog (MFC does this automatically), but I had to override the <code>OnInitDialog</code> method to make initialization of a ComboBox:</p>
  
  <pre><code>BOOL CLogin::OnInitDialog()
  {
   CDialog::OnInitDialog();
  
   InitCommonControls();
  
   if ( FillInCombo() != 0 )
    //erro ao tentar ler leitoras
    return TRUE;
  
   return TRUE;
  }
  </code></pre>
  
  <p>The method <code>FillInCombo</code> calls a PCSC class to fill this combo with all available smart card readers.</p>
  
  <p>However, while debugging  a strange behavior takes place. While attempting to select an item on the combo, it closes automatically (it actually generates an OnClose event) and DoModal returns -1.</p>
  
  <p>Then, next, the application is never again loaded correctly unless I clean the solutions and build it again.</p>
  
  <pre><code> CLogin SmartNetData;
   int ret = SmartNetData.DoModal();
   switch ( ret )
   {
      case IDOK:
      break;
      case -1: 
      // strange error
      OnOK();
      return TRUE;
      case IDABORT:
      case IDCANCEL:
      OnOK();
      return TRUE;
   };
  </code></pre>
  
  <p>Thanks for any possible help on this.</p>
  
  <p>LATER EDIT: I realized the problem arises because of the combobox. I am not sure why. I replaced it by a ListBox and I am not getting troubles. </p>