zoukankan      html  css  js  c++  java
  • MFC的PictureControl控件上展示Halcon的窗体

    自定义函数:id是MFC窗体上的PictureControl控件的ID,此函数返回halcon的HTuple类型。

    HTuple initPicControl(int id);

    HTuple CHalconMFC1219Dlg::initPicControl(int id)//初始化halcon窗体控件到pictureControl控件上
    {
        HTuple hWindow;
        CRect Rect;
        HWND hWnd = GetDlgItem(id)->GetSafeHwnd();//获取控件句柄
        ::GetWindowRect(hWnd, &Rect);//获取控件大小
        OpenWindow(0, 0, Rect.Width(), Rect.Height(), (Hlong)hWnd, "visible", "", &hWindow);
    
        return hWindow;
    }

    使用方法:以CHalconMFC1219Dlg工程为例

    1、复制粘贴上述代码到CHalconMFC1219Dlg.cpp中,作为类的成员函数。在头文件里添加一行代码

    HTuple hWindow;

    2、在OnInitDialog()函数中调用此函数。

    BOOL CHalconMFC1219Dlg::OnInitDialog()
    {
        CDialogEx::OnInitDialog();
    
        // 设置此对话框的图标。  当应用程序主窗口不是对话框时,框架将自动
        //  执行此操作
        SetIcon(m_hIcon, TRUE);            // 设置大图标
        SetIcon(m_hIcon, FALSE);        // 设置小图标
    
        // TODO:  在此添加额外的初始化代码
        hWindow=initPicControl(IDC_PictureControl);
    
        return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
    }

     按钮事件函数

    HImage Mandrill("monkey"); 
    Hlong width, height; 
    Mandrill.GetImageSize(&width, &height); 
    SetPart(hWindow,0,0,height-1,width-1); //图片适应窗体
    DispObj(Mandrill,hWindow); //显示在hWindow上
  • 相关阅读:
    FastAPI(5)- 查询参数 Query Parameters
    FastAPI(4)- 路径参数 Path Parameters
    FastAPI(3)- uvicorn.run()
    Python
    Python
    Python
    Python
    Python
    Python
    Python
  • 原文地址:https://www.cnblogs.com/xixixing/p/12068352.html
Copyright © 2011-2022 走看看