The rightmost parameters are for the source which is probably the original (not zoomed image). So you have to calculate the destination parameters (the left most ones).
To support zoom in/out you must track the actual zoom factor in a variable that is initialised with 1. Then adjust this upon the event:
if (zDelta > 0)
m_zoomFactor *= ZOOMFACTOR;
else
m_zoomFactor /= ZOOMFACTOR;
Then multiply the original dimensions with the factor to get the zoomed dimensions (
rcSrc
is here the size of the original bitmap):
int zoomWidth = (int)(0.5 + rcSrc.Width() * m_zoomFactor);
int zoomHeight = (int)(0.5 + rcSrc.Height() * m_zoomFactor);
Assuming the mouse position indicates the center of the zoomed image, the left and top positions can be retrieved by subtracting half the width resp. the height:
int left = x - zoomWidth / 2;
int right = y - zoomHeight / 2;
However, it may be necessary to track the center positions for the previous zoom state too to adjust these.
The final
StretchBlt
call should be:
myDC->StretchBlt(left, right, zoomWidth, zoomHeight,
&dcPaintBitmap,
0, 0, rcSrc.Width(), rcSrc.Height(),
SRCCOPY);
Note that I have not tested this.