Click here to Skip to main content
15,905,232 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I am new to mfc can any one tell me how to add zoom in and zoom out feature in mfc??
thanx
Posted
Comments
Richard MacCutchan 23-May-13 3:38am    
You need to give a lot more detail about what you are trying to zoom.
Cool Dude-P 24-May-13 9:19am    
i want panning and zooming image in mfc...pls give me any hint how to do it
Richard MacCutchan 24-May-13 9:32am    
Take a look at the CDC::StretchBlt and CDC::BitBlt functions.
Santhosh G_ 23-May-13 11:41am    
Do you want to zoom controls in the dialog? Or do you need to zoom some bitmaps or image ?
Cool Dude-P 24-May-13 9:19am    
i want panning and zooming image in mfc...pls give me any hint how to do it

1 solution

Please use StretchBlt function to create zoomed effect.

BOOL StretchBlt(
  HDC hdcDest,      // handle to destination DC
  int nXOriginDest, // x-coord of destination upper-left corner
  int nYOriginDest, // y-coord of destination upper-left corner
  int nWidthDest,   // width of destination rectangle
  int nHeightDest,  // height of destination rectangle
  HDC hdcSrc,       // handle to source DC
  int nXOriginSrc,  // x-coord of source upper-left corner
  int nYOriginSrc,  // y-coord of source upper-left corner
  int nWidthSrc,    // width of source rectangle
  int nHeightSrc,   // height of source rectangle
  DWORD dwRop       // raster operation code
);


Change nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc to according to zoom and Pan.
Changing nXOriginSrc, nYOriginSrc will provide pan effect. Changing nWidthSrc, nHeightSrc will provide Zoom/Unzoom effect.

The following article might help you to create a zoom/pan effect of your bitmap.

CZoomCtrl: A Picture Control with Zooming and Scrolling[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900