title: MFC/C++ ComboBox: disable drawing of Dropdown closing & opening (UI freeze)
body: <p>I've just added an <strong>Item-Filter-Feature</strong> to a <code>CComboBox</code> derived class called 
  <code>ComboBoxFbp</code> in an old MFC application.</p>
  
  <pre><code>BOOL CComboBoxFbp::OnEditChange()
  {
      CString csText;
  
      if (m_wFbpMode &amp; _FbpMode_UserTextFiltersList) {
          GetWindowText(csText);
  
          // This makes the DropDown "flicker"
          // ShowDropDown(false);
  
          // Just insert items that match
          FilterItems(csText);
  
          // Open DropDown (does nothing if already open)
          ShowDropDown(true);
      }
  
      return FALSE;   // Notification weiterleiten
  }
  
  void CComboBoxFbp::FilterItems(CString csFilterText)
  {
      CString csCurText;
      int nCurItem;
      DWORD wCurCursor;
  
      // Text/selection/cursos restore
      GetWindowText(csCurText);
      nCurItem = GetCurSel();
      if (nCurItem != CB_ERR &amp;&amp; nCurItem &gt;= 0 &amp;&amp; nCurItem &lt; GetCount()) {
          CString csCurItemText;
          GetLBText(nCurItem, csCurItemText);
          if (csCurItemText == csCurText)     csCurText = csCurItemText;
          else                                nCurItem = CB_ERR;
      } else {
          nCurItem = CB_ERR;
      }
  
      wCurCursor = GetEditSel();
  
      // Delete all items
      ResetContent();
  
      csFilterText.MakeLower();
  
      // Add just the items (from the vector of all possibles) that fit
      for (auto item : m_vItems)
      {
          CString csItemText = item.first;
          csItemText.MakeLower();
          if (!csFilterText.IsEmpty() &amp;&amp; csItemText.Find(csFilterText) &lt; 0)
              continue;
  
          const int i = AddString(item.first);
          SetItemData(i, item.second);
      }
  
      // Text/selection/cursos restore
      if (nCurItem != CB_ERR)     SelectString(-1, csCurText);
      else                        SetWindowText(csCurText);
      SetEditSel(LOWORD(wCurCursor), HIWORD(wCurCursor));
  }
  </code></pre>
  
  <p>So when the user types, the long list of items in the DropDown gets filtered accordingly. Everything's fine so far.</p>
  
  <p>The size/height of the ListBox/DropDown doesn't change once its open. It <strong>does</strong> change accordingly when die DropDown opens. Meaning if there are only 2 items the DropDown is only 2 items high.</p>
  
  <p><strong>My issue</strong></p>
  
  <p>When the user enters a text where just one item fits the DropDown is only 1 item in height (this happens with some user workflows, i.e. user manually closes &amp; opens the DropDown).</p>
  
  <p>Now when the user now changes the text so multiple items are fitting the height stays 1 item and it looks weird as even the scrollbar doesn't look correct as it doesn't fit.</p>
  
  <p><strong>What I've tried so far</strong></p>
  
  <ol>
  <li>I cannot use <code>CComboBox::SetMinVisibleItems</code> (or the MSG behind it) as it only works in a Unicode CharacterSet (which I'm not able to change in this old application) and from WinVista onwards (app runs on WinXP).</li>
  <li>The only other option is to close and open the DropDown so it gets redrawn correctly with the correct height (see <em>// This makes the DropDown "flicker"</em> in Source Code above).</li>
  </ol>
  
  <p>Now going with option 2 I don't want the user to see the closing and opening ("flicker") of the DropDown after every key he is pressing.</p>
  
  <p>To prevent this I've tried a couple of solutions I've found but none works in my case with a ComboBox-DropDown. Here's a list of methods I've put just before the <code>ShowDropDown(false)</code> and just after the <code>ShowDropDown(true)</code>.</p>
  
  <ol>
  <li>EnableWindow(false/true);</li>
  <li>(Un)LockWindowUpdate();</li>
  <li>SendMessage(WM_SETREDRAW, FALSE/TRUE, 0)</li>
  </ol>
  
  <p>With all three calls I still see the DropDown closing/opening.</p>
  
  <p>Do you guys have other ideas how I can prevent this flicker?</p>
  
  <p>Thanks in advance
  Soko</p>