Need a good unmanaged C++ OCX example - c++

I need a very simple and clear example of how to create an OCX in unmanaged C++ code. Ideally, I'd like to consume it in Office, but any container (i.e. VB6, .NET WinForms) should be good.
I am having trouble seeing how I can add controls to the OCX canvas... I have seen examples of opening dialogs from within the OCX's load event... but that is not what I want... I need the GUI in the OCX itself.

Have you looked at this Microsoft tutorial. It uses MFC. If you want to create a windowless control you would need to use ATL.

Related

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.

Common Controls Plugins for MFC like in c#?

I'm working with MFC VC++ Application. I would like to use simple UI like in c# NumericUpdown & openFile Dialog & SavefileDialog etc in my application. I would like to know is there any wrapper or plugin for MFC to do this process? Because it is too messy to add a simple control using MFC when comparing to C# .Net! Is there library or plugin to reduce this task? Preferably a free one.
Maybe you just don't know how to do it? In an MFC app controls are easily added by dragging them from a toolbar onto a dialog template. That is the "Visual" part of Visual C++.
And the open and save dialog are available using MFC class CFileDialog.

How do I call C++ code when a button is clicked in a WPF application in C#?

I don't have any idea of how a connection between wpf and c++ code is made. I have added a record button in my wpf application. Is it possible to wrap the c++ solution here: http://msdn.microsoft.com/en-us/library/hh855374.aspx so that when the record button is pushed in the wpf, the c++ solution will get executed?
Yes, this is possible. You can use P/Invoke or a C++/CLI wrapper.
Or you could actually read that page your provided and find a link that says For more information about audio, see Capturing Audio Data in C#.

Writing a wrapper class for an ActiveX control

I am given a video calling software which implements an activex control to render the video in a web browser. As activex works only in IE i am given the task of implementing a cross-browser version of the activex control using FireBreath framework.
I need to write a wrapper class for the activeX control.
I am new to activex,visual studio(eveything involved in the project). And the activex code has thousands of lines of code. It is taking a long time for me to understand the code.
Does anyone have any good example wrapper classes and any other suggestions or links which would help my project?
The closest I know of is this: https://github.com/firebreath/FBAXExample
It's an example of hosting an activex control inside a FireBreath plugin. You'd be better off (and a lot cleaner) if you can do a complete port, but it may be possible to do it with just a wrapper; you may also want to look at the WebView library in FireBreath itself, which embeds IE inside a FireBreath plugin. You can find it here: https://github.com/firebreath/FireBreath/tree/master/src/libs/WebView/Win

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.