Solved

How can hide Vert Scrollbar of CHtmlView?

Posted on 2006-11-06
14
1,162 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 123
Separate into files by filename 12 76
maxBlock challenge 30 112
Trying to run powershell  in a batch file. How do I do this? 8 67
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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now