DesktopImageViewer

From Xojo Documentation

Class (inherits from DesktopUIControl)


New in 2021r3

Used to display an image in a window.

Events
Closing FocusLost MouseExit
ConstructContextualMenu FocusReceived MouseMove
ContextualMenuItemSelected KeyDown MouseUp
DragEnter KeyUp MouseWheel
DragExit MouseDown Opening
DragOver MouseDrag
DropObject MouseEnter


Properties
Active fa-lock-32.png LockBottom TabIndex
AllowAutoDeactivate LockLeft Tooltip
AllowTabStop LockRight Top
Enabled LockTop Transparent
Handle fa-lock-32.png MouseCursor Visible
Height Name fa-lock-32.png Width
Image PanelIndex Window fa-lock-32.png
Index fa-lock-32.png Parent
Left Scope fa-lock-32.png

Notes

Refer to the Picture class to see what image formats are supported for each platform.

Examples

The following line of code in the Opening event of a DesktopImageViewer displays a picture of a prancing stallion. The image had been added to the Project Editor.

Me.Image = Ferrari

The following example implements drag and drop between two DesktopImageViewers, 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.

Me.AcceptPictureDrop
Me.AcceptFileDrop("image/jpeg")

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
d.Drag
Return True // Allow the drag

See Also

DesktopUIControl class; DesktopCanvas control.