---
title: "PictureBox (Generic)"
canonical: "https://docs.cuesystem.com/space/CVCGC/420380694/PictureBox%20(Generic)"
format: markdown
---
> Macro (toc)

---

# Description

The PictureBox displays any picture stored in project resources. Picture can be fitted using one of the following method.

|  |  |
| --- | --- |
| ![image](media://f3dee635-8d35-42b7-bb03-096e905cdb6e) | None - places picture to left top corner of the object. The picture’s and objects’s dimensions are not changed. Some of the picture parts can be cropped by the bounding of the object. |
| ![image](media://2a0529ed-698e-4928-bae8-b0f90f4166aa) | Fit Object to Content - resizes an object to fit picture. The object’s proportions are altered to match the picture proportions, if necessary. |
| ![image](media://9f592885-d89f-4ba9-84eb-2fbaa817a0aa) | Fit Content to Object - resizes picture to fit an object and allows the picture proportions to be changed. |
| ![image](media://01425835-77d9-428d-a2cc-3d1de5c56275) | Center Content - centres picture to an object. The picture’s and objects’s dimensions are not changed. Some of the picture parts can be cropped by the bounding of the object. |
| ![image](media://cf8d9a3d-b2be-46e8-8b6d-6c19bb4440dc) | Fit Content Proportionally - resizes picture to fit an object while preserving the picture proportions. The objects’s dimensions are not changed. If the picture and the object have different proportions, some empty space will result. |
| ![image](media://a4c72925-342c-4996-b371-e353b34b9ce1) | Fill Object Proportionally - resizes picture to fill the entire object while preserving the picture’s proportions. The object’s dimensions are not changed. If the picture and the object have different proportions, some of the picture parts will be cropped by the bounding of the object. |

# Properties

|  |  |  |  |  |
| --- | --- | --- | --- | --- |
| Property Name | Data Type | Allowed Values | Default Value | Description |
| Behavior |
| Events | Boolean | True False | False | If True event OnTouch is enabled. If False event OnTouch is disabled. |
| Appearance |
| Align | Long | Left-Top   
Left-Middle   
Left-Bottom   
Center-Top  
Center-Middle   
Center-Bottom   
Right-Top   
Right-Middle  
Right-Bottom | Center-Middle | Horizontal and vertical align of picture. |
| Fitting | Long | 0 = None  
1 = Fit Object to Content   
2 = Fit Content to Object   
3 = Center Content  
4 = Fit Content Proportionally  
5 = Fill Object Proportionally | 0 | Method of picture fitting |
| Picture | AddressOf _Picture | Any | Nothing | Picture placed as content. |
| PictureOffsetX | Long | Any | 0 | Horizontal offset of picture in pixels. |
| PictureOffsetY | Long | Any | 0 | Vertical offset of picture in pixels. |

# Functions

## SetAlign

This function sets Align of Picture. You can use meaningful BitOr combinations of the following constants as parameters

- _TEXT_ALIGNLEFT, _TEXT_ALIGNHCENTER, _TEXT_ALIGNRIGHT
- _TEXT_ALIGNTOP, _TEXT_ALIGNVCENTER, _TEXT_ALIGNBOTTOM

The function returns True on success or False if an error occurs.

#### Syntax

```visualbasic
Function SetAlign(newalign As Long) As Boolean
```

## GetAlign

This function returns current Align of Picture.

#### Syntax

```visualbasic
Function GetAlign() As Long
```

## SetEvents

This function enables (newevents = True) or disables (newevents = False) event OnTouch. Function returns True.

#### Syntax

```visualbasic
Function SetEvents(newevents As Boolean) As Boolean
```

## GetEvents

This function returns True (event OnTouch enabled) or False (event OnTouch disabled).

#### Syntax

```visualbasic
Function GetEvents() As Boolean
```

## SetFitting

This function sets Fitting of Picture to newfitting. You can use following predefined constants for fitting

- FITTING_NONE
- FITTING_FIT_OBJECT_TO_CONTENT
- FITTING_FIT_CONTENT_TO_OBJECT
- FITTING_CENTER_CONTENT
- FITTING_FIT_CONTENT_PROPORTIONALLY
- FITTING_FILL_OBJECT_PROPORTIONALLY

For example, if instance of PictureBox is named PictureBox1, you can use as parameter PictureBox1.FITTING_FIT_CONTENT_PROPORTIONALLY to fit content proportionally.

Function returns True on success or False if an error occurs (parameter has wrong value).

#### Syntax

```visualbasic
Function SetFitting(newfitting As Long) As Boolean
```

## GetFitting

This function returns current Fitting.

#### Syntax

```visualbasic
Function GetFitting() As Long
```

## SetPicture

This function sets Picture to newpicture. Function returns True.

#### Syntax

```visualbasic
Function SetPicture(newpicture As AddressOf _Picture) As Boolean
```

## GetPicture

This function returns current Picture.

#### Syntax

```visualbasic
Function GetPicture() As AddressOf _Picture
```

## GetPictureHeight

This function returns current PictureHeight. Return value depends on ObjectHeight and Fitting method.

#### Syntax

```visualbasic
Function GetPictureHeight() As Long
```

## GetPictureWidth

This function returns current PictureWidth. Return value depends on ObjectWidth and Fitting method.

#### Syntax

```visualbasic
Function GetPictureWidth() As Long
```

## SetPictureOffsetX

This function sets PictureOffsetX to newpictureoffsetx. Function returns True.

#### Syntax

```visualbasic
Function SetPictureOffsetX(newpictureoffsetx As Long) As Boolean
```

## GetPictureOffsetX

This function returns current PictureOffsetX.

#### Syntax

```visualbasic
Function GetPictureOffsetX() As Long
```

## SetPictureOffsetY

This function sets PictureOffsetY to newpictureoffsety. Function returns True.

#### Syntax

```visualbasic
Function SetPictureOffsetY(newpictureoffsety As Long) As Boolean
```

## GetPictureOffsetY

This function returns current PictureOffsetY.

#### Syntax

```visualbasic
Function GetPictureOffsetY() As Long
```

## BringToFrontZOrder

This function temporarily brings the object to the very top position.

#### Syntax

```visualbasic
Function BringToFrontZOrder()
```

## RestoreZOrder

This function restores object’s z-order to value defined in design mode.

#### Syntax

```visualbasic
Function RestoreZOrder()
```

# Events

## OnTouch

This event is generated when the object is touched and property Events is set to True.

#### Syntax

```visualbasic
Event OnTouch As Process()
```