Implementing Scrollbars: Step 5

In the Window_OnCreate 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.

BOOL Window_OnCreate (HWND hWnd, CREATESTRUCT * lpCreateStruct) 
{ 
   L_INT nRet; 
   UNREFERENCED_PARAMETER (lpCreateStruct); 
   /* Let Window_OnPaint know to start a timer. */ 
   bFirst = TRUE; 
   /* Initialize the bitmap to 24-bits. */ 
   L_InitBitmap (&Data.BitmapHandle, sizeof(BITMAPHANDLE), Data.FileInfo.Width, 
   Data.FileInfo.Height, 24); 
   /* Load the image to the bitmap. */ 
   nRet = L_LoadBitmap (Data.szFilename, &Data.BitmapHandle, sizeof(BITMAPHANDLE), 
   0, ORDER_BGR, NULL, &Data.FileInfo); 
   if (nRet != SUCCESS) 
   { 
      L_TCHAR buf[1024];           /* Buffer to hold the error message. */ 
      wsprintf (buf, TEXT("Error %d Loading %s"), nRet, (LPTSTR) Data.szFilename); 
      MessageBox (hWnd, buf, TEXT("Error"), MB_OK); 
      return (FALSE);           /* Failure in creation, so return FALSE. */ 
   } 
   /* Set the display width and height variables to be the same as the bitmap, with proper orientation */ 
   DisplayWidth = BITMAPWIDTH(&Data.BitmapHandle); 
   DisplayHeight = BITMAPHEIGHT(&Data.BitmapHandle); 
   /* Set the destination rectangle to use the whole bitmap */ 
   SetRect(&rLeadDest, 0, 0, DisplayWidth, DisplayHeight); 
   /* Set the source rectangle to use the whole bitmap */ 
   SetRect(&rLeadSource, 0, 0, DisplayWidth, DisplayHeight); 
   /* Force paint palette creation */ 
   FORWARD_WM_QUERYNEWPALETTE (hWnd, SendMessage); 
   return (TRUE); 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help