CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: OnNewWindow2

  1. #1
    Join Date
    Aug 1999
    Posts
    5

    OnNewWindow2

    OnNewWindow2( LPDISPATCH* ppDisp, BOOL* Cancel ); is method of CHtmlWiew class and ppDisp is a to an interface pointer that, optionally, receives the IDispatch interface pointer of a new WebBrowser or Internet Explorer object. I need to know URL location of that new window of a Internet Explorer object. How to do that?


  2. #2
    Join Date
    Jun 1999
    Posts
    6

    Re: OnNewWindow2

    Have exactly the same problem.
    Did You find a solution ???



  3. #3
    Join Date
    May 1999
    Location
    13 N 77 E
    Posts
    183

    Re: OnNewWindow2

    One solution is to create a new explorer object and pass its Idispatch to the parameter. Now you can use the interface to the new explorer object ( IWebBrowser2) to get the LocationURL using an incoming call.

    hope this will work :-)
    I tried this with VB , it works.
    but its a bit of sweat with VC.

    But the problem is a recursive newwindow call !!!!I am in need of a solution myself




  4. #4
    Join Date
    Aug 1999
    Posts
    5

    Re: OnNewWindow2

    Rcursive window call: solution:

    OnMouseClicked(){
    flag=TRUE
    }
    OnNewWindow(){
    if (flag){
    ......
    ..
    *ppDisp=.....
    .....
    ...
    flag=FALSE
    }
    {

    OnNavigationComplete(){
    if(flag){
    flag=FALSE
    }
    }


    This means that newwindow can retrieve URL only when mouse clicked (when user click on a hiperlink).
    If html page is loaded and that page want to open new window by it self (whitout user clicking on hiperlink); my code will not alowed this.
    This code will prevent and recursive opennewwindow.
    Try this code and write to me how it works.


  5. #5
    Guest

    Re: OnNewWindow2

    I am using the regular Internet explorer and not a control. I have no intention of writing a hook to get the mouse click on the browser.

    I am trying to get the sink registered with all the windows or the window currently in focus.

    The VB code here shows the spirit in which i need the thing to work.
    This VB code is faulty and the victim of a lot of wayward experimentation.
    But it should give an idea of the problem.

    MSDN Article ID: Q180366 suggests some interesting ideas but event that fails with sites like www.games.com www.desktop.com etc



    Dim ie As shdocvw.InternetExplorer
    Dim WithEvents iecoll As shdocvw.ShellWindows
    Dim WithEvents currentie As InternetExplorer
    Dim first As Boolean
    Dim firstie As Object

    Private Sub Command1_Click()
    For Each ie In iecoll
    Set currentie = ie
    Next
    End Sub

    Private Sub currentie_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    If Not first Then
    Set firstie = pDisp
    first = True
    End If
    End Sub

    Private Sub Form_Load()
    first = False
    Set iecoll = New shdocvw.ShellWindows
    For Each ie In iecoll
    Set currentie = ie
    Next
    End Sub


  6. #6
    Join Date
    Aug 1999
    Posts
    492

    Re: OnNewWindow2

    I need the answer to this also. Did you ever get the solution?

    Why would Microsoft hide such an important piece of information with this function in the first place?

    Why are the "tolerant" so easy to offend?

  7. #7
    Join Date
    Aug 1999
    Posts
    5

    Re: OnNewWindow2

    Yes I get the solution. If you use Microsoft Web Browser Control (ActiveX control)on dialog ,you must create another dialog with Web Browser Control on it in resource editor. When NewWindow event ocurs in the first dialog you must content of this newwindow put in second dialogs Web Browser Control with this line: *ppDisp=pNewDlgExplorer->m_explorer_control.GetApplication();. Now, second dialogs Web Browser Control start to load some html page and you must OnBeforeNavigate (CDlgExplorerSecond::OnBeforeNavigate) catch this new page and put this new page back in firs dialog:


    CDlgExplorerSecond::OnBeforeNavigate(strUrl)
    {
    pFirstDlgExplorer->Navigate(strUrl);
    }



    .
    ..
    .


    CDlgExplorerSecond* pNewDlgExplorer;
    pNewDlgExplorer=new CDlgExplorerSecond;
    pNewDlgExplorer->Create(IDD_DIALOG_EXPLORER);


    void CDlgExplorerFirst::OnNewWindow2Explorer(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel)
    {
    *ppDisp=pNewDlgExplorer->m_explorer_control.GetApplication();
    }







Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured