Can you use Win32 GUI in a browser plugin? - c++

Of course it would mean you're plugin is not cross-platform but let's focus on the technical side...
Is a browser plugin (like done in NPAPI) restricted in what it can do? Or do you get fairly free reign to access the PC and the render-window you're given? For instance can you create Win32/MFC controls in your browser this way?
A side question - is your browser plugin conceptually akin to a .DLL, which is therefore just arbitrary compiled code implementing a specific interface for browser control/communication?

There are 2 types of NPAPI plugins: windowed and windowless plugins. Both of them has some advantages and disadvantages (see this link). When you deal with windowed plugin on Win32 you get HWND of browser plugin window and you can work with it like with any window in OS.

Related

How should a Windows application with custom controls be drawn with Direct2D?

I would like to create a Windows application (for Windows 10) using the C++ and the Windows API. I already have some basic knowledge of using the built-in windows controls to create a basic application, but would now like to expand into custom controls . Since I have no need for my application to be compatible with anything but Windows 10, and would like to use a reliable API which supports transparency and anti-aliasing but is also fast enough to render a GUI, I have chosen to use Direct2D.
The MSDN documentation says:
'Your application should create render targets once'
Bearing this in mind, should each child window use one ID2D1HwndRenderTarget which renders only to the parent window (and doesn't respond to the child windows' WM_PAINT messages), or should there be a single ID2D1DCRenderTarget which would draw to each control using the device context from the WM_PAINT message (using bindDC() - although I would still like to be able to use transparency, and am not interested in GDI interoperability)? Should I even be using Direct2D at all?
I would like to use the Windows API, so a solution involving QT or MFC wouldn't work. I haven't got a specific application in mind, but would eventually like to create a simple library that would enable me to quickly produce GUI applications that have a custom look.
I have spent hours scouring the web for answers, but have found nothing conclusive. MSDN itself seems particularly unhelpful, it just teaches you to draw an ellipse and stops there. Please forgive me if I have accidentally broken the rules of asking questions - as you can probably tell I am new to Stack Overflow - and if any other information is needed, I will of course include it (I am using C++ with Visual Studio Community 2019).

How to make a Native UI window in C++ with HTML/CSS UI in the client area

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
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.
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.
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.
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.

How to create movable/resizeable/configurable Toolbars for a Windows Application

I have a large C++ application with a mostly homegrown layer for GUI Abstraction etc. The application is plain C/C++ on Win32 API.
So far the application only supports a static horizontal toolbar which can not be modified in any way at runtime (besides enabling/hoovering visualization).
We thought about switching to a ribbon interface but nobody we asked liked that idea.
So we want to add some sort of toolbar with the following capabilities:
Movable and resizeable (acting as floating windows/palettes)
Use Bitmaps of any Size
Supports User configured Toolbars Supports
Enabling/Disabling/Checked State
Preferably create disabled/checked/hoovering state bitmaps automatically
How can this be done with the least effort?
I looked at rebars and the TOOLBAR API. Rebars seem not to be resizeable and i was unable to find a working sample for toolbars.
Working sample: here's what I could find: tutorial with link to full example code, part-3 covers toolbars

Can I get the HWND of an embedded Flash ActiveX control from browser control in my application?

It seems that in browsers, the Flash Control uses an optimized way of drawing. I could not achieve this while embedding the control directly (fast animations are choppy in the control I directly embed, not in a browser). I have found an open source project that implements an optimized drawing, however it is pretty complicated (also, very dependent on the whole project, so not easily reusable in mine).
I would like to try and use an IE ActiveX control, load an HTML that embeds a Flash Control, then get the HWND of this control do some application specific things (already implemented in my project). Is this possible? How?

How to convert an ActiveX (webbrower hosted) project into static library project?

I have an ActiveX component which contains a control (webbrowser control embedded in composite control dialog pane) for accessing certain URL. The ActiveX component accessing URL can be used in other MFC or VB projects. The usage is to register the ActiveX component (use regsvr32 cmd) and then insert the control in a dialog window by using "Insert ActiveX control".
Now I am planning to convert the ActiveX component to static library with the same browser window and web access functions. I wonder how to do it? In addition, how the browser window (in static library) can be used in other MFC projects. Is it through functions call? Is there a sample project available?
I used Microsoft .Net 2003 as development tool.
Thank you very much in advance.
I'm a little unclear about the extent to which you think you can put all of that in a static library.
This is probably not going to be as straightfoward as you think. The wizard and code in VS/MFC/ATL which allows you to insert an ActiveX control in a dialog is doing a lot of work for you. That said, it makes certain assumptions about the nature of the site for the ActiveX control, such as how the message pump works, who is the owner window, the threading model, and so on. In a dialog, these are knowns. In another context, they are not.
The right way to go about doing what you're doing is to leave it as an ActiveX control. Maybe if you stated what problem you are trying to solve by putting it into a static library, we could give other options.
The WebBrowser ActiveX control is really a wrapper for the shdocvw.dll library, in the system32 folder. shdocvw.dll is the heart and soul of IE (and, by extension, much of the Windows Explorer interface). It's all very heavily based on COM, which has its own rules for loading libraries and so on. So the site (any application which wants to use your ActiveX control) really needs to be friendly to ActiveX/COM anyway.