|
Hi,
I am trying to get it done using C#, but I am not going anywhere...
can anyone help me.
Any hints pls.
( I already have a simple WebBrowser Object, I need to get the position of the Scroll Bar)
|
|
|
|
|
IHTMLDocument2 htmlDoc = (IHTMLDocument2)m_browser.Document;
htmlDoc.parentWindow.scroll(100, 100);
|
|
|
|
|
With that code I'm getting a compilation error:
Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.IHTMLDocument2'.
Any ideas?
|
|
|
|
|
Scroll to absolute position [adapted from C# example]
webbrowser1.document.window.parent.scrollto(x,y)
But:
Anyone know how to get the current 'y', so one could scroll relative to the current position?
|
|
|
|
|
There is also a HtmlElement.ScrollIntoView Method in .NET 2.0, very useful .
|
|
|
|
|
This is how you do it in C# using VS 2005:
Add a COM reference in your project to mshtml (shows up as "Microsoft HTML Object Library" in the Add Reference dialog).
Add the following to your buttonDown Clicked handler:
private void buttonDown_Click(object sender, EventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
if (doc == null)
return;
mshtml.IHTMLDocument2 htmlDoc = (mshtml.IHTMLDocument2)doc.DomDocument;
htmlDoc.parentWindow.scrollBy(0, 100);
}
|
|
|
|
|
1.As you know IE or Any browser use HTTP Connection they first download the main page and then links in them , our Internet connection is slow and i want to be be it fast browser so i want that HTML page text content is dowloaded and rendered and stop at that moment as gif's or Jpeg files eat the time to download , i am using IE ctrl in my application to atomate for some purpose, i tried to stop in OnNavigateComplete2WebBrowser but it not work , i found article in MSDN in (Reusing the WebBrowser Control) and found the following section i copied from MSDN
(Download Control:-
Hosts can control certain aspects of downloading, such as frames, images, Java, and so on, by implementing an ambient property defined as DISPID_AMBIENT_DLCTL. When the host'sIDispatch::Invoke method is called with dispidMember set to DISPID_AMBIENT_DLCTL, it should place zero or a combination of the following values in pvarResult...)
2.i am writing direct mailer, so it need MX record finding , that is done if you have you DNS Server address known , i hear that GetNetworkParam works but in online MSDN it is given to include "iphlpapi.h" and this and "iphlpapi.lib" but these i not find in our VC++ 6.0 Enterprise edition library.
3.How to scroll data in CScrolView window greater than 32k lines , i tried by bypassing the Scrollmsgs using hooks,it works but not smoothly , as VC++ binary editor|RichEdit scroll > 32k
|
|
|
|
|
Thank for your good work.It works well.
But now i have got a problem. can we get the whole height & width the scroll bar will scroll?
Does anybody could help me out?? thank you
|
|
|
|
|
Hi,
I want to be able switch on and off the execution of ActiveX controls in my code. Does anyone know how this is possible?
Thanks
|
|
|
|
|
I am facing a problem catching the scroll bar events in CHtmlView class. I have tried to use the OnScroll() method of the view class but it does not seems to work at all. If anyone know the way, please help me out of this problem.
regards
Humphrey Chakma
|
|
|
|
|
After the scroll bar is moved by clicking mouse manually, how to get scroll bar position information in program?
|
|
|
|
|
You can write the code below to get the scroll bar position....
HRESULT hr;
// get the document dispatch from browser
IDispatch *pDisp = GetHtmlDocument();
ASSERT( pDisp ); //if NULL, we failed
IHTMLDocument2 *pDocument = NULL;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pDocument );
IHTMLElement *pBody = NULL;
hr = pDocument->get_body( &pBody );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pBody );
// from body we can get element2 interface,
// which allows us to do scrolling
IHTMLTextContainer *pContainer = NULL;
hr = pBody->QueryInterface(IID_IHTMLTextContainer,(void**)&pContainer);
ASSERT(SUCCEEDED(hr));
ASSERT( pContainer );
CPoint ScrollPos;
pContainer->get_scrollTop(&ScrollPos.x);
pContainer->get_scrollLeft(&ScrollPos.y);
CString str;
str.Format("Top: %ld, Left: %ld", ScrollPos.x, ScrollPos.y);
AfxMessageBox(str);
pDisp->Release();
Hope this will do for you.
Humphrey Chakma
|
|
|
|
|
Here is a version of the code that does not require the updated SDK. This version works with the default Visual C++ 6.0 installation.
HRESULT hr;
// get the document dispatch from browser
IDispatch *pDisp = wBrowser.GetDocument();
ASSERT( pDisp ); //if NULL, we failed
IHTMLDocument2 *pDocument = NULL;
hr = pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDocument );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pDocument );
IHTMLWindow2 *pWindow = NULL;
hr = pDocument->get_parentWindow( &pWindow );
ASSERT( SUCCEEDED( hr ) );
ASSERT( pWindow );
pWindow->scrollBy( 0, delta );
pDisp->Release();
|
|
|
|
|
|
Is there a way to GET the scrollbar positions without using IHTMLElement2?
|
|
|
|
|
Have you found a way to obtain the scroll position? The non-IHTMLElement2 version does scroll to the specified position properly while the IHTMLElement2 version didn't. Is this what you found? The scroll problems appear to be caused by newer versions of IE. There has to be a way to get the current position or I'm not sure why you would need scroll-to unless you wanted to move to the beginning or end of the display.
|
|
|
|
|
I like this way!thx!
I am not a genius, but shed more sweat!
|
|
|
|
|
Hi,
I have a webbrowser control in my dialog and it shows a right side (vertical) scrollbar which i dont want it to show or any of the scrollbars..Please help me out..
how can i do that..Thanks a lot in advance..
Regards,
Himanshu
|
|
|
|
|
Great Code Do Yahoo Messenger Uses Code like this for Main Chat window.
If we go on adding new HTML Data to the control how can we make sure that scrollbar always remains at the bottom and dose'nt Moves Up and Down
As in case of IDE when we use Ctrl + Page Down in the output window whatever ouput may be generated but we can see the last line always same for Yahoo Messenger Main Chat window.
|
|
|
|
|
The code work fine for the scrollbar but can I hide the scrollbar
Hello
I work on a mobile robot GUI and I receive the video from an IP camera and I need to center the web page and hide the scrollbars
So the code works very fine with the “SimpleBrowser” Class from Gary R. Wheeler.
http://www.codeproject.com/useritems/simplebrowserformfc.asp?target=simplebrowser
But I don’t understand why the code don’t work with with the IE control (Webbrowser) on a dialog box MFC (I have done this : “insert control ActivX” and I declare a variable to be related to this Control (m_nav1).
The probleme is here: with the “hr = pDocument->m_nav1.get_body (&pBody );”
pBody is empty ??????? when I debug.
//////////////////////////////////////////////////////////////////
// get the document dispatch from browser
IDispatch *pDisp = m_nav1.get_Document(); // ok work fine
ASSERT( pDisp ); //if NULL, we failed
……………………………………………..
hr = pDocument->get_body(&pBody ); // pBody is initialized but empty
ASSERT( SUCCEEDED( hr ) );
ASSERT( pBody ); //Assertion occur
////////////////////////////////////////////////////////////////////
By the way I still need a something to hide the scrollbars.
Thanks
|
|
|
|
|
Hiding scrollbars should be done inside your web page HTML code. You can do this:
<body style="overflow:hidden">
It will do
|
|
|
|
|
Thank you so much!! This tip has helped a lot.
|
|
|
|
|
I have specific requirement to write the html(response) pages obtained using the WebBrowser controls.So, I wrote a event handler to the OnDocumentComplete event.Inside the handler, I am caling the getDocument function and obtained the html page.When doing like this, the intermediate pages are also stored.I mean the pages which contain meta http-equvi=refresh.I need only the final response page that is displayed on the browser window.Is there any way to do this. Please help me. Can any of you tell me the usage and significance of the option OLECMDID_HTTPEQUIV in execWB()call.Will this be helpful to solve my issue.If so, please give me some ideas on its usage.
|
|
|
|
|
// no error check
// m_wndHtmlView is CHtmlView class
IDispatch *pDisp = m_wndHtmlView.GetHtmlDocument();
IHTMLDocument2 *pDocument = NULL;
pDisp->QueryInterface( IID_IHTMLDocument2, ( void** )&pDocument );
IHTMLElement* pBody = NULL;
pDocument->get_body( &pBody );
IHTMLWindow2* pWindow = NULL;
pDocument->get_parentWindow( &pWindow );
pWindow->scroll( 0, 250 );
|
|
|
|
|
I try your code in my application(I use rIWebControl2),but nothing happen. How should I do?
And I try the code in this article, it also doesn't work.
thanks
benben
|
|
|
|