title: Why does repeating call to createBitmapIndirect in WM_MOUSEMOVE eventually returns NULL?
body: <p>I'm writing a complex color editing dialog box which contains a list view control and a photoshop-style HSV color picker. This dialog will be used as described: 
  the user first clicks on the particular item, then manipulates cursor on the colorpicker to setup the right color for the item, then clicks another item and repeats the process.</p>
  
  <p>My hotoshop stle HSV colorpicker is devided in two rectangels - 
  1. 256x20 color ramp that represents with full 360 span of HUEs</p>
  
  <ol>
  <li>256x256 window that showes all the VALUES and SATURATION variation of the current selected HUE.</li>
  </ol>
  
  <p>Realization:
  I've made some research and decided to use GDI bitmaps.
  So I fill in GDI BITMAP struct, get dc, get comaptable dc, and create hBitmap by CreateBitmapIndirect:</p>
  
  <pre><code>    case WM_INITDIALOG:
      bitmap_hsv.bmBits=&amp;bits_hsv;
      bitmap_hsv.bmBitsPixel=32;
      bitmap_hsv.bmHeight=256;
      bitmap_hsv.bmPlanes=1;
      bitmap_hsv.bmType=0;
      bitmap_hsv.bmWidth=256;
      bitmap_hsv.bmWidthBytes=256*4;
  
      hDC=GetDC(hDlg);
      hDC_compat=CreateCompatibleDC(hDC);
      hBitmap_hsv=CreateBitmapIndirect(&amp;bitmap_hsv);
      return (INT_PTR)TRUE;
  </code></pre>
  
  <p>Then on the mouse move I have to check if the user selected some other HUE in the hue ramp and if he did then I need to fill the byte array of my BITMAP by new values. In the listing for simplicity reasons every mouse move need change of HUE and refill the whole bitmap each call. </p>
  
  <pre><code>case WM_MOUSEMOVE:
      if (wParam&amp;MK_LBUTTON)
      {
          hDC=GetDC(hDlg);
          pt.x=(LONG) LOWORD(lParam);//client coords
          pt.y=(LONG) HIWORD(lParam);//client coords
          H+=1;
          if (H==360) H=0;
          fill_bits_hsv(H,bits_hsv,4);
          hBitmap_hsv=CreateBitmapIndirect(&amp;bitmap_hsv);
          if (!hBitmap_hsv)
          {
              err=GetLastError();
              return 0;//I STOP CODE HERE TO SEE err=0;
          }
          SelectObject(hDC_compat,hBitmap_hsv);
          BitBlt(hDC,0,0,255,255,hDC_compat,10,10,SRCCOPY);
  
          drawCursor(pt.x,pt.y,hDC);
          ReleaseDC(hDlg,hDC);
      }
      return 0;
  </code></pre>
  
  <p>It works ok for 40 or 50 first calls, but then all the window lags and looses DC, I can move the window, but the area is not refreshing. My stop mark shows the problem with 
  hBitmap=CreateBitmapIndirect(...) which shows 0x00000000 and GetLastError shows 0; </p>
  
  <p>And now the main question what am I doing wrong? </p>