SetCtrlBitmap
int SetCtrlBitmap (int panelHandle, int controlID, int imageID, int bitmapID);
Purpose
Sets a bitmap object image in a control. You can use this function to replace an existing image in a control, create a new image in a control, or delete an image in a control. To delete an image, call SetCtrlBitmap with 0 as the value for the bitmap ID.
![]() |
Note LabWindows/CVI displays images in the tree and tab controls at 16 x 16 pixels, regardless of the original size of the image. |
You can obtain the ID of the bitmap object from functions such as NewBitmapEx and GetCtrlBitmap.
For picture controls, you can use this function instead of DisplayImageFile.
For picture buttons, you can use this function instead of calling SetCtrlAttribute with the ATTR_IMAGE_FILE attribute.
For picture rings, you can use this function instead of ReplaceListItem. To add a new entry, first call InsertListItem with a NULL value and then call SetCtrlBitmap.
For graphs, you must first call PlotBitmap with a NULL filename. Then call SetCtrlBitmap.
When you use SetCtrlBitmap to change the bitmap object that is assigned to a tree control image index, LabWindows/CVI updates all of the tree control items that use that index.
Supported Controls
You can use SetCtrlBitmap with the following controls:
Parameters
Input | ||
Name | Type | Description |
panelHandle | int | Specifier for a particular panel that is currently in memory. You can obtain this handle from functions such as LoadPanel and NewPanel. |
controlID | int | The defined constant, located in the .uir header file, that you assigned to the control in the User Interface Editor, or the ID returned by functions such as NewCtrl and DuplicateCtrl. |
imageID | int | For picture rings, the zero-based index of an image in the ring. For graphs, the plot handle you obtain from PlotBitmap. For tree controls, the image index you obtain from AddTreeImage. For picture controls and picture buttons, this parameter is ignored. For tab controls, the zero-based index of the tab page that contains the image. |
bitmapID | int | ID of the bitmap object that contains the image. You can obtain the ID from functions such as NewBitmapEx and GetCtrlBitmap. |
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. A negative number indicates that an error occurred. |
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later
Example
Refer to userint\imagedit.cws for an example of using the SetCtrlBitmap function.