In the MainWndProc function, add code to process WM_LBUTTONUP messages. This code defines the source and destination rectangles for painting, and forces a repaint. The code should appear as follows:
case WM_LBUTTONUP:
EndGDIX = LOWORD(lParam);
EndGDIY = 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. */
EndPixelX = MulDiv(BITMAPWIDTH(&LeadBitmap), EndGDIX - rLeadDest.left, DisplayWidth);
EndPixelY = MulDiv(BITMAPHEIGHT(&LeadBitmap), EndGDIY - rLeadDest.top, DisplayHeight);
/* Do nothing if no area is defined */
if ((EndPixelX == StartPixelX) || (EndPixelY == StartPixelY))
return (0);
/* Get the source rectangle coordinates for painting.
Allow for different mouse drag directions */
if (StartGDIX < EndGDIX)
{
rLeadSource.left = StartPixelX;
rLeadSource.right = EndPixelX;
}
else
{
rLeadSource.left = EndPixelX;
rLeadSource.right = StartPixelX;
}
if (StartGDIY < EndGDIY)
{
rLeadSource.top = StartPixelY;
rLeadSource.bottom = EndPixelY;
}
else
{
rLeadSource.top = EndPixelY;
rLeadSource.bottom = StartPixelY;
}
/* Use this local function (described in Fitting an Image to a Window) to
center the cropped display in the client area. */
CalcDisplay (rClientSize.right, /* Width allowed */
rClientSize.bottom, /* Height allowed */
rLeadSource.right - rLeadSource.left, /* Width factor, for aspect ratio */
rLeadSource.bottom - rLeadSource.top, /* Height factor, for aspect ratio */
&DisplayTop, /* Resulting top value, for centering */
&DisplayLeft, /* Resulting left value, for centering */
&DisplayWidth, /* Resulting width value */
&DisplayHeight); /* Resulting height value */
/* Set the destination rectangle for painting */
SetRect(&rLeadDest, DisplayLeft, DisplayTop,
DisplayLeft + DisplayWidth, DisplayTop + DisplayHeight);
/* If necessary, translate the source rectangle to the bitmap's view perspective */
if (LeadBitmap.ViewPerspective != TOP_LEFT)
L_RectToBitmap(&LeadBitmap, TOP_LEFT, &rLeadSource);
/* Repaint the whole client area */
InvalidateRect(hWnd,NULL,TRUE);
return (0);
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.