Create a virtual graphics window under Windows NT.
::new_extern_window opens a new virtual window. Virtual means that a new window will not be created, but the window whose Windows NT handle is given in the parameter WINHWnd is used to perform output of gray value data, regions, graphics as well as to perform textual output. Visualization parameters for the output of data can be done either using Halcon commands or by the appropriate Windows NT commands.
Example: setting of the drawing color:
Halcon: set_color(WindowHandle,"green"); disp_region(WindowHandle,region); Windows NT: HPEN* penold; HPEN penGreen = CreatePen(PS_SOLID,1,RGB(0,255,0)); pen = (HPEN*)SelectObject(WINHDC,penGreen); disp_region(WindowHandle,region);
Interactive operators, for example ::draw_region, ::draw_circle or ::get_mbutton cannot be used in this window. The following operators can be used:
Output of gray values: set_paint, set_comprise (set_lut and set_lut_style after output) Regions: set_color, set_rgb, set_hsi, set_gray, set_pixel, set_shape, set_line_width, set_insert, set_line_style, set_draw Image part: set_part Text: set_fontYou may query current set values by calling procedures like ::get_shape. As some parameters are specified through the hardware (Resolution/Colors), you may query current available resources by calling operators like ::query_color.
The parameter WINHWnd is used to pass the window handle of the Windows NT window, in which output should be done. The parameter WINHDC is used to pass the device context of the window WINHWnd. This device context is used in the output routines of Halcon.
The origin of the coordinate system of the window resides in the upper left corner (coordinates: (0,0)). The row index grows downward (maximum: Height-1), the column index grows to the right (maximal: Width-1).
You may use the value -1 for parameters Width and Height. This means, that the corresponding value is chosen automatically. In particular, this is important if the aspect ratio of the pixels is not 1.0 (see ::set_system). If one of the two parameters is set to -1, it will be chosen through the size which results out of the aspect ratio of the pixels. If both parameters are set to -1, they will be set to the current image format.
The position and size of a window may change during runtime of a program. This may be achieved by calling ::set_window_extents, but also through external influences (window manager). For the latter case the procedure ::set_window_extents is provided.
Opening a window causes the assignment of a default font. It is used in connection with procedures like ::write_string and you may change it by performing ::set_font after calling ::open_window. On the other hand, you have the possibility to specify a default font by calling ::set_system('default_font',<Fontname>) before opening a window (and all following windows; see also ::query_font).
You may set the color of graphics and font, which is used for output procedures like ::disp_region or ::disp_circle, by calling ::set_rgb, ::set_hsi, ::set_gray or ::set_pixel. Calling ::set_insert specifies how graphics is combined with the content of the image repeat memory. Thereto you may achieve by calling e.g. ::set_insert(::'not':) to eliminate the font after writing text twice at the same position.
The content of the window is not saved, if other windows overlap the window. This must be done in the program code that handles the Windows NT window in the calling program.
For graphical output (::disp_image,::disp_region, etc.) you may adjust the window by calling procedure ::set_part in order to represent a logical clipping of the image format. In particular this implies that only this part (appropriately scaled) of images and regions is displayed. Before you close your window, you have to close the Halcon-window.
Steps to use new_extern_window:
Creation: *Create a Windows-window. *Call new_extern_window with the WINHWnd of the above created window. Use: *Before drawing in the window you have to call the method set_window_dc. This ensures that the halcon drawing routines use the right DC. Before you release the DC you should call set_window_dc again. This time with the address of a long set to zero. This allows Halcon to delete the created graphic objects. Destroy: *Call close_window. This must be done before the Windows-window is closed.
Note that parameters as Row, Column, Width and Height are constrained through the output device, i.e., the size of the Windows NT desktop.
|
WINHWnd (input_control) |
integer -> HTuple.long |
| Windows windowhandle of a previously created window. | |
| Restriction: WINHWnd != 0 | |
|
WINHDC (input_control) |
integer -> HTuple.long |
| Device context of WINHWnd. | |
| Restriction: WINHDC != 0 | |
|
Row (input_control) |
rectangle.origin.y -> HTuple.long |
| Row coordinate of upper left corner. | |
| Default value: 0 | |
| Restriction: Row >= 0 | |
|
Column (input_control) |
rectangle.origin.x -> HTuple.long |
| Column coordinate of upper left corner. | |
| Default value: 0 | |
| Restriction: Column >= 0 | |
|
Width (input_control) |
rectangle.extent.x -> HTuple.long |
| Width of the window. | |
| Default value: 512 | |
| Restriction: (Width > 0) || (Width == -1) | |
|
Height (input_control) |
rectangle.extent.y -> HTuple.long |
| Height of the window. | |
| Default value: 512 | |
| Restriction: (Height > 0) || (Height == -1) | |
|
WindowHandle (output_control) |
window -> long * |
| Window identifier. | |
HTuple m_tHalconWindow ;
Hobject m_objImage ;
WM_CREATE:
/* here you should create your extern halcon window*/
HTuple tWnd, tDC ;
::set_check("~father") ;
tWnd = (INT)((INT*)&m_hWnd) ;
tDC = (INT)(INT*)GetWindowDC() ;
::new_extern_window(tWnd, tDC, 0, 0, sizeTotal.cx, sizeTotal.cy, &m_tHalconWindow) ;
::set_check("father") ;
WM_PAINT:
/* here you can draw halcon objects */
long l = 0 ;
if (m_thWindow != -1) {
/* donīt forget to set the dc !! */
HTuple tDC((INT)(INT*)&pDC->m_hDC) ;
HTuple tDCNull((INT)(INT*)&l) ;
::set_window_dc(m_tHalconWindow,tDC) ;
::disp_obj(pDoc->m_objImage, m_tHalconWindow) ;
/* release the graphic objects */
::set_window_dc(m_tHalconWindow, tDCNull) ;
}
WM_CLOSE:
/* close the halcon window */
if (m_tHalconWindow != -1) {
::close_window(m_tHalconWindow) ;
}
If the values of the specified parameters are correct ::new_extern_window returns H_MSG_TRUE. If necessary, an exception is raised.
::set_color, ::query_window_type, ::get_window_type, ::set_window_type, ::get_mposition, ::set_tposition, ::set_tshape, ::set_window_extents, ::get_window_extents, ::query_color, ::set_check, ::set_system
::open_window, ::open_textwindow
::open_window, ::disp_region, ::disp_image, ::disp_color, ::set_lut, ::query_color, ::set_color, ::set_rgb, ::set_hsi, ::set_pixel, ::set_gray, ::set_part, ::set_part_style, ::query_window_type, ::get_window_type, ::set_window_type, ::get_mposition, ::set_tposition, ::set_window_extents, ::get_window_extents, ::set_window_attr, ::set_check, ::set_system
System