Solved

How can hide Vert Scrollbar of CHtmlView?

Posted on 2006-11-06
14
1,167 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:CongUan
  • 7
  • 4
14 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17887005
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
 

Author Comment

by:CongUan
ID: 17887492
I still see a Vert scrollbar when it display a webpage successfully.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17887517
have you tried above code ? or can you post some code that you have tried ??
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:CongUan
ID: 17887555
i tried above code.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17887597
where you have include following code in CHtmlView derived class function ??
0
 

Author Comment

by:CongUan
ID: 17888144
I included above code in OnDocumentComplete of ChtmlView derived class.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17888170
At my end on CHtmlView derived class its successfully hiding scrollbars in OnDocumentComplete event.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17895661
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
 

Author Comment

by:CongUan
ID: 17904996
still not work. i put above code into a function and call it anytime.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17905111
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
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 250 total points
ID: 17905129
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question