Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scrolling the Webbrowser Document - VC++

0 views
Skip to first unread message

NEST Electronics

unread,
Mar 25, 1998, 3:00:00 AM3/25/98
to

Hi,

is there any possibility to scroll the active document of the WebBrowser by
C++ commands ?

It doesn't work with the CWnd::ScrollWindow - member function, because there
the WebBrowser window itself, but not the document is scrolled.

It also doesn't work with sending a WM_KEYDOWN (Pagedown or something) to
the WebBrowser object.

An other problem is: Where do you get the correct dispid-parameter for the
DWebBrowser2 events ?
Have a look:
ON_EVENT(CWebBrowser2,ID_BROWSER, ?? ,OnBeforeNavigate2,...)

This may be a simple problem, but not for beginners.


Any ideas, known source-code, examples .... are very welcome !
Arthu...@t-online.de

Thank's for help Arthur

Alexey Sanin

unread,
Mar 27, 1998, 3:00:00 AM3/27/98
to

Look this code for scrolling:

void CWebControl::SetScrollSize()
{
IDispatch *p = m_WebBrowser.GetDocument();
if(p){

IHTMLDocument2* htmDoc2 = NULL ;

if (p -> QueryInterface(IID_IHTMLDocument2, (void **)&htmDoc2) == S_OK){
IHTMLElement * htmlBody = NULL;
if (htmDoc2 -> get_body(&htmlBody) == S_OK){
if(htmlBody != NULL){
IHTMLTextContainer *pHTMLText;

htmlBody -> get_offsetWidth(&m_WndWidth); // Wnd Width & Height
htmlBody -> get_offsetHeight(&m_WndHeight);
if (htmlBody -> QueryInterface(IID_IHTMLTextContainer,
(void **)&pHTMLText) == S_OK){
pHTMLText -> get_scrollWidth(&m_ScrollWidth); // Document Width &
Height
pHTMLText -> get_scrollHeight(&m_ScrollHeight);

pHTMLText -> Release();
}

htmlBody -> Release();
}
}
htmDoc2 -> Release() ;
}

p -> Release();
}
}

void CWebControl::ScrollTo(LONG scrollX, LONG scrollY)
{
IDispatch *pDisp = m_WebBrowser.GetDocument();
if(pDisp){

IHTMLDocument2* htmDoc2 = NULL ;

if (pDisp->QueryInterface(IID_IHTMLDocument2, (void **)&htmDoc2) == S_OK){
IHTMLWindow2* htmWin2 = NULL ;
if (htmDoc2->get_parentWindow(&htmWin2) == S_OK){
htmWin2->scroll(scrollX, scrollY) ;
htmWin2->Release() ;
}
htmDoc2->Release() ;
}

pDisp -> Release();
}

}


CPoint& CWebControl::GetScrollPosition()
{
LONG x = 0, y = 0;
IDispatch *pDisp = m_WebBrowser.GetDocument();
if(pDisp){

IHTMLDocument2* htmDoc2 = NULL ;

if (pDisp->QueryInterface(IID_IHTMLDocument2, (void **)&htmDoc2) == S_OK){
IHTMLElement * htmlBody = NULL;
if (htmDoc2 -> get_body(&htmlBody) == S_OK){
if(htmlBody != NULL){
IHTMLTextContainer *pHTMLText;
if (htmlBody -> QueryInterface(IID_IHTMLTextContainer,
(void **)&pHTMLText) == S_OK){
pHTMLText -> get_scrollLeft(&x);
pHTMLText -> get_scrollTop(&y);

pHTMLText -> Release();
}

htmlBody -> Release();
}
}
htmDoc2->Release() ;
}

pDisp -> Release();
}

return CPoint(x, y);
}

//////////////////////

Second question:

You can get dispid for any OLE events and methods by OLE-COM Object Viewer
from
Platform Win32 SDK.
(It also is included into VC installation).

For example:

ON_EVENT(CWebControl, ID_WEB_BROWSER, 0x000000fa, OnBeforeNavigate2, \
VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT \
VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)


NEST Electronics wrote in message <6fb4k4$ldj$1...@news02.btx.dtag.de>...

0 new messages