Solved

How can hide Vert Scrollbar of CHtmlView?

Posted on 2006-11-06
14
1,173 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 131
Expand data scrubbing tool 13 35
dog bark java program 15 108
has77  challenge 9 88
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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