zoukankan      html  css  js  c++  java
  • HSmartWindowControl实现鼠标滚动缩放图像

    HSmartWindowControl对比HWindowControl的优越性在于内部已经实现好了图像的拖拽缩放,拖拽功能是不需要改什么就能实现的,根据官方文档,缩放功能需要做一些处理。
    参考官方文档11.5章Visualization,20.05版本下,官方文档所在目录为:安装目录/MVTec/HALCON-20.05-Progress/doc/html/manuals/programmers_guide/programmers_guide_0059.html
    为了方便在winform程序中的使用,将该控件加上了缩放事件封装成了一个用户控件,在此做记录:

    internal class SmartWindowControl : HSmartWindowControl
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            MouseWheel += SmartWindowControl_MouseWheel;
        }
    
        private void SmartWindowControl_MouseWheel(object sender, MouseEventArgs e)
        {
            MouseEventArgs newe = new MouseEventArgs(e.Button, e.Clicks, e.X - Location.X, e.Y - Location.Y, e.Delta);
            HSmartWindowControl_MouseWheel(sender, newe);
        }
    }
    

    编译之后可以直接在工具箱中看到这个控件,使用的时候可以直接拖拽到窗口中。

    • 在拖拽过程中遇到错误:未能加载工具箱项xxx,将从工具箱中移除
      在网上查找了这个问题的解决方法,有人说将项目从x64改成x86,这个是显然不适用于我的情况的,我的程序需要是64位的,尝试了一下将x64改成了AnyCPU(未选中首选32位),问题解决。
  • 相关阅读:
    Python中的memoryview
    Python常见陷阱
    特殊方法 之 len __repr__ __str__
    collections模块
    使用math中的hypot实现向量
    Ellipsis对象
    array
    标准库heapq的使用
    Mysql常用命令
    使用npm查看安装的包
  • 原文地址:https://www.cnblogs.com/yutou2016/p/13606067.html
Copyright © 2011-2022 走看看