0

I have this program, it is apparently coded in C++, and I can see that the window(dialog box) is a native one, but in the middle of the window, it has modern looking UI elements, and when I right click on the client area(with modern UI elements) it shows a context menu like a web browser does(with almost same items as Internet Explorer).

There is also a newer version of this program, apparently it has coded same as before but the content in the web browser like area is now coded in Silverlight.

So according to my understanding this is a just a native window with an HTML web page in the client area, which allows to take advantage of CSS designing.

I would love to know how such a program be developed C++ and how does event handling is done in such a system.

Any help is much appreciated. Thanks

  • 3
    You can embed web view control, for example IWebBrowser2, into native window. There are some ready projects for reuse. For start I would recommend [webview by zserge](https://github.com/zserge/webview). – Daniel Sęk Jul 12 '19 at 16:20
  • @DanielSęk You have a typo in your link formatting. – ruohola Jul 12 '19 at 16:22
  • @DanielSęk thanks for the link, I've used `IWebBrowser2` but it requires the `WebView2Loader.dll` to be in the users computer as well right? –  Jul 12 '19 at 16:27
  • It requires that user has installed Internet Explorer on his Windows box. But today all Windows boxes have IE installed. Only problem with IE it is a little outdated, and you need to deviate from modern CSS and Javascript usage. – Daniel Sęk Jul 12 '19 at 16:31
  • I see, thanks for the info, can wxWebView be used for this? but there's no way to handle event properly –  Jul 12 '19 at 16:32
  • I don't know wxWebView. Zserge webview allows to call Javascript from C/C++ and another way. I have even written simple editor with text area which can save text to file and load it later. I had give up trying to implement multi level undo (it would need a lot of time). There is some peculiarity with zserge/view: don't include , allow "webview.h" to do it. – Daniel Sęk Jul 12 '19 at 16:34
  • You can also embed the [WebView Class](https://learn.microsoft.com/en-us/dotnet/api/microsoft.toolkit.forms.ui.controls.webview?view=win-comm-toolkit-dotnet-stable) (MS Edge) – Castorix Jul 12 '19 at 18:50
  • Unanswerable. For all we know, this could just be a UWP app written in JavaScript/HTML. – IInspectable Jul 12 '19 at 21:28
  • @IInspectable Hello, thanks for the answer, I can confirm it is based on C++ and Web browser based, the window is created from function in the DLL(100% confirmed by the author himself) –  Jul 15 '19 at 09:27

1 Answers1

0

Basically you do this by embedding a web browser control into your application. Microsoft directly provides such a control or you can use 3rd party alternatives.

  1. In WinForms you can add a WebBrowser control like any other common control, see here. You can also include the same control in a WPF application.

  2. The above .Net WebBrowser control emulates IE7 by default (I believe) even if the user has a newer version of IE installed. You can make it use a newer version as shown in various online resources. A better option is however, to not use IE or the WinForms WebBrowser control at all. Consider CefSharp. "Cef" stands for Chromium embedded framework, which is a native library. CefSharp is a C# wrapper around CEF.

  3. If you are not using C#, in a native Win32 application you can just embed CEF. Or you can embed Microsoft's IE-based control as, essentially, a COM object, but I would recommend the former in this case. This is exactly what CEF is for.

jwezorek
  • 8,592
  • 1
  • 29
  • 46