From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
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.
f = FolderItem.ShowOpenFileDialog(FileTypes1.All)
If f <> Nil Then
ImageViewer1.Image = Picture.Open(f)
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:
If obj.PictureAvailable then
Me.Image = obj.Picture
ElseIf obj.FolderItemAvailable Then
Me.Image = Picture.Open(obj.FolderItem)
The MouseDown event uses the DragItem constructor. It is: