Form1.cs
using HalconDotNet;
using System;
using System.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
HObject ho_Image = null;
HTuple hv_AcqHandle = null, hv_width, hv_height;
private void button1_Click(object sender, EventArgs e)
{
HOperatorSet.GenEmptyObj(out ho_Image);
HOperatorSet.ReadImage(out ho_Image, "computer.png");
HOperatorSet.GetImageSize(ho_Image, out hv_width, out hv_height);
HOperatorSet.SetPart(hSmartWindowControl1.HalconWindow, 0, 0, hv_height - 1, hv_width - 1);
HOperatorSet.DispObj(ho_Image, hSmartWindowControl1.HalconWindow);
}
public Form1()
{
InitializeComponent();
}
public void Form1_MouseWheel1(object sender, MouseEventArgs e)
{
System.Drawing.Rectangle rect = hSmartWindowControl1.RectangleToScreen(hSmartWindowControl1.ClientRectangle);
if (rect.Contains(Cursor.Position))
{
hSmartWindowControl1.HSmartWindowControl_MouseWheel(sender, e);
}
}
private void hSmartWindowControl1_Load(object sender, EventArgs e)
{
}
}
}
Form.Designer.cs添加
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseWheel1);