title: flicker on tab control - WIN32
body: <p>I have a WIN32 application. Its main window is <code>hwndMain</code>, one of its child is <code>hwndView</code>. There is one tab control <code>hwndTab</code> on <code>hwndView</code>.</p>
  
  <p>When I resize <code>hwndMain</code>, <code>hwndView</code> is resized and so is <code>hwndTab</code>. It flicker a little, but not much.</p>
  
  <p>I have tried to use <code>WS_EX_COMPOSITED</code> style ( for <code>hwndView</code> or <code>hwndTab</code>), but it just gave me blank window. I tried to use <code>WS_EX_TRANSPARENT</code> and it solves flicker, but when the windows is resized to be larger, the childs are updated very slow, e.g I see black region for one second, then the region is updated.</p>
  
  <p>I have successfully sloved the flicker issue for <code>TreeView</code> by using <code>WS_CHIPCHILDREN</code> style. (See remark below). But using <code>WS_CHIPCHILDREN</code> stlye for <code>hwndView</code> doesn't fix the flicker issue for tab control.</p>
  
  <p>I have paid attention to <code>WM_ERASEBKGND</code> and <code>Not set hbrBackground</code> also.</p>
  
  <p>I want to use double buffer for tab control, but I can't find a tutorial for this purpose. All the tutorial I found is: In <code>WM_PAINT</code>, after creating <code>CompatibleDC</code> and <code>CompatibleBitmap</code>, draw what you want in <code>memdc</code> and.....; But I don't want to do any custom drawing in <code>WM_PAINT</code> for <code>hwndTab</code>. I just want to leave the tab control do this job, but shows the final result only.</p>
  
  <p>Could someone show me a small example how to double buffer a tab control (if you think this will fix the flicker issue of tab control), in the language <code>c</code> + <code>winapi</code>, since I don't have the knowledge of C#, Net,..etc.</p>
  
  <hr>
  
  <p>Remark: For my TreeView, it is a child of a window <code>hwndContainer</code>. It is created as:</p>
  
  <pre><code>win-&gt;hwndContainer = CreateWindowEx(
      WS_CLIPCHILDREN,
      _T("SUMATRA_PDF_TOCBOX"), NULL,
      WS_CHILD,
      0, 0, gGlobalPrefs.sidebarDx, 0,
      win-&gt;hwndPanel, NULL,
      ghinst, NULL);
  </code></pre>
  
  <p>Using <code>WS_CLIPCHILDREN</code> fix the flicker, even if I don't use double buffer. But it is strange to put 
  <code>WS_CLIPCHILDREN</code> in the first parameter position. If I put it after WS_CHILD, i.e</p>
  
  <pre><code>win-&gt;hwndContainer = CreateWindowEx(
      NULL,
      _T("SUMATRA_PDF_TOCBOX"), NULL,
      WS_CHILD | WS_CLIPCHILDREN,
      0, 0, gGlobalPrefs.sidebarDx, 0,
      win-&gt;hwndPanel, NULL,
      ghinst, NULL);
  </code></pre>
  
  <p>,then the flicker still occurs.</p>
  
  <p>So I also tried to use the first way when I created <code>hwndView</code>, but it just gave blank white window.
  I am really confused with these stuff.</p>
  
  <p>Here is the blank window picture when I used <code>WS_EX_COMPOSITED</code> for <code>hwndView</code>.
  There is no such problem when I used it for <code>hwndContainer</code>.</p>
  
  <p><code>hwndView</code> in fact has two child: a Tab Control <code>hwndTab</code> and a child which has its own double buffer and drawing. I am not sure if this cause the problem for using <code>WS_EX_COMPOSITED</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/ZIDbJ.png" alt="enter image description here"></p>