Link to home
Start Free TrialLog in
Avatar of CongUan
CongUan

asked on

How can hide Vert Scrollbar of CHtmlView?

Hi all,

I have a problem that HtmlView control show a webpage, not need ScrollBar, but that Scrollbar is still there and is disabled.

I used ShowScrollBar(SB_VERT, FALSE);

but it is still displayed.
Avatar of mahesh1402
mahesh1402
Flag of India image

CHtmlView having multiple windows/container embeded inside it...

Just put following code to hide scrollbar of CHtmlView

   IHTMLDocument2 *lpHtmlDocument = NULL;
   LPDISPATCH lpDispatch = NULL;
   lpDispatch = GetHtmlDocument();
   ASSERT(lpDispatch);

   lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&lpHtmlDocument);
   ASSERT(lpHtmlDocument);

   lpDispatch->Release();

   CComQIPtr<IHTMLDocument2>piDoc(lpHtmlDocument);  //pointer html document
   CComPtr<IHTMLElement>piElem;    //pointer to element
   CComPtr<IHTMLBodyElement>piBody;  //pointer to bodyelement

   piDoc->get_body(&piElem);  
   piElem->QueryInterface(&piBody);
   piBody->put_scroll(CComBSTR(_T("no")));   //Hide


-MAHESH
Avatar of CongUan
CongUan

ASKER

I still see a Vert scrollbar when it display a webpage successfully.
have you tried above code ? or can you post some code that you have tried ??
Avatar of CongUan

ASKER

i tried above code.
where you have include following code in CHtmlView derived class function ??
Avatar of CongUan

ASKER

I included above code in OnDocumentComplete of ChtmlView derived class.
At my end on CHtmlView derived class its successfully hiding scrollbars in OnDocumentComplete event.
I performed following test to ensure its working :

I downloaded following sample with src which use CHtmlView : http://www.codeproject.com/miscctrl/chtmlview_search.asp. In CHtmlView_SearchView.CPP
Edit any function CCHtmlView_SearchView::FindText() and copy paste above code at end of function. In search box typed something and pressed enter and Vert scrollbar vanished.

-MAHESH
Avatar of CongUan

ASKER

still not work. i put above code into a function and call it anytime.
CongUan ,
 It will be better if you post code about how you put above code in function and called if from where.. to resolve this..

-MAHESH
ASKER CERTIFIED SOLUTION
Avatar of mahesh1402
mahesh1402
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial