File Viewers
In Application Center, we use the FileView
control to preview a file. Please do not confuse it with FilesView
, which is designed to display a list of files.
Of course, in FilesView
control you can double-click a file to open it in the designated external program. For instance, a .docx
file will launch in MS Word or OpenOffice, depending on what is installed on your system. But if you want to preview the file within Application Center, you must display it in FileView
control.
For the FileView
control to display a file, it must be able to recognize the file format. Therefore, you have to configure which file extension should be opened with which internal/external viewer. You can do that via Ststem Management→File Viewers
app (see the picture below).
Application Center comes with some built-in viewers:
- Built-in Image Viewer
- Built-in Web Browser Viewer
- Built-in Auto Cad Viewer (requires AutoCad installed on client PC)
- Built-in Open Office Viewer (requires OpenOffice installed on client PC)
- Built-in Fast Report (.fr3) Viewer
Depending which file format you want to display, you will select one of those mentioned above as viewer's Kind. For example, if you are trying to display an image, your best choice will be Built-in Image Viewer. Please note that the Built-in Image Viewer may not be able to display your image if it does not support the image format. Of course, that could happen only with certain exotic image formats, as the most common ones are supported.
Your second best choice is Built-in Web Browser Viewer. If none of other built-is viewers are not helpfull, you can always try with Built-in Web Browser Viewer. In that case we will use embeded Edge browser or Internet Explorer to display your file.
But what happens if none of built-in viewers cannot display your file?
Then you can develop your own. Like in the picture above, we have a custom .wwp file format and we have registered a Custom Viewer Library. This kind of viewer requires an external library. You can add one or more files, but you must specify which .dll serve as an entry point (see Library property in the picture above).
To use an external .dll to display file content you must implement and expose a strict interface. Your library must implement the following:
MIDL_INTERFACE("ED000000-0000-46C7-BFB7-4F732CEA14D6")
IFileViewer : public IUnknown
{
public:
virtual const wchar_t* __stdcall GetSource() = 0;
virtual void __stdcall SetSource(const wchar_t* path) = 0;
virtual void __stdcall Focus() = 0;
virtual void __stdcall Resize(int width, int height) = 0;
virtual VARIANT __stdcall Call( const wchar_t* method, const VARIANT* args, const int args_count ) = 0;
};
IFileViewer* __stdcall CreateViewer( const wchar_t* fileType, HWND parent )
{
// `MyViewer` class must implement `IFileViewer` interface.
auto viewer = new MyViewer();
viewer->SetParentHWND(parent);
...
return viewer;
}
When the last reference to MyViewer
instance is released, viewer will be destroyed.