안녕하세요
좋은 하루 되세요
TCppWebBrowser로 scrollbar 를 제어하고 있습니다.
scrollbar의 위치를 가져오고 설정하고...
팁게시판에 김태선님이 올려놓으신 팁을 이용했습니다.
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=575
http://www.codeproject.com/miscctrl/scrollbrowser.asp
long __fastcall TZWebMain::GetScrollHei(TCppWebBrowser *CppWebBrowser)
{
HRESULT hr;
IDispatch *pDisp = CppWebBrowser->Document;
if(pDisp==NULL )return 0;
// get document interface
::IHTMLDocument2 *pDocument = NULL;
hr = pDisp->QueryInterface( ::IID_IHTMLDocument2, (void**)&pDocument );
if(!SUCCEEDED( hr ))return 0;
if(pDocument==NULL )return 0;
// this is the trick!
// take the body element from document...
::IHTMLElement *pBody = NULL;
hr = pDocument->get_body( &pBody );
if(!SUCCEEDED( hr ))return 0;
if(pBody==NULL )return 0;
// from body we can get element2 interface,
// which allows us to do scrolling
::IHTMLElement2 *pElement = NULL;
hr = pBody->QueryInterface(::IID_IHTMLElement2,(void**)&pElement);
if(!SUCCEEDED( hr ))return 0;
if(pElement==NULL )return 0;
long scroll_height;
pElement->get_scrollTop(&scroll_height );
return scroll_height;
}
그런데 문제는 위팁을 이용해서 get_scrollTop 으로
scroll의 위치를 가져오면 항상 0 으로 나오는 사이트가 많습니다.
여기 볼랜드 포럼(
http://www.borlandforum.com)도 마찬가지구요
여러가지로 테스트 결과 한가지 현상을 발견했으니....
웹페이지 맨 위에 아래 문구가 있는경우 안되더군요
< ! DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN ' > (안보여서 띄어씀)
위와같은 현상은
webBroswer의 Border설정에도 똑같이 안 먹습니다.
WebBroswer->OleObject.OlePropertyGet("Document").OlePropertyGet("Body").OlePropertyGet("style").OlePropertySet("Border","none");
web은 잘몰라서 그런데....
< ! DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN ' > ==> 이놈이 의미하는것이 무엇인지 알고싶구요
위 함수로 scrollbar의 위치를 못구하는 경우의 해결책을 알고싶습니다.
감사합니다.
-추신-
첨부파일은 borlandforum.com의 html 에서
위 doctype에 대한 문장을 뺀경우와 그렇지 않는경우의 html파일입니다.