title: Windows-8 & Internet Explorer-10 broke my ActiveX control drawing?
body: <p>I am experiencing a very weird behavior while running my Active-X control on “Windows 8” OS, and browser “Microsoft Internet-Explorer 10”.</p>
  
  <p>The control:
  My Active-X control is very stable product that my company is already distributing for several years between hundreds of happy customers.   The control is an ATL custom-draw control, written in C++, and built with “Visual Studio 2008”. </p>
  
  <p>The problem – the drawing disappears:
  While I press the link that opens my control for the first time, I can see that my control is being painted gradually (as my data loading is sometimes slow), but eventually all the drawing disappears, leaving a blank white background color where the controls is located.</p>
  
  <p>Using ‘Spy++’ I can see that my control is really there, but all its painting disappear.
  If I move the browser or change its size the control will be re-painted, but otherwise it is simply not visible.</p>
  
  <p>I tried to debug this problem and find out who is erasing my drawing.
  I came up with the following technique:</p>
  
  <ol>
  <li>Using WinDBG I added breakpoints at ‘user32.dll’ DLL on the following methods: user32!InvalidateRect, user32!InvalidateRgn, user32!FillRect,</li>
  <li>I defined these methods to only show stack and continue with to run,</li>
  <li>I ran the above problematic scenario,</li>
  <li>When the problem happens I am trying to view who called ‘Invalidate’ or ‘FillRect’,</li>
  <li>Since all this happens very quickly I am using the ‘Print Screen’ button to freeze the moment</li>
  </ol>
  
  <p>After doing this several times I find that exactly at the time my control disappears the following stack calls ‘user32!FillRect’:</p>
  
  <pre><code>user32!FillRect
  MSHTML!memcpy+0x9805
  MSHTML!COmWindowProxy::SwitchMarkup+0x468
  MSHTML!CMarkup::SetInteractiveInternal+0x428
  MSHTML!CMarkup::RequestReadystateInteractive+0x98
  MSHTML!CMarkup::BlockScriptExecutionHelper+0xde
  MSHTML!CHtmPost::Exec+0x794
  MSHTML!CHtmPost::Run+0x1c
  MSHTML!PostManExecute+0x5f
  MSHTML!PostManResume+0x7b
  MSHTML!CHtmPost::OnDwnChanCallback+0x3a
  MSHTML!CDwnChan::OnMethodCall+0x19
  MSHTML!GlobalWndOnMethodCall+0x169
  MSHTML!GlobalWndProc+0xd7
  user32!InternalCallWinProc+0x23
  user32!UserCallWinProcCheckWow+0x100
  user32!DispatchMessageWorker+0x3ef
  user32!DispatchMessageW+0x10
  IEFRAME!CTabWindow::_TabWindowThreadProc+0x981
  IEFRAME!LCIETab_ThreadProc+0x378
  iertutil!CIsoWinMsg::PostQueuedMessagesToComponent+0x4b
  IEShims!NS_CreateThread::DesktopIE_ThreadProc+0x66
  KERNEL32!BaseThreadInitThunk+0xe
  ntdll!__RtlUserThreadStart+0x72
  ntdll!_RtlUserThreadStart+0x1b
  </code></pre>
  
  <p>This is consistent.
  When examining this stack I found that this message belongs to a window of class <code>Internet Explorer_Hidden</code>, which is window of size <code>zero (0x0)</code>, but with a <code>WS_VISIBLE</code> style. This window belongs to the browser.</p>
  
  <p>Does anyone know this phenomenon?
  Is it possible that the browser hidden window is causing this problem?
  Could you recommend on other approach to try and hunt the stack that is erasing my drawing?</p>
  
  <p>Many thanks for any hint!</p>
  
  <p>Paz Offer</p>