ActiveX project in Browzer get Zoom Settings - browser

I'm maintaining an existing VB6 application.
It's built as an AcitveX control. The build process builds a CAB file which is then fired into a Browser from an HTM file.
My question is, is there any way to detect the Zoom setting once the Application is loaded in the Browser?
It's not a WebBrowser project so, I can't use that object to query the setting, at least I don't think so...

During the ActiveX initialization process you are guaranteed to get a SetClientSite callback, among many others, which will give you an IWebBrowser2 pointer. There may be some timing issues with regards to zoom, but this is a starting point.

Related

Editing a managed bean for XPINC, rebuild and error 500

Greeting, brethren,
So I inherited this app (yes, XPages can be legacy now ;-). It is meant for the Notes client only and one process takes a convoluted route via what I understand is called a Managed Bean (the Code/Java design element).
The database resides on a server.
When editing said bean.java, I meet two issues.
If I test immediately thereafter, I'm greeted with an Error 500 that won't go away unless I close then restart both Notes and Designer
In some cases, changes made to bean.java are not immediately available. So far I haven't been able to characterize those cases. For example, yesterday afternoon I could no anything, nothing would bring a change to the Notes client. (Yes, I cleaned & rebuilt and autobuild is disabled). This morning changes are apparent immediatly (save for the quit/relauch bore).
I've tried to set xsp.application.forcefullrefresh=true in the app's Xsp properties but haven't noticed much effect.
What am I doing wrong ? What could I do to fluidify the modifying of a bean ?
When working in XPiNC, after every change you have to close and restart designer. If I understand things correctly, it's trying to access class files that have been discarded. That's why whenever I've had to develop for XPiNC, my initial testing during development is on a browser, I would recommend this approach.
There are minimal differences in syntax, usually only encountered if manually creating URLs to files etc or using the bad practice "" to specify database location in #DbLookup. Wherever possible, avoid #Formula approaches, their performance is worse than object orientated methods (e.g. view.getAllEntriesByKey())
It's the same for the bean. There are only two ways to speed up picking up updates - use a browser or use XPiNC on a different PC.

Struggling with Chrome Extension architecture

I'm new to Chrome extension development, and I'm a bit struggling with the architecture to put in place.
I would like to develop an extension (browser_action), that, when the button is clicked, opens a window where information will be populated from the WebTraffic.
I figured out I could use the WebRequest API to get info about the traffic.
I could create a popup window, but it's displayed only when I click on the extension button, and hides as soon as I click somewhere else
I tried creating a background window, but it does not show up.
I'd be very grateful if anyone could help me with the initial setup of my application.
Thanks in advance
You need both.
Take a look at the Architecture Overview, or maybe this question.
The lifetime of the popup is indeed equal to how long it stays on screen. It's the UI part, but putting logic there is usually bad.
A background page is permanently there but invisible. It's typically the "brain" of an extension, taking care of heavy lifting and routing messages to other parts.
In short:
You need a background script to collect webRequest information for you in some format.
You need a popup page to show it. Keep in mind it's not guaranteed to be present at a given time and can close at any time.
It's probably best to use Messaging to request the information from the background page. If you need real-time updates, you can use long-lived connections.
In your case you can also tightly couple the two and call chrome.runtime.getBackgroundPage() to directly reference stuff in it.

SWT Browser component blocks SWT UI thread

I am embedding an org.eclipse.swt.browser.Browser into a view in a modified eclipse (Indigo), for use as a preview pane of a form editor component. On a form model change or an element selection change the code renders the form via vaadin 6 and displays it in the browser component.
Now, this works like a charm in most cases. But for some highly complex forms the HTML+JS generated by vaadin generates a lot of stress on the browser, rendering it unresponsive for up to a few seconds. That in itself wouldn't be tragic (1), but as long as the SWT Browser component is busy rendering that stuff, the entire eclipse UI thread is blocked.
A simple way to reproduce this is to create an HTML page that blocks inside a javascript function (see https://gist.github.com/creinig/5150747 for an example) and display it in the SWT browser. As long as that JS function is running, the entire SWT application is not responding to anything.
The only info I've found on this problem are
one SO question (without resolution) and
one question on EclipseZone (unanswered).
Not that helpful :(
The API docs of the Browser component don't seem to offer any insight on whether its rendering is triggered periodically by the UI thread or if itself triggers something that blocks the UI.
Is there a way to decouple the Browser component's rendering from the SWT UI thread? Or anything else that could be done to protect the eclipse UI from hanging stuff in the browser?
(1): We need forms of this complexity level, we're already optimizing the rendering performance and a switch to vaadin7 will most likely also speed things up. But the problem will certainly persist, if only in reduced severity.
Not a real solution, but a workaround that Works For Me (TM):
As described here it is really easy to launch the system's default browser from SWT. So I'm going to add an option to the view containing the browser control that will "detach" the view by disabling the browser control and opening the system browser instead.
In case the linked page drops off the net, here's the gist:
org.eclipse.swt.program.Program.launch("http://my.funny.url/");
launches the application registered for HTTP URLs. In other words: the system default browser.
Happiness ensues :)

WebServiceHost inside VSTO addin

I'm about developing an application level VSTO addin that consists, among others, of a UI with an embedded Webbrowser control and a simple REST-style service, based upon WCF's WebServiceHost. The service delivers content, in particular flash movies, to the embedded browser. This used to work like a charm until yesterday. For some still unknown reason (maybe some .NET update that changed some internal processing), the complete Word application now freezes when the browser loads a flash movie from the embedded server. It still works when I move the webserver code into a separate process, and it also works when the flash movie is already in the browser cache, so I am quite sure that it is the combination of serving and displaying the flash movie both in the addin that is causing the problem.
I did some research (which I should have done earlier, maybe) and learned that multi-threading and VSTO addins do not go well together. And running a webservice surely implies some kind of multi-threading.
So my question is: is there any chance to make this kind of architecture run reliably? If so: what am I missing? Or should I better try another approach? If so: what would you recommend?
Note: Using "file://" urls and thus loading the content directly from the disk is not an option since I cannot guarantee a common docroot and need to put some logic between the UI and the content serving.
VSTO add-ins are STA, so you should consider researching WCF and STA (see related SO post).
You could always host the WCF service as a windows service to avoid the STA issues of the VSTO add-in host.

How can I use the Winforms WebBrowser control in a webapp?

I have developed a library to manipulate HTML to conform to our needs using the WebBrowser control, however I need this library to work on a web app and not a winforms app. The main issue I get is this:
"ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment."
I understand this is because the WebBrowser control needs to be ran in a STA Thread, but obviously a web app isn't an STA environment. Its a server side process though so its not in a page itself. Any ideas on how I can get round this? I considered setting the AspCompat="true" attribute on the Page tag of a hidden page and running it from that but I would rather a more elegant solution.
Cheers
Instantiate and perform your work in a new thread upon which you have explicitly set the ApartmentState via SetApartmentState().

Resources