title: Displaying a bitmap on a "BUTTON" class window in WIN32
body: <p><em><strong>Edit:</strong> I think the WM_CREATE message isn't sent during the creation of child windows (namely my button).  So by calling SendMessage during WM_CREATE, I'm sending a message to a window that hasn't been created yet.  The solution for now is to call SendMessage() during the WM_SHOWWINDOW message. Do child windows send WM_CREATE messages at creation?</em> </p>
  
  <p>Why isn't the bitmap displaying on the button?  The bitmap is 180x180 pixels.</p>
  
  <p>I have a resource file with: </p>
  
  <pre><code>Bit BITMAP bit.bmp
  </code></pre>
  
  <p>I then create the main window and a child "BUTTON" window with: </p>
  
  <pre><code>HWND b, d;
  
  b = CreateWindow(L"a", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, 0, 0, 
                    hInstance, 0);
  
  d = CreateWindow(L"BUTTON", NULL, WS_CHILD | WS_VISIBLE | BS_BITMAP, 
                   10, 10, 180, 180, b, 200, hInstance, 0);
  </code></pre>
  
  <p>Then, in my windows procedure, I send the "BUTTON" window the "BM_SETIMAGE" message with:</p>
  
  <pre><code>HBITMAP hbit; 
  
  case WM_CREATE:    // It works if I change this to: case WM_SHOWWINDOW 
  
  hbit = LoadBitmap(hInstance, L"Bit");
  
  SendMessage(d, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbit);
  </code></pre>
  
  <p>LoadBitmap() is returning a valid handle because It isn't returning NULL, and I'm able to display the bitmap in the client area using the BitBlt() function.  So I'm either not sending the message correctly, or I'm not creating the "BUTTON" window correctly.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks!</p>