IWebBrowser2 issues - how to open documents in new windows? - c++

I have IWebBrowser2 ctrl embedded into my own dialog. I want to simply
display a promo banner within it from my url. How to disable all popup
menu items from the control and force it to open links in new window
(currently when I click on link in the banner, it is being opened
within the same control).
Regards
Dominik

Have a look at the following article:
WebBrowser Customization

I don't know if there is a more convenient way of doing this - but you could always intercept BeforeExplorerNavigate2(), set the out-parameter cancel to true and from there either do a new Navigate() with a different target frame name or open a new window.
As Rob pointed out, there might be problem with filtering out navigate events originating from scripts, see this question.

Related

Adobe DISPATCH_METHOD for disabling navigation bar, bookmark and right click etc (MFC)

I am very new to activeX control and I need to embed adobe activex control in my MFC dialog.
I use the example code in https://www.codeproject.com/Articles/9537/Adobe-ActiveX-Control-with-MFC to implement an Adobe ActiveX control, it works and display the pdf file successfully.
I need the pdf to be displayed without toolbar, navigation bar, bookmark and right click, but the sample code only contains a method like following:
It works for disabling toolbar. But there is no method for navigation bar etc.
I searched online for InvokeHelper(0x3, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, On); and realize that 0x3 is the DISPATCH ID and it is invoking the Adobe API by this ID.
Therefore, I guess there must be other method in Adobe for navigation bar and bookmark etc, but I cannot find the corresponding document about the method DISPATCH ID.
Anyone knows that please ?
I even cannot find any documents about the setShowToolBar method DISPATCH ID.
By reading Interapplication Communication API reference from Adobe, I find out how to close the bookmark automaticlly.
I called SetPageMode(L"none"), it works for closing bookmark.
But I haven't figured out how to close the navigation bar and status bar.

Creating a Control Panel Applet similar to built in applets

I have created a Control panel applet. The icon is placed in the control panel. When I double click my icon, it just opens a notepad application.
What I have to implement is, when I double click on my icon, it should open the GUI similar to the UI of other the Control panel (Power options of control panel.)
My question is, do I need to create a separate windows forms application? or any other way is there?
Creating address bar similar to explorer is not possible, since MS has not exposed such control.
You can take a look at the following link...
MFC: Address Bar control like Windows Explorer

Embedding file open dialog

Office 2010 has a new type of ribbon, the backstage view. This has been implemented in MFC using Codejock Xtreme Toolkit Pro V15.0.1.
The thing is that I feel that the File>Open and File>SaveAs act very strange in Office. They open a modal file open dialog instead of opening an embedded file open dialog in the backstage, which would (IMHO) feel much more natural.
I cannot find a way of doing this in C++ using MFC or Win32. The only thing I found was this question, but that was for Delphi.
So, is it possible to embed the standard Windows File Open dialog as a control in another dialog? Or do I need to implement the entire thing myself?
To the best of my knowledge, The standard Open/Save dialog functionality is exposed through the modal dialog only (through the GetOpenFilename Win32 API).
There is a standard mechanisme to customise the dialog (See Skizz answer) but it remains a modal dialog. One case of advanced customisation was the VB6 Open Project dialog:
The Existing tab contains a file dialog. How did they do it? I mean, how did they manage to put a standard dialog into a page of their 3-tabs property sheet?
It appears that they simply used the standard customization dialog and added a tab control above the standard dir/file controls and listview for other 'tabs' above dir/file controls. These dir/file controls were then hidden by the custom code when a tab other than Existing was clicked. You get it: no real tabs! Just a good old file dialog where the main controls may be hidden in favor of other ones.
So my short answer is: You're pretty much out of luck using the dialog as a child control.
Now, to come back to Office: I believe it's better to keep a modal dialog. It would otherwise be confusing to user: Is the path that I started to type the real path of did I just clicked 'Home' and let the save command unfinished?
I don't know if you can embed a file open dialog into another dialog, but you can certainly extend the existing dialogs:-
Here's one implementation.
And another.
And an MSDN version.
Thanks to David for pointing out the above are a bit out of date, so, after a quick Google, here's a more modern take on extending the file dialogs (and lots of other stuff as well).

How to practically customize IE context menu?

I need to add one menu item in IE context menu. It is similar with Google customized context menu "Search Google for xxx" when you right click on IE.
I did a research and found that overriding IDocHostUIHandler::ShowContextMenu in a IE BHO can customized IE context menu. The sample project can be found in Popup blocker project published in codeproject. It works well and is easy to implement. However this approach has a problem. The problem is it will conflict with other add-ons' context menu customization per MSDN.
In MSDN Internet Explorer Center forum, there are some discussions about this topic. However there is not a proper implementation posted.
If anybody has experience on this, please share your idea. Thanks!
See Adding Entries to the Standard Context Menu on MSDN.
For some sample code, download and extract the Web Accessories for Internet Explorer 5 (the mechanism still works in IE versions up to and including 8). Look at ie5wa.inf and *.html for examples of various IE context menu extensions.
Note that the abive is achieved without COM, purely via one registry setting and a file containing a blob of script (Javascript, JScript, VBScript etc.) The script (JScript, VBScript) may in turn work with COM objects, should your menu action logic reside in such an object, e.g.
create a HKCU\Software\Microsoft\Internet Explorer\MenuExt\My &Context Menu" registry key (&` precedes the menu accelerator letter, if any)
set the default value for the key to point to a file containing the script code implementing the context menu action(s), possibly interacting with a COM object (must support IDispatch IIRC; also read up on the My Computer Security Zone)
create a binary contexts value (0x02 for images, 0x10 for selections, etc.) which regulates when the new context menu should be displayed
I customized my IE in order to navigate to a selected text. You can read the full story and get detailed source code here.
The hearth of my solution is built around the following javascript code and the Registry key [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]:
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
if(0 < str.length)
{
if (str.indexOf("http")!=0)
window.open("http://"+str, "_blank");
else
window.open(str, "_blank");
}

How to disable the Visual Basic dialog when double click the ActiveX Control

I developed a custom ActiveX control:ax_love.
When I insert it into a ppt inside and double click this control will show a pop-up VisualBasic window,this is unacceptable. I hope the double click action will trigger my own function.
ps:I use atl/com in vs2017.
In Design mode, clicking on an ActiveX control will open up the VB window - this is as-expected. In Presentation mode, clicking on the ActiveX control will trigger your function.
If you want a version of this to only open in Presentation mode (so users won't be taken to a VB page), save the file as a PowerPoint Macro-Enabled Show (.ppsm). Then it always opens in Presentation mode (keep a copy in .pptm format for editing, but don't give that one to your users).