How to Embed Webkit into My C/C++/Win32 Application

How to embed WebKit into my C/C++/Win32 application?

Brent Fulgham has put lots of work into producing a Windows Cairo port of WebKit, which doesn't rely on Apple's proprietary backend stuff (e.g. CoreGraphics, CoreFoundation, CFNetwork). I believe that is what you are after. The details aren't entirely collated in one place, but there is some information in the Trac wiki and other bits are dotted around on Brent's blog.

EDIT: Link to Brent's project on sourceforge

EDIT 2: News of some interesting progress from Brent's blog

How do I embed WebKit in a window?

There is an accepted answer for "How to embed WebKit into my C/C++/Win32 application?". I think it might be the best place to start. IIRC WebKit provides various interfaces for different features and you need to make sure that you have implementations for all the ones that you require in your application.

ChromiumEmbedded might be worth a look, but there could be variations in the WebKit implementations.

How to embed web application into windows app with custom behavior

If you are using WPF, you can create you window with something like this (xaml):

<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None"
Title="MainWindow" Left="100" Top="200" Height="350" Width="525" PreviewKeyDown="Window_PreviewKeyDown">
<Grid x:Name="grdBrowserHost">
</Grid>
</Window>

WindowStyle attr None means "borderless with no titlebars" window. Left and Top are for position, and Width and Height are self-explanatory. All those properties can be accessed via code-behind with simple this.Width, etc... PreviewKeyDown I put here because in this example (as you will see), Topmost property will be changed from code behind (dynamically).

Code-behind should look something like
using System;

using System.Windows;
using System.Windows.Input;

namespace WpfApplication2
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

System.Windows.Controls.WebBrowser browser = new System.Windows.Controls.WebBrowser();
// you can put any other uri here, or better make browser field and navigate to desired uri on some event
browser.Navigate(new Uri("http://www.blic.rs/"));
grdBrowserHost.Children.Add(browser);
}

private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.Close();
}
else
{
this.Topmost = !this.Topmost;
}
}
}
}

In this example I have created default WebBrowser control for showing html. If you want some other web rendering engine you must find 3rd-part control and include it in your references. For webkit, you can check How to use WebKit browser control in WPF

Can you embed a WebKit Plugin into a Cococa Application without using a WebView

I didn't find out the answer to my specific question, but I found out what was causing my problem (and it wasn't related to the bug that I had listed), it had to do with not executing things on the UI thread.

Is there an embeddable Webkit component for Windows / C# development?

There's a WebKit-Sharp component on Mono's GitHub Repository. I can't find any web-viewable documentation on it, and I'm not even sure if it's WinForms or GTK# (can't grab the source from here to check at the moment), but it's probably your best bet, either way.

Embed HTML browser into a native C++/Win32 project using Visual Studio

You could embed an HTLM Browser (Internet Explorer) within your windows with some heavy use of COM. I used to do that and have the same need to avoid MFC, .NET, etc. This control is quite configurable, and you can remove and/or override pretty much anything.

I did my work based on an old article in The Code Project: http://www.codeproject.com/KB/COM/cwebpage.aspx



Related Topics



Leave a reply



Submit