My requirement is to develop a ActiveX control which can send the byte stream to serial port. The ActiveX control should expose only one function like
SendData(char* data, int nLen, int nPort)
This function should be able to be invoked by pressing a button developed in java rendered in Internet Explorer(both 32 and 64 bit). I am confused whether i should go with windowless ActiveX control using MFC/ATL or Browser Helper Objects. In future i may need to support Firefox also.
Any help will be appreciated.
Although BHO would work, ActiveX will suite better your requirements. BHO are very similar to ActiveX - they are both native or managed code running in the browser window. The difference is that BHO is available for all pages (it is instantiated when the browser tab is created) while ActiveX which is not a BHO is instantiated when some Javascript code in the page creating it (or with the <object> tag. The life time of a ActiveX is the page.
ATL is a better choice. Use the VS Wizard, and create an ATL based COM in-proc server. Then add a COM object. Since you want to call it from HTML make sure it is a dual interface (i.e. derived from IDispatch). Add the method that you want to the IDL file. In COM, the calling convention for string arguments is BSTR, and the standard convention for array is SAFEARRAY. How do you plan calling the method from your Javascript code?
Depends how you want to instantiate your object from the HTML page. You can have an <object classid='clsid:'class guid'> or you can use Javascript: var myobj = new ActiveXObject(ProgId). Both methods are valid.
Related
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.
I'm working with an MFC application (C++). We use embedded browsers in some dialogs - IWebBrowser2 ActiveX objects. By default, they emulate IE version 7 (for compatibility reasons). We need a newer version to be able to display modern webpages, so we change IE version by setting the registry key FEATURE_BROWSER_EMULATION. (See this blogpost or other SO questions on the subject.)
But when we change to a newer IE for embedded browsers, a third party module we use crash. It turns out that it too uses a (hidden) IWebBrowser2 object, and it can't handle a modern IE. (Updating the third party module is not an option right now.)
The third party module isn't used often, so we tried solving it by changing the FEATURE_BROWSER_EMULATION temporary. But that doesn't work! It seems like FEATURE_BROWSER_EMULATION is only read the first time an IWebBrowser2 object is created. If you do like this:
(1) Set FEATURE_BROWSER_EMULATION to 7000 (=IE7)
(2) Create a dialog box with an IWebBrowser2 control (and navigate to "thismachine.info")
(3) Close the dialog box
(4) Set FEATURE_BROWSER_EMULATION to 11001 (=IE11)
(5) Create a dialog box with an IWebBrowser2 control (and navigate to "thismachine.info")
both IWebBrowser2 controls will be IE7! (If you swap 7000/11001 both will be IE11.) Despite that the whole dialog, the browser control and the first IWebBrowser2 object get deallocated in step (3).
Is there any way to get two IWebBrowser2 objects to use different IE versions in the same process? What's causing this - is there some "registry cache" in the COM handling, causing the new registry value to be ignored? (If so, is there a way to clear that cache?) Or is there some part of the first IWebBrowser2 object that isn't deallocated? (If so, is there a way to do that?) Or do anyone have a different approach/suggestion?
I am working on my webcontrol used IWebBrowser2.
I want it play flash movie but disallow other ActiveX controls.
I found disallow all ActiveX contorls using DLCTL_NO_DLACTIVEXCTLS | DLCTL_NO_RUNACTIVEXCTLS flags
in implements of invoke.
but I've searching msdn for IWebBrowser and related Interfaces, I can't found any solution.
I expect catch a event before ActiveX loaded or allow only flash ActiveX ways.
please help. thanks.
Hosts of the Web Browser can control how it behaves by implementing IOleClientSite and responding to DISPID_AMBIENT_DLCONTROL with a set of desired behavior flags. One important caveat: the flag DLCTL_NO_RUNACTIVEXCTLS only blocks OBJECT tags within the document itself. It has no impact on the use of calls to new ActiveXObject(“…”) from script, if DLCTL_NO_SCRIPTS was not set.
In order to prevent ActiveX execution in a Web Browser host, supply an IInternetSecurityManager and return URLPOLICY_DISALLOW and S_FALSE when your ProcessURLAction implementation is called with URLACTION_ACTIVEX_RUN. To permit only a specified “allow list” of controls to run, the ProcessURLAction implementation can examine the CLSID of the requested control; that CLSID is passed in using the pContext parameter.
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
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.