From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As Picture )
aDesktopImageViewer.Image = newPictureValue
PictureValue = aDesktopImageViewer.Image

New in 2021r3

Supported for all project types and targets.

The picture displayed in the DesktopImageViewer. If you add the picture to the Project Editor, it will be listed in the drop-down menu in the Properties pane.


The following example displays an open-file dialog box that allows the user to choose a JPEG, or PNG file and display it in an DesktopImageViewer. It is assumed that the file types used as parameters passed to FolderItem.ShowOpenFileDialog have been assigned in the File Type Sets Editor or with the FileType class via the language.

Var f As FolderItem
f = FolderItem.ShowOpenFileDialog(FileTypes1.All)
If f <> Nil Then
ImageViewer1.Image = Picture.Open(f)
End If

Drag and Drop

The following example implements drag and drop between two ImageWells, a jpeg file dragged from the desktop to either DesktopImageViewer, and from one DesktopImageViewer to the other.

In the Opening event handler of the DesktopImageViewers, the two statements tell the controls to accept either a dragged picture or a dragged file of type jpeg. The file type "image/jpeg" was defined previously in the File Type Sets Editor.


The DropObject event handler is:

Sub DropObject(obj As DragItem)
If obj.PictureAvailable then
Me.Image = obj.Picture
ElseIf obj.FolderItemAvailable Then
Me.Image = Picture.Open(obj.FolderItem)
End If
End Sub

The MouseDown event uses the DragItem constructor. It is:

Var d As DragItem
d = New DragItem(Self, Me.Left, Me.Top, Me.Width, Me.Height)
d.Picture = Me.Image
Return True // Allow the drag