title: Why does GetObject return an BITMAP with null bmBits?
body: <p>Context: I'm trying to take a screenshot of another window to feed it into OpenCV. I found some code on the web that should be able to convert a BITMAP to something OpenCV can work with. Unfortunately I ran into some trouble.</p>
  
  <p>Question: Why is the bmBits attribute/member always null? (I also tried with PrintWindow instead of BitBlt the result was the same)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;Windows.h&gt;
  
  int main(int argc, char* argv[])
  {
      std::wstring windowName = L"Calculator";
  
      RECT rect;
      HWND hwnd = FindWindow(NULL, windowName.c_str());
      if (hwnd == NULL)
      {
          return 0;
      }
      GetClientRect(hwnd, &amp;rect);
  
      HDC hdcScreen = GetDC(NULL);
      HDC hdc = CreateCompatibleDC(hdcScreen);
      HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen, 
          rect.right - rect.left, rect.bottom - rect.top);
      SelectObject(hdc, hbmp);
  
      PrintWindow(hwnd, hdc, PW_CLIENTONLY);
  
      BITMAP bmp;
      GetObject(hbmp, sizeof(BITMAP), &amp;bmp);
  
      return 0;
  }
  </code></pre>