IHTMLDocument2/IHTMLElement2 functions crash in IE7(Access violation) when scrolling

This is a discussion on IHTMLDocument2/IHTMLElement2 functions crash in IE7(Access violation) when scrolling within the Windows Programming forums, part of the Platform Specific Boards category; PROBLEM 1. How do i programmatically scroll an IWebBrowser2 control in all IE versions? 2. Why is it that the ...

  1. #1
    Registered User kimyat13's Avatar
    Join Date
    Oct 2010
    Posts
    9

    Question IHTMLElement2 functions crash in IE7 when programmatically scrolling browser control

    PROBLEM

    1. How do i programmatically scroll an IWebBrowser2 control in all IE versions?

    2. Why is it that the code i have runs in IE6 but crashes in IE7?

    3. Follow-up to question(2), is there a way to work around the Access Violation in mshtml.dll when calling functions from the IHTMLWindow2, IHTMLElement2, IHTMLDocument2 and IHTMLDocument3? (ex. get_scrollTop, get_scrollHeight, get_ScrollWidth, get_parentWindow)

    THANKS!


    CODE

    Code:
    //error trapping had been removed
    BOOL CBrowserControl::Scroll(LONG scrollType)
    {
    CComPtr<IDispatch> spDoc;
    long scrollPos;
    
    m_spWebBrowser->get_Document(&spDoc);
    
    IHTMLDocument2 *pDocument = NULL;
    HRESULT hresult = spDoc->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
    //hresult is S_OK
    IHTMLElement *pBody = NULL;
    hresult = pDocument->get_body( &pBody );
    IHTMLTextContainer *pElement = NULL;
    hresult = pBody->QueryInterface(IID_IHTMLTextContainer,(void**)&pE lement);
    //hresults are S_OK
    
    IHTMLWindow2 *pWindow = NULL;
    hresult = pDocument->get_parentWindow( &pWindow ); 
    //the crash happens here. cannot read hresult anymore since an access violation happens upon calling the function
    
    long scrollwidth, scrollheight;
    pElement->get_scrollHeight(&scrollheight); 
    //a crash here occurs too if i try to comment the code above
    pElement->get_scrollWidth(&scrollwidth);
    //still crashes here
    
    long page; 
    m_spWebBrowser->get_Height(&page);
    
    switch(scrollType)
    {
    case StepDown:
    ............//other cases here
    }
    pWindow->scrollBy( 0, scrollPos );
    return true;
    }
    Last edited by kimyat13; 10-15-2010 at 06:00 AM.

  2. #2
    Registered User kimyat13's Avatar
    Join Date
    Oct 2010
    Posts
    9
    DETAILS

    Good day..

    I know it's quite a long shot, but I have this problem.. And I've ran out of places to ask for help for..

    I am supposed to make my webbrowser control scroll depending on what scrollType I pass. Well, everything worked fine... that is, in IE6.
    My code crashes in IE7 at get_parentWindow, get_scrollHeight (and perhaps also in scrollBy). They all return access violations.

    Trying other solutions on the net didn't help, IE7 still crashes with calling functions (like get_scrollTop and etc)... I already tried scrolling using IHTMLElement2. But no luck... I also tried IHTMLDocument3->get_documentElement and used that for scrolling, still... no sunshine in sight.

    Is this an IE thing? or are there settings I failed to look at? Does anyone know by chance a way to work around this? it's really not good to just restrict users from using my scrolling functions if they don't use ie6.

    i am kinda desperate now.
    will be forever grateful for the help.

  3. #3
    Registered User kimyat13's Avatar
    Join Date
    Oct 2010
    Posts
    9
    ultimately, i gave up on this idea.



    instead of using the interfaces and so on as what i've done, i just focused to the control and automatically sent the keyboard keys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Static member functions more efficient?
    By drrngrvy in forum C++ Programming
    Replies: 6
    Last Post: 06-16-2006, 07:07 AM
  2. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 05:58 PM
  3. Attaching functions to a class/struct
    By VirtualAce in forum Tech Board
    Replies: 2
    Last Post: 08-04-2003, 10:56 AM
  4. Expression Manipulator v0.2 (bug fixes, functions)
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-26-2003, 04:52 PM
  5. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21