设置首页收藏本站
12
返回列表 发新帖
开启左侧

send_mouse_down_event,send_mouse_up_event等如何使用?

[复制链接]
sefule 发表于 2025-3-10 21:00:28 | 显示全部楼层
使用上面的方法,出现矩形框位置移动问题,修改了一下:
[DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
private void HWindowControl1_MouseUP(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                mouse_event(0x8 | 0x10, 0, 0, 0, 0);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                hWindowControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.HWindowControl1_MouseUP);
                hWindowControl1.Focus();
                HOperatorSet.DrawRectangle1(hWindowControl1.HalconWindow, out ht_RectRow1, out ht_RectRow2, out ht_RectCol1, out ht_RectCol2);
                HalconDotNet.HObject ho_RectRegion;
                HalconDotNet.HOperatorSet.GenRectangle1(
                    out ho_RectRegion,  
                    ht_RectRow1, ht_RectRow2, ht_RectCol1, ht_RectCol2);
                HObject regionContour;
                HOperatorSet.GenContourRegionXld(ho_RectRegion, out regionContour, "border");
                HalconDotNet.HOperatorSet.DispObj(regionContour, hWindowControl1.HalconWindow);
                hWindowControl1.MouseUp -= new System.Windows.Forms.MouseEventHandler(this.HWindowControl1_MouseUP);


            }
            catch (Exception)
            {
            }
        }
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表