In my project (for Mac and Windows desktop), I have a listbox (lb) that displays the names of local files on the user’s computer and saves the corresponding FolderItem (f) in the RowTag. In the lb.Change event, the file is displayed in an adjacent HTMLViewer - hv, whose renderer is WebKit - using hv.LoadPage(f).
The files I want to display are mostly pdfs and images which will display OK in the HTMLViewer. However, if the file type can’t be displayed, I want to capture this so that I can open the file in the default program instead, using f.Open.
On Mac, if the file is, for example a .docx, then with hv.LoadPage(f) the following sequence of events are fired:
CancelLoad
DocumentBegin
Error (102, Frame load interrupted)
DocumentCompleted
So I can use the Error event to go down my alternate pathway. However, on Windows, only the CancelLoad event fires and that’s it. If I change the renderer to Native, then a modal dialog pops up asking if I want to download the file, which is not the desired behaviour.
Does anyone have suggestions on how I could implement this on Windows? Or is there are more elegant way to achieve the desired result?
Thanks,
Frank