mfc显示bmp图片如何鼠标滚轮控制图片的放大缩小

你微笑時好美 2015-12-02 11:25:45
如图,这是我已经做好的功能,想添加一个功能,鼠标在图片上滚动滚轮,或者点击左右键能控制图片的放大缩小,应该怎么做呢,各位给点启发~~谢谢啦,如果有类似的教程最好了,我之前没接触过图片这类的东西,
...全文
409 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
向立天 2016-03-19
  • 打赏
  • 举报
回复
您好 我是本版版主 此帖已多日无人关注 请您及时结帖 如您认为问题没有解决可按无满意结帖处理 另外本版设置了疑难问题汇总帖 并已在版面置顶 相关规定其帖子中有说明 您可以根据规定提交您帖子的链接 如您目前不想结帖只需回帖说明 我们会删除此结帖通知 见此回复多日内无回应 我们将强制结帖 相关规定详见界面界面版关于版主结帖工作的具体办法
赵4老师 2015-12-02
  • 打赏
  • 举报
回复
CWnd::OnMouseWheel afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt ); Return Value Nonzero if mouse wheel scrolling is enabled; otherwise 0. Parameters nFlags Indicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL Set if the CTRL key is down. MK_LBUTTON Set if the left mouse button is down. MK_MBUTTON Set if the middle mouse button is down. MK_RBUTTON Set if the right mouse button is down. MK_SHIFT Set if the SHIFT key is down. zDelta Indicates distance rotated. The zDelta value is expressed in multiples or divisions of WHEEL_DELTA, which is 120. A value less than zero indicates rotating back (toward the user) while a value greater than zero indicates rotating forward (away from the user). The user can reverse this response by changing the Wheel setting in the mouse software. See the Remarks for more information about this parameter. pt Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window. Remarks The framework calls this member function as a user rotates the mouse wheel and encounters the wheel's next notch. Unless overridden, OnMouseWheel calls the default ofWM_MOUSEWHEEL. Windows automatically routes the message to the control or child window that has the focus. The Win32 functionDefWindowProc propagates the message up the parent chain to the window that processes it. The zDelta parameter is a multiple of WHEEL_DELTA, which is set at 120. This value is the threshold for an action to be taken, and one such action (for example, scrolling forward one notch) should occur for each delta. The delta was set to 120 to allow for future finer-resolution wheels, such as a freely-rotating wheel with no notches. Such a device might send more messages per rotation, but with a smaller value in each message. To support this possibility, either aggregate the incoming delta values until WHEEL_DELTA is reached (so you get the same response for a given delta-rotation), or scroll partial lines in response to the more frequent messages. You could also choose your scroll granularity and accumulate deltas until WHEEL_DELTA is reached. Override this member function to provide your own mouse-wheel scrolling behavior. Note OnMouseWheel handles messages for Windows NT 4.0. For Windows 95 or Windows NT 3.51 message handling, use OnRegisteredMouseWheel. CWnd Overview | Class Members | Hierarchy Chart See Also mouse_event
worldy 2015-12-02
  • 打赏
  • 举报
回复
设置一个比例系数r, 滚轮滚动改变r值, 加载图片到一个位图,选入到一个内存MemDC 绘画时,使用r值计算原图将显示的区域位置(x0,y0)和大小(w,h) 调用StretchBlt(hDC,x0,y0,w,h,MemDC,0,0,Wc,Hc,SRCCOPY)

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧