title: Display BMP using CreateWindow
body: <p>I want to display a logo at the top of the screen.  The logo is a bmp file.  I made an example program to show what happens in full working code:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;commctrl.h&gt;
  #include &lt;tchar.h&gt;
  #include "resource.h"
  
  LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
  
  char szClassName[] = "BmpTestApp";
  
  int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
  {
      HWND hwnd;
      MSG messages;
      WNDCLASSEX wincl;
  
      wincl.hInstance = hThisInstance;
      wincl.lpszClassName = szClassName;
      wincl.lpfnWndProc = WindowProcedure;
      wincl.style = CS_DBLCLKS;
      wincl.cbSize = sizeof(WNDCLASSEX);
  
      wincl.hIcon = NULL;
      wincl.hIconSm = NULL;
      wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
      wincl.lpszMenuName = NULL;
      wincl.cbClsExtra = 0;
      wincl.cbWndExtra = 0;
  
      wincl.hbrBackground = (HBRUSH)COLOR_WINDOW;
  
      if(!RegisterClassEx(&amp;wincl))
          return 0;
  
      DEVMODE display;
      EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &amp;display);
  
      hwnd = CreateWindowEx(WS_OVERLAPPED, szClassName, "Bitmap Display Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, HWND_DESKTOP, NULL, hThisInstance, NULL);
      ShowWindow(hwnd, nCmdShow);
  
      while(GetMessage(&amp;messages, NULL, 0, 0))
      {
          TranslateMessage(&amp;messages);
          DispatchMessage(&amp;messages);
      }
  
      return messages.wParam;
  }
  
  LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  {
      switch(message)
      {
          HWND logo;
          case WM_CREATE:
              RECT hwndRect;
              GetWindowRect(hwnd, &amp;hwndRect);
              int winWidth;
              int winHeight;
              winWidth = hwndRect.right - hwndRect.left;
              winHeight = hwndRect.bottom - hwndRect.top;
  
              HBITMAP logoImage;
              logoImage = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_LOGO), IMAGE_BITMAP, winWidth - 180, winHeight - 530, LR_DEFAULTCOLOR);
              logo = CreateWindow(WC_STATIC, NULL, SS_BITMAP | SS_CENTER | WS_CHILD | WS_VISIBLE, 0, 0, winWidth - 180, winHeight - 530, hwnd, NULL, NULL, NULL);
              SendMessage(logo, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)logoImage);
              break;
  
          case WM_DESTROY:
              PostQuitMessage(0);
              break;
  
          default:
              return DefWindowProc(hwnd, message, wParam, lParam);
      }
  
      return 0;
  }
  
  
  // resource.rc
  IDB_LOGO BITMAP "Logo.bmp"
  
  // resource.h
  #define IDB_LOGO 300
  </code></pre>
  
  <p>When I run my program, there is just a box the size of the image, but no image inside.  Logo.bmp is definately in the folder where my resource.rc file is and all the other project files.  Why is it not displaying?  Thanks.</p>