title: MFC button onclick handler
body: <p>I've 2 mfc buttons that I want to hide when a 3D stl file is being loaded and then show the buttons again when the stl loading is complete. This is to prevent user from re-loading the model when the loading is currently taking place.</p>
  
  <p>The snippet of the code is as below</p>
  
  <pre><code>        { // change control state when model loads
              ((CButton *)this-&gt;GetDlgItem(IDC_RELOAD_STOCK_BUTTON))-&gt;ShowWindow(SW_HIDE);
              ((CButton *)this-&gt;GetDlgItem(IDOK))-&gt;ShowWindow(SW_HIDE);
              UpdateWindow();
          }
  
          // this process takes few seconds to load the file in the memory
          customStockModel.LoadFile(pathName.GetBuffer(pathName.GetLength()));
  
          {
              // change control state when the model has loaded
              ((CButton *)this-&gt;GetDlgItem(IDC_RELOAD_STOCK_BUTTON))-&gt;ShowWindow(SW_SHOW);
              ((CButton *)this-&gt;GetDlgItem(IDOK))-&gt;ShowWindow(SW_SHOW);
              UpdateWindow();
  
          }
  </code></pre>
  
  <p>The buttons do get hidden and reappear as I expect, but when I click the button area while it's hidden, the onclick handler gets called immediately when the button control reappears on the screen. it seems like the click message is queued and mfc calls the handler once the buttons are activated. What am I doing wrong here?</p>