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.
CongUanAsked:
Who is Participating?
 
mahesh1402Connect With a Mentor Commented:
I tried to put in above code at last just after lpTxtRange->Release(); and it seems to work... have you tried with that ?

void CCHtmlView_SearchView::FindText(CString searchText, long lFlags /* =2 */, BOOL bNNF /* =FALSE  (for internal use)*/)
{
::CoInitialize(NULL);
   
    .......
    .......

     lpTxtRange->Release();
            
        MessageBox("Hiding Vertical Scrollbar.......");
     
        CComQIPtr<IHTMLDocument2>piDoc(lpHtmlDocument);
        CComPtr<IHTMLElement>piElem;
        CComPtr<IHTMLBodyElement>piBody;
        piDoc->get_body(&piElem);
        piElem->QueryInterface(&piBody);
        piBody->put_scroll(CComBSTR(_T("no")));  

-MAHESH
0
 
mahesh1402Commented:
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
0
 
CongUanAuthor Commented:
I still see a Vert scrollbar when it display a webpage successfully.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
mahesh1402Commented:
have you tried above code ? or can you post some code that you have tried ??
0
 
CongUanAuthor Commented:
i tried above code.
0
 
mahesh1402Commented:
where you have include following code in CHtmlView derived class function ??
0
 
CongUanAuthor Commented:
I included above code in OnDocumentComplete of ChtmlView derived class.
0
 
mahesh1402Commented:
At my end on CHtmlView derived class its successfully hiding scrollbars in OnDocumentComplete event.
0
 
mahesh1402Commented:
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
0
 
CongUanAuthor Commented:
still not work. i put above code into a function and call it anytime.
0
 
mahesh1402Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.