This topic contains the following sections.
The Cognex Tool Display control displays images, graphics, and other state information associated with a vision tool's records. It uses the CogRecord and the tool's ICogTool interface to connect images and graphics to a CogDisplay.
The following figure shows the Tool Display control showing a current InputImage:

The following figure shows the Tool Display control showing a Blob tool's last run image with graphics:

The control's CogComboBox lists the images and graphics from the current record and its subrecords. You can click on the list and select which image or graphic to display. If the record hierarchy contains only one image, the CogComboBox is disabled, but displays the images name. If no images are available, the CogComboBox is empty and disabled. The list of images and graphics is refreshed whenever a new Subject record is set or the tool's inspection records change.
The CogDisplay area of the control displays the currently selected image and its associated graphics. You manipulate this display as you would a CogDisplay control.
The Tool Display control has the following properties, methods, and events:
| Property | Description |
| SelectedRecordKey | Returns the key of the currently-selected inspection record, or selects a different record using the given key string. When you change the SelectedRecordKey property, it fires a RecordChange event. |
| Subject | Returns or sets a reference to the top-level CogRecord object for the set of inspection records to display. If you set the Tool property to a specific vision tool, the Subject is automatically set. Otherwise, you must set Subject to a specific CogRecord object. You can also set Subject to NULL to disconnect the Tool Display control from the inspection records. Whenever you set this property, the control's list of inspection records and displayable images is updated. |
| Tool | Returns or sets a reference to the VisionPro tool associated with this Tool Display control. If the Tool property is set, the control obtains its Subject inspection record automatically from the tool using its CreateCurrentRecord and CreateLastRunRecord methods. If you do not set the Tool property, you must set the control's Subject property to a specific CogRecord object. |
| Method | Description |
| Refresh | Updates the control's list of images and graphics that are contained in the current inspection record. |
| Event | Description |
| RecordChange | Fires when the selected inspection record changes. |
You can use the Cognex Tool Display control in either of two modes:
- automatic mode
- manual mode
The next section describes how to use each of these modes.
In automatic mode, you set the control's Tool property to the vision tool for which you want to display record information. The control obtains CogRecord objects from the tool's CreateCurrentRecord and CreateLastRunRecord methods, and uses the record to set its Subject property. Whenever the tool fires a Changed event, indicating that its inspection records have changed, the control obtains new records, and automatically displays the record information. For example, if you call the tool's Run or Train methods, the control displays the new record information. The following code shows how to use the Tool Display control in automatic mode.
CogToolDisplay mToolDisplay = new CogToolDisplay(); mToolDisplay.Tool = myVisionTool;
In manual mode, you set the control's Subject property to the specific CogRecord object that contains the hierarchy of tool information to display. Manual mode is suitable for applications in which a record is generated by your custom code. The underlying CogRecords will typically be generated by vision tools, but the top-level record need not be. In order to display new record information, you must programmatically set theSubject property to a new CogRecord. The following code shows how to use the Tool Display control in manual mode.
Dim LastRunRecord As CogRecord Set LastRunRecord = myVisionTool.CreateLastRunRecord Dim InputImageRecord As CogRecord Set InputImageRecord = LastRunRecord("InputImage") Set ToolDisplay.Subject = InputImageRecord