The FILEPREVIEW control
Published 17 JUN 2016 at 12:08:27AM
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: [caption id="attachment_1866" align="aligncenter" width="905"] Windows Explorer PowerPoint preview[/caption] 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
[caption id="attachment_1878" align="aligncenter" width="640"] FILEPREVIEW control example[/caption] 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).
Comments
At 17 JUN 2016 12:14AM Matt Crozier wrote:
bLen() - Nice!! :). Is that equivalent to to getByteSize()?
At 17 JUN 2016 12:20AM Captain C wrote:
Well spotted :) Yes it is - I got fed up typing GetByteSize ….