scrolling

Add-in Express™ Support Service
That's what is more important than anything else

scrolling
Programmatically scrolling in IE window 
Madhu Chinthakunta




Posts: 6
Joined: 2011-06-21
Hello:

I have an IE plugin project with a toolbar and an explorer bar. Based on some logic I want to scroll the document in the IE window up/down. The effect should be the same as dragging the scrollbars. I tried using window.scollBy(x,y) as show below without any luck.

How do I achieve this?

Thanks
Madhu

void ScrollY(int deltax, int deltay)
{
mshtml.IHTMLWindow2 window = HTMLDocument.parentWindow;
if (window != null)
{
window.scrollBy(deltax, deltay);
Marshal.ReleaseComObject(window);
}
}
Posted 07 Jul, 2011 03:33:28 Top
Andrei Smolin


Add-in Express team


Posts: 17132
Joined: 2006-05-11
Hello Madhu,

Please check the value returned by scrollBy. See also http://msdn.microsoft.com/en-us/library/aa741495(VS.85).aspx.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Jul, 2011 06:57:55 Top
Madhu Chinthakunta




Posts: 6
Joined: 2011-06-21
Thanks for the response.

But IHTMLWindow2:scrollBy(int, int) is a void method. :(
Posted 07 Jul, 2011 12:11:57 Top
Andrei Smolin


Add-in Express team


Posts: 17132
Joined: 2006-05-11
Hi Madhu,

Your method works fine for me.

private void adxieMenuItem1_OnClickEx(object sender, ADXIEMenuItemClickEventArgs e)
{
    ScrollY(120, 120);
}

void ScrollY(int deltax, int deltay)
{
    mshtml.IHTMLWindow2 window = HTMLDocument.parentWindow;
    if (window != null)
    {
        try
        {
            window.scrollBy(deltax, deltay);
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);
        }
        Marshal.ReleaseComObject(window);
    }
} 


Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Jul, 2011 07:34:09 Top