Implementing Scrollbars: Step 5

In the MainWndProc function, modify the WM_CREATE message processing so that the display rectangle does not fit the client area. To keep it simple, initialize the display rectangle to be the same size as the bitmap. In the WM_PAINT message processing, the L_PaintDC function uses rLeadDest as the display rectangle.

case WM_CREATE:
   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (szFilename, &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL);
   if (nRet != SUCCESS)
   {
      wsprintf (achBuff, TEXT("Error %d loading %s"), nRet, szFilename);
      MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
      /* We have an error, so post WM_DESTROY */
      PostMessage (hWnd, WM_DESTROY, 0, 0);
      return (FALSE);
   }
   /* Set the destination rectangle to use the whole bitmap */
   SetRect(&rLeadDest, 0, 0, LeadBitmap.Width, LeadBitmap.Height);
   /* Set the source rectangle to use the whole bitmap */
   SetRect(&rLeadSource, 0, 0, LeadBitmap.Width, LeadBitmap.Height);
   /* Set the display width and height variables to be the same as the bitmap, with proper orientation */
   DisplayWidth = BITMAPWIDTH(&LeadBitmap);
   DisplayHeight = BITMAPHEIGHT(&LeadBitmap);
   /* Force paint palette creation */
   SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);
   return (TRUE);