Thread: IHTMLDocument2::get_parentWindow() fails

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102

    IHTMLDocument2::get_parentWindow() fails

    Hi. Don't know if this is the forum for COM related questions, but it still is Windows programming. I Tried to get the IHTMLWindow2 interface of an IHTMLDocument2 using get_parentWindow(), but the function crashed my application.

    Code:
    IHTMLWindow2 *parentWindow = NULL;
    //webBrowser is a valid IWebBrwoser2 obejct
    webBrowser->get_Document(&iDispatchDocument);
    
    iDispatchDocument->QueryInterface(IID_IHTMLDocument2, (void**)&htmlDocument);
    htmlDocument->get_parentWindow(&parentWindow);
    I am sure that htmlDocument is a valid pointer, since I can call its other functions (I can even get all the elements).

    What could be the cause for this crash? Thank you for any help.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Are you not checking HRESULT return values?

    Check for errors and look up the meaning of any error codes.

    gg

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Thanks for your reply, but I can't check the return value of get_parentWindow, because the function doesn't return before crashing the application. webBrowser->get_Document and iDispatchDocument->QueryInterface both return S_OK.

  4. #4
    Registered User kimyat13's Avatar
    Join Date
    Oct 2010
    Posts
    9
    were you able to solve this? i am really desperate for at least some information regarding my problem.

    a completely answered thread for this one would definitely help me out..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 21
    Last Post: 06-24-2009, 09:49 AM
  2. Mac - File locking with fcntl() fails on shared volumes!?
    By idelovski in forum Linux Programming
    Replies: 3
    Last Post: 11-10-2008, 07:37 PM
  3. Why this fails - confusing
    By manav-II in forum C++ Programming
    Replies: 2
    Last Post: 07-21-2008, 01:01 AM
  4. Replies: 0
    Last Post: 05-23-2005, 11:39 AM
  5. ReadFile function fails.
    By dpkeller in forum C++ Programming
    Replies: 2
    Last Post: 12-03-2004, 10:20 PM