This is something I've been trying to find out if it is possible and how to do it. I would like to be able to embed a Gtk+ control/widget within a Webkit view, integrated as part of the webpage. For instance, I was hoping that it could be possible to integrate a specific control in the middle of a programmatically generated webpage loaded onto a Webkit instance in a Gtk+ application. I'd like to make it a part of the DOM, if possible.
My intent is to use the webview as a basis for some parts of the UI, but there are some specific controls that needed to be the original Gtk+ ones.
When dealing with controls in forms, for instance, one of two things happen, either Webkit-gtk renders them explicitly to look like the Gtk+ controls, or makes use of actual Gtk +controls and embeds them. If the reality is the second case, then it might actually be easy to do it with other controls as well.
I'm developing the application in C# (mono) with GTK#, but I'm also hoping that if it is possible to do it directly in Gtk+, then it might eventually be possible to do in GTK#.
This used to be possible in WebKitGTK 1.x, but since WebKitGTK has become multiprocess, the capability has been removed.
However, you may be in luck, since GTK# uses quite old versions of libraries. I can't tell what version of WebKitGTK you're using, but if it has the create-plugin-widget signal then you should be able to do this.
I've never used this signal before, but I believe it works like this: you put an <object> tag into your HTML, and then the signal will be emitted when the webview needs to embed your widget. In the signal handler, you create your widget, and pass it as the return value of the signal handler.
You may want to look into Broadway. This is the web backend for GTK+, and uses HTML5 to display GTK+ widgets. You may have to use entirely GTK+ in your webpage, but this seems to be the only way to make a webpage containing GTK+ elements.
Related
I have two applications:
A legacy one, written in .net
A modern web application with cool html5/js features
I want to make them coexist so i'm considering integrating a WebBrowser ActiveX control in my .net application. I want to understand how "deep" i can make them communicate and more specifically:
Which type of information can i send from the webapp to parent .net app?
In Microsoft documentation, several events are associated to the WebBrowser class like Navigated which seems to be triggered every time the webapp's url changes. So i can imagine a mechanism which:
change the url
without affecting the webapp content
but passes some info to the .net app.
example: navigating to http://my.web.app/#event=hello&content=you will tell me that event type hello was triggered with content you.
That sounds like a tedious process, so:
Is there something higher level that this idea? At the beginning, i expected something like the window.postMessage method?
If not, is there a library that provides a higher level api to perform such things more easily?
I think you can build a bridge between javascript code in modern application and your C# host application using this technique
https://learn.microsoft.com/en-us/dotnet/framework/winforms/controls/implement-two-way-com-between-dhtml-and-client
It allows to execute C# code from JS as well as invoke JS from C#. You need to set ObjectForScripting property of WebBrowser control to C# object, methods of which will be called and then invoke it like
window.external.YourCSharpObjectMethod('called from JS code');
I'm being slowly driven mad at work having to manually gather data contained within an ActiveX object running in Internet Explorer 8. It's essentially a ticket system containing some key customer details etc. which I must copy and paste a lot more than is healthy.
Where would I start looking for a solution that will allow me to grab the data I want and navigate the ActiveX system programmatically?
Ideally I'd be thinking of writing something in Java or C# but I'm open to any suggestions!
Unless the ActiveX you are interested in exposes information through public interface (in which case you can injected JavaScript on page to read data) you'll have to use some form of screen scraping. If the control has regular input controls it should not be too hard, but if everything rendered directly you may need OCR the images...
Injecting script:
use WebBrowser control and "eval" your script on the page - some communication sample is here http://msdn.microsoft.com/en-us/library/a0746166%28v=VS.85%29.aspx, eventually you'll need InvokeScript - http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.invokescript%28v=VS.85%29.aspx
use normal IE automation http://msdn.microsoft.com/en-us/library/aa752084%28v=vs.85%29.aspx.
for one-time use "javascript:" in address bar or just developer tools (F12).
utilize XSS vulnerabilities of the site (half kidding, don't forget to fix whatever you find afterwards if you own the site, as for reporting errors to third party consult your conscience)
I have a .NET ActiveX/COM Object which has a WebBrowser control (among other controls such has buttons, etc) inside it.
This object seems to load fine, the buttons are displayed and working but, for some reason, the WebBrowser control doesn't show up!
Is there some limitation for this in IE (e.g., is IE afraid of something recursive, etc.)? Is there a way that I can overcome it?
Thanks in advance,
Zubrowka
FireBreath has a library called WebView that does this; I've tested it both in NPAPI based browsers and in ActiveX and it works just fine. There are many reasons why you may want to do this.
Since I don't know what you're doing, I can't tell you what you're doing wrong... but I can show you the source code that FireBreath uses to do it:
https://github.com/firebreath/FireBreath/blob/master/src/libs/WebView/Win/WebViewWin.cpp
This is in C++, but you might be able to find something useful from it. I don't use .net in the browser -- too much overhead -- but theoretically the same principles should apply.
I was wondering is there any option of using Stylesheets for .NET Windows controls ?
If not, which is the best way to make the UI look consistent.I need to use VS 2005 to make
the changes in the UI.
Regards
We derive usercontrols from all controls in our system -- all the derived classes do is set the style from a central list of constants defining colours and fonts. Then we use these controls on our WinForms for a consistent look and feel.
If we want to change the style, we just change the list of constants.
This also allows is to perform UI tricks like setting the background colour of controls to a different colour when they are being edited.
If you want to make your UI consistent and pretty, why don't you give WPF a try? You will be able to organize your styles in resource dictionary, then reference to it in all the other projects.
Well guess he's talking about WinForms. Then you cant use Stylesheets. Havnt coded that much of WinForms. But guess you could have an "Settings/sheet" class that have properties of different style you are using and then set them when creating your controls.
you can use Stylesheets in web pages only not in Windows controls.
Even ASP.NET controls, which ultimately render HTML, are notoriously CSS-unfriendly. The reason is that they use tables extensively for layout, and they set a lot of inline style tags which of course do not honor the style sheet. Some work has been done to create wrappers for these controls, but it was incomplete the last I looked.
It's a shame, but our team will not use the out-of-the box controls most of the time. We've rolled our own and packaged them into an internal library. While the Microsoft controls would have been very useful, they simply don't meet our criteria for clean, accessible, styleable HTML.
Microsoft seems, finally, after something like 10 years, to have realized that this is important to a modern development team. The control output of ASP.NET MVC is far cleaner and behaves itself quite well with respect to CSS. Whether they'll eventually revisit the core ASP.NET controls is anyone's guess.
I am looking creating some custom controls that need to be compiled as a stand alone dll rather than with the primary application. Unfortunately so far this has meant manually creating the controls without the use of the designer since afaik you can't compile a User Control as a stand alone component. As doing things this way makes the controls rather difficult for the designers to style without putting in a lot of effort on the developers part, I am wondering if there is in fact a viable way to compile a .ascx style control into a stand alone binary?
You can turn a user control into a custom control that is in a standalone .dll, but it loses the ability of being updateable via markup.
In other words, you can build an .ascx file using markup and code, and then turn it into something similar to a control that was built exclusively with code.
Turning an .ascx User Control into a Custom Control
You have to understand that user controls are just a convenience for reusable content though - ultimately, the markup does get processed and compiled. Custom controls are really the only way to distribute a web control. IF you have to distribute controls as a library, I would concentrate on making them CSS friendly for your devs with just a few layout controlling properties, rather than messing around with .ascx.
The MSDN article http://msdn.microsoft.com/en-us/library/aa479318.aspx explains how you can do this. Basicly you precompile the application and take the resulting DLL.