开始
以前用的是HWindowControl控件,显示的平移缩放都是自己处理。听说过HSmartWindowControl控件,有空看了一下,觉得比HWindowControl简单,而且AttachDrawingObjectToWindow功能不错,halcon自己维护了HDrawingObject对象,可以用鼠标移动和调整不需要写代码重绘,省心。
一,鼠标定点缩放
1,在Form上加入HSmartWindowControl控件
2,手动加上Form的滚轮处理
public Form1()
{
...
MouseWheel += Form1_MouseWheel;
...
}
//
public void Form1_MouseWheel(object sender, MouseEventArgs e)
{
//HSmartWindowControl控件的区域
Rectangle rect = hSmartWindowControl1.RectangleToScreen(hSmartWindowControl1.ClientRectangle);
//滚动时,鼠标悬停在在HSmartWindowControl控件上
if (rect.Contains(Cursor.Position))
{
//缩放
hSmartWindowControl1.HSmartWindowControl_MouseWheel(sender, e);
}
}
//显示原图
private void buttonRefresh_Click(object sender, EventArgs {
if (image != null)
{
HOperatorSet.GetImageSize(image, out HTuple Width, out HTuple Height);

最低0.47元/天 解锁文章
466

被折叠的 条评论
为什么被折叠?



