|
|||||||
On one of our more recent projects, we were required to display a PDF document by double-clicking in an edit table. No real issue, we can use just use SHELLEXEC as documented here right? Wrong. The problem with a SHELLEXEC, is that by default, it launches a browser that has an address bar containing the full URL to the document in question, allowing the user to modify the URL and potentially access information they were not privy to. (The users don't have browse rights so there isn't a problem of them browsing to other information, but knowing the fully formed URL they could take intelligent guesses at other potential document names). So, we considered looking at turning the address bar off, but then remembered the new WebView control. A control that allows you to embed the Microsoft WebView2 Edge Browser directly into an OpenInsight form and to interact with it. This looked like it was going to be the easiest hack ever. Create a form with just two controls, the WebView control and a close button. Have it accept as a create parameter the document to display, and all is good, yes? So we added a quickevent to the form that simply set the URI property of the WebView control, to the value passed in the createParam for the form. It ran. It did nothing. Puzzled we modified the CREATE quickevent to also update the screen caption with the file name we were trying to display. (This ability to stack quickevents rocks!). The caption changed to the correct value but still nada. Thinking laterally we invoked the system monitor and used the SP command to set the URI of the control to the value we had passed in. It displayed. Rinse and repeat. Chatting to the developers, it seems the issue here is that the WebView control takes a little time to instantiate itself, so it it might not be finished before the CREATE event runs. So we have to wait for the WebView control to be finished and THEN set the URI. Sounds like a case for looping, querying status and waiting, yes? No. The WebView control is asynchronous. So all we have to do is wait for an event that tells us that the WebView control is ready, and THEN set the URI. All this took was two quickevents. One on the CREATE event, setting a synthetic property to contain the document name and one on the WEBVIEWCREATED event for the WebView control (which is fired when the WebView is fully instantiated) which retrieves the synthetic property and uses it to set the URI property. |
|||||||
| |||||||
2 Comments:
Nice!
"(This ability to stack quickevents rocks!)" - How do you do that?!
By Anonymous, At 5 September 2023 at 22:25
You can stack up to three events. In the example above we stack two, getting a property and setting a property.
By Sprezz, At 11 September 2023 at 13:42
Post a Comment
Subscribe to Post Comments [Atom]
<< Home