Zooming In on a Selection: Step 4

In the MainWndProc function, add code to process WM_LBUTTONDOWN messages. This code initializes coordinates for defining two rectangles. One rectangle is relative to the client area and is used with the GDI functions to outline the selection. The other rectangle is relative to the bitmap and is used to zoom in by defining the source rectangle for painting. The code should appear as follows:

case WM_LBUTTONDOWN:   
   /* Save the starting position in screen pixels (used by GDI functions) */   
   StartGDIX = LOWORD(lParam);   
   StartGDIY = HIWORD(lParam); 
   /* Use the mouse position's percentage offsets in the image rectangle   
   to determine the pixel offsets in the bitmap.   
   Using percentages allows for the possibility that the image is zoomed. */     
   StartPixelX = MulDiv(BITMAPWIDTH(&LeadBitmap), StartGDIX - rLeadDest.left, DisplayWidth);   
   StartPixelY = MulDiv(BITMAPHEIGHT(&LeadBitmap), StartGDIY - rLeadDest.top, DisplayHeight); 
   /* Initialize a variable used when the WM_MOUSEMOVE event outlines the area */   
   FirstDraw = TRUE;   
   return (0); 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help