I am using code to host windows web control in application. I do not want a new instance of iexplorer to open when someone clicks a link in the page. Checked MSDN and read the following information. I know how to do what it says in C++. Can someone show me how to do this in assembly?  My app is based on the assembly code contained in APLHA_2 of the Client Sites SDK by Andrew Barfield (Xtreme)
Xtreme Software
Thank you to all who reply.

Info below from MSDN site

Controlling New Windows

One important way to take control of the WebBrowser Control is to control navigation. You saw earlier how you can intercept DISPID_BEFORENAVIGATE2 in an IDispatch::Invoke implementation to control where your WebBrowser Control will navigate. Another important aspect of navigation is to control how the navigation occurs, especially when opening new windows. Let's say, for instance, that the user clicks the right mouse button over a link and chooses "Open in New Window" or that a page contains a script like this:

window.open("www.msn.com");

By default, the WebBrowser Control deals with this code by opening a new instance of Internet Explorer to display the page. This may be fine for your application. But then again, it may not. Perhaps you'll want all links to open in your current WebBrowser Control instance. Or perhaps you'll want to open a link in a new WebBrowser Control instance under your control, with your user interface and with your branding.

You can intercept an event, DWebBrowserEvents2::NewWindow2, in your IDispatch implementation to control this. Your control needs to connect to the DWebBrowserEvents2 connection point to intercept this event.

Once you're connected to DWebBrowserEvents2, implement your IDispatch::Invoke so that it handles DISPID_NEWWINDOW2. During the IDispatch::Invoke function call for DISPID_NEWWINDOW2, the array pDispParams contains two parameters. The first one, at index zero, is a Boolean value that tells the WebBrowser Control whether to cancel the new window or not. By default, it is FALSE and a new window will open. If you want to cancel new window creation completely, set the flag to TRUE.

The parameter at index one is a pointer to an IDispatch interface. You can set this parameter to the IDispatch of a WebBrowser Control that you've created. When you pass back an IDispatch like this, MSHTML will use the control you've given it to open the link.
Posted on 2006-04-09 19:10:08 by devilhorse
What exactly do you want to know? The complete implementation requires a bunch of interfaces, which will be likely > 50 KByte of sourcecode. The special way to change the invoke function is described in the MSN text:

- have an implementation of the DWebBrowserEvents2 dispatch interface
- catch the DISPID_NEWWINDOW2 command in the Invoke method (given as dispIdMember)
- get the two parameters (from pDispParams), this is an array containing two VARIANT entries
- fill in the second VARIANT with the IDispatch interface pointer of your created control

By the way - the second parameter is not documented in my MSDN, so it must be a quite new feature, or an undocumented one :)
Posted on 2006-04-10 05:53:16 by beaster
Here is an excerpt from the code. The browser works. I just do not know how to open all links within the hosted browser only. At the end of this code excerpt I included a snippet from c++. I really don't understand how to do the same thing in assembly


IDispatch@Invoke_ proc pif:DWORD, dispIdMember:DWORD, riid:DWORD, lcid:DWORD, wFlags:WORD, pDispParams:DWORD, pVarResult:DWORD, pExcepInfo:DWORD, puArgErr:DWORD

.IF dispIdMember == DISPID_STATUSTEXTCHANGE
;Do something

        ;catch the DISPID_NEWWINDOW2 command

.ELSEIF dispIdMember == DISPID_NEWWINDOW2
   
      ;get the two parameters (from pDispParams),
      ;this is an array containing two VARIANT entries

.ELSEIF etc, etc, etc...

.ENDIF

        ret
IDispatch@Invoke_ endp

//C++ code
case DISPID_NEWWINDOW2:
        // Set the cancel flag to block popups
        pDispParams->rgvarg[0].pvarVal->vt = VT_BOOL;
        pDispParams->rgvarg[0].pvarVal->boolVal = VARIANT_TRUE;
        break;


f0dder edit: changed <quote> to <code>, moved 'text' outside <code> block
Posted on 2006-04-11 00:19:25 by devilhorse

mov eax,
mov eax,
mov eax,

lea ecx,
mov , VT_BOOL

lea ecx,
mov , VARIANT_TRUE


...but please bear over with me, I just woke up and this is a whole bunch of indirections ;). You can always try compiling your .cpp file with "cl /O1 /c /FAs" and have a look at the output assembly listing - it won't be pretty though, and will use hardcoded offsets rather than nice structure names...
Posted on 2006-04-11 02:00:33 by f0dder