If you are using the high-level LBitmapWindow (or derived) class, zooming in on a selection is done automatically for you when you set the tool to TOOL_ZOOMRECT using LBitmapWindow::SetToolType. The class object will automatically handle the mouse events for you, and adjust the bitmap's display rectangles in order to zoom in on the user-defined rectangle.
If you are not using LBitmapWindow, this topic describes how to let the user select an area with a mouse and zoom in on the selected area. In this topic, you learn the following:
How to use the source rectangle with the LPaint::PaintDC function.
How to translate client area coordinates to bitmap coordinates, while accounting for differences in view perspective. For general information about view perspectives, refer to Accounting for View Perspective.
Add this code to load an image and initialize the display rectangles.
Add these global variables for tracking coordinates to your program.
Add this 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.
Add this code to process WM_MOUSEMOVE messages. This code outlines the selection using GDI functions.
Add this code to process WM_LBUTTONUP messages. This code defines the source and destination rectangles for painting, and forces a repaint (CalcDisplay is defined below).
Add this code to process WM_RBUTTONDOWN messages. This code returns to the display of the full image when the user clicks the right mouse button.
Add this code to process WM_PAINT messages. This code sets the bitmap rectangles and paints the image.
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries