Welcome: Hunan Intelligent Applications Tecgnology CO.,ltd.-HNIAT.com
Language: Chinese ∷  English

Basic knowledge

HALCON window embedded in MFC

VC ++ / MFC is different from VB. Displaying pictures other than BMP format, such as JPG format, in MFC windows is very complicated. It cannot be displayed simply by the PICTURE CONTROL control. Of course, GDI + or other methods can be used. In the user interface of machine vision software, it is often necessary to draw some marks on the obtained images. For beginners of MFC, it takes a lot of time to learn and research. Usually we use HALCON combined with MFC to develop machine vision software. It is impossible to leave HALCON. So I wonder if HALCON itself has any methods for displaying pictures and drawing images. These methods and effects seem to be integrated with the software and windows written by MFC. One, in fact, does exist.

 

The author found the open_window method in the official PDF provided by HALCON, combined with the disp_obj method, it can display pictures and images, etc., and then only through these two methods, only a new window is generated on the MFC window. See Get upset. Here is the complete code:

 

#define dialogfirstx 320

#define dialogfirsty 220

#define picturex 280

#define picturey 210

 

// ...

 

Hlong lWWindowID, windowshandle;
 Hobject Image;

 

// ...


 :: set_window_attr ("border_width", 0);
  
  lWWindowID = (Hlong) m_hWnd;
  
  :: set_check ("~ father");
  :: open_window (dialogfirstx, dialogfirsty, picturex, picturey, lWWindowID, "visible", "", & windowshandle);
  :: set_check ("father");
  :: disp_obj (Image, windowshandle);


// ...

From the above code, the idea is to extract m_hWnd, which is the main window we wrote in MFC, and assign it to lWWindowID. When open_window (), use lWWindowID as the parent window of the window we want to open. OK. It can be seen that there is an additional method set_chech (). If you log out of this method, the program will fail. If you change lWWindowID to the default "root" or 0 of open_window (), you can display images and elements, but The display effect is as described at the beginning of this article, and a window separate from the main dialog box written by MFC is displayed for display.

 

disp_obj () can not only display pictures, we see that the object it displays is Hobject. The markers, elements of the image, areas after image processing, elements, and effects drawn by ourselves can be displayed by disp_obj (). So the requirements at the beginning of this article are well solved.

CONTACT US

Contact: Manager Xu

Phone: 13907330718

Tel: 0731-22222718

Email: hniatcom@163.com

Add: Room 603, 6th Floor, Shifting Room, No. 2, Orbit Zhigu, No. 79 Liancheng Road, Shifeng District, Zhuzhou City, Hunan Province

Scan the qr codeClose
the qr code