One of the new controls added to version 10 is the FILEPREVIEW control, which taps into the Windows Shell interface to expose the same functionality provided by the Windows Explorer when previewing the contents of files, as per the example below:
Using the FILEPREVIEW control is quite easy – simply set the FILENAME property with the name and path of the file you want to preview, and if the OS has handlers installed for that file type then the control will render them.
Here’s an example of previewing a PowerPoint file:
fileName = get_Property( @window : ".EDL_FILENAME", "TEXT" ) if bLen( fileName ) then call set_Property_Only( @window : ".FPV_VIEWER", "FILENAME", | fileName ) end
The devil of course is in the details – your OS must have the correct handler DLLs installed for you to view the preview of the file, and this may rely on third party software being installed as well. For example, to preview Word and Excel documents you must have Office installed, to preview PDF files you must have something like Adobe Reader installed and so on. You can test for this at runtime by using the PREVIEWHANDLER method, which returns a GUID identifying the preview handler DLL if it is installed. You simply pass the extension you wish to look up and check for a returned GUID like so:
handlerGUID = exec_Method( previewCtrl, "PREVIEWHANDLER", "pdf" ) if bLen( handlerGUID ) then // We have a PDF preview viewer on the workstation ... call set_Property_Only( previewCtrl, "FILENAME", "c:\temp\test.pdf" ) end
The control also supports an ACTIVE property which returns TRUE$ if the control currently has a file loaded for previewing.
(Disclaimer: This article is based on preliminary information and may be subject to change in the final release version of OpenInsight 10).