我按照章柯渊博客的设置报错了,应该是下面这里的问题:
他可能在前面定义了 HWND hWnd;
下面讲一下我的做法
首先参照这个帖子把项目配置好: http://www.ihalcon.com/read-1357.html
添加picture control ,和两个button按钮,命名为“读取图像”和“处理图像”
在“打开图像”里面添加如下代码
复制代码
并且把open_window函数改成如下代码
复制代码
复制代码
![点击查看原图](https://i-blog.csdnimg.cn/blog_migrate/8f97311ee272a524e63e10eff4448908.bmp)
他可能在前面定义了 HWND hWnd;
下面讲一下我的做法
首先参照这个帖子把项目配置好: http://www.ihalcon.com/read-1357.html
![点击查看原图](https://i-blog.csdnimg.cn/blog_migrate/991ec7a582012bc2b7bbd7b0ad802069.bmp)
添加picture control ,和两个button按钮,命名为“读取图像”和“处理图像”
![点击查看原图](https://i-blog.csdnimg.cn/blog_migrate/5e670c858d69314878a5755a48f090ef.jpeg)
在“打开图像”里面添加如下代码
复制代码
1
2
3
|
CRect rtWindow1;
GetDlgItem(IDC_DISPIMAGE)->GetClientRect(&rtWindow1);//IDC_DISPIMAGE为第一个图像控件的ID号,第二个窗口类似处理。
HWND hImgWnd= GetDlgItem(IDC_DISPIMAGE)->m_hWnd;
|
复制代码
1
|
open_window(rtWindow1.left, rtWindow1.top, rtWindow1.Width(), rtWindow1.Height(), (Hlong)hImgWnd, "visible", "", &WindowHandle); HDevWindowStack::Push(WindowHandle);
|
![点击查看原图](https://i-blog.csdnimg.cn/blog_migrate/c93a92919bd151a9b40b343b3816b86b.jpeg)
然后在“处理图像”里面添加如下代码
复制代码
1
2
3
4
|
CRect rtWindow2;
GetDlgItem(IDC_STATIC)->GetClientRect(&rtWindow2);//IDC_DISPIMAGE为第一个图像控件的ID号,第二个窗口类似处理。
HWND hImgWnd= GetDlgItem(IDC_STATIC)->m_hWnd;
open_window(rtWindow2.left, rtWindow2.top, rtWindow2.Width(), rtWindow2.Height(), (Hlong)hImgWnd, "visible", "", &WindowHandle); HDevWindowStack::Push(WindowHandle);
|
![点击查看原图](https://i-blog.csdnimg.cn/blog_migrate/a65997dda5a1e7cd39834fa60c72b3b0.jpeg)
运行之后
图片:5.jpg
![点击查看原图](https://i-blog.csdnimg.cn/blog_migrate/e9eab35d92427bde1fe20c60c82fcc82.jpeg)