title: Error Creating Window Handle
body: <p>I'm battling the old "Error creating window handle" fun.  My application has a center area that hosts whatever control the user is currently working on.  When the user loads a new control, I destroy the old one.  Or at least I try to.  When I run the task manager, I see in horror as the number of GDI objects is not reducing as a new control is getting loaded.  This is what I'm doing to (try to) kill off a contorl I'm done with.  The counter shows a huge number in the end, which seems about right, but the GDI objects in Task Manager stays about the same, until it hits 10,000, and then everything comes crashing down.</p>
  
  <pre><code>    private void RecursivelyKillYourself(Control C) {
          if (C.Controls != null &amp;&amp; C.Controls.Count &gt; 0) {
              List&lt;Control&gt; Controls = C.Controls.OfType&lt;Control&gt;().ToList();
              C.Controls.Clear();
              Controls.ForEach(c_inner =&gt; RecursivelyKillYourself(c_inner));
          } else {
              C.Dispose();
              num++;
          }
      }
  </code></pre>
  
  <p>EDIT</p>
  
  <p>Fixed - gotta make sure you create tooltips correctly.  Also, as a commentator pointed out, that long silly Recursive method is unnecessary.  Just a simple Dispose will do.</p>
  
  <p>bad</p>
  
  <pre><code>(new SMcMaster.TabOrderManager(this)).SetTabOrder(SMcMaster.TabOrderManager.TabScheme.AcrossFirst);
  </code></pre>
  
  <p>good</p>
  
  <pre><code>ToolTip T = new ToolTip();
  T.SetToolTip(btnAddPropertyInvoice, "Add Properties");
  components.Add(T);
  </code></pre>