Solved

hide scrollbar in CHtmlView

Posted on 2002-07-04
21
1,962 Views
Last Modified: 2013-11-20
Hi all,
    I have some quesition about CHtmlView. I derived CHtmlView to my app and I would like to hide scrollbar
(not disable ,I can scroll up and down with up and down button ) .Does anyone know how to that? .If CHtmlView cannot do that I want you can suggest the way that I can do
so I will customize my app for it.

Thank you
0
Comment
Question by:wanlop
  • 9
  • 7
  • 2
21 Comments
 
LVL 12

Expert Comment

by:migel
ID: 7129495
Hi!
you have to
handle DocHostUIHandler method GetHostInfo
and set
DOCHOSTUIFLAG_SCROLL_NO flag in the DOCHOSTUIINFO->dwFlags
field
here is cite from README.TXT for MS driller sample (you can get it form MS MSDN site)
"To implement the IDocHostUIHandler, the client site needs to implement
the interface. In MFC, the class COleControlSite encapsulates the client
site. In this example we are subclassing MFC, a class CCustomControlSite,
is derived from COleControlSite and CCustomControlSite implements IDocHostUIHandler.
To hook in the CCustomControlSite, a class CCustomOccManager is derived from
COccManager. Subclassing COccManager and COleControlSite in such a manner is
implementation specific to MFC. So, if future versions of MFC change the
implementation of COleControlSite or COccManager, this sample (and your code
if you use this technique) might not work. We are looking at possible ways to
have MFC expose the client site for customization. If in future MFC does expose
the client site, then we will modify this sample to use that functionality. "
0
 

Author Comment

by:wanlop
ID: 7129604
Hi
     I used to do with your suggestion .But It seem scrollbar was
disable not hide when I browse to page that large that screen
I can not scroll down by my arrow down or arrow up key.
I would like to scroll the page but I don't want scrollbar show up.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7129643
Try this

ShowScrollBar API
=================
The ShowScrollBar function shows or hides the specified scroll bar.

BOOL ShowScrollBar(
  HWND hWnd,  // handle to window
  int wBar,   // scroll bar
  BOOL bShow  // scroll bar visibility
);

GOOD LUCK
0
 

Author Comment

by:wanlop
ID: 7130889
Hi
  I used to try with ShowScrollBar too. And it not work too.  :(
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7131031
wher u used that function,

In View,
Child Frame
or in Main Frame

Try in Child Frame and in View
0
 

Author Comment

by:wanlop
ID: 7131046
I put in class that I derived from CHtmlView. and it not work.

but right now I found the solution to solve my problem.
thanks.
0
 
LVL 12

Expert Comment

by:migel
ID: 7131178
Hi!
just for interest - what solution you found? (URL?)
0
 

Author Comment

by:wanlop
ID: 7131243
I think it's not good solution but it can solve my problem.
My app is show in full screen mode .I just get the window rect and plus a little bit to 20 point  to right 's variable and replace
the current rect so scrollbar will hide from the screen rect.

:)
0
 
LVL 12

Expert Comment

by:migel
ID: 7131271
Hmmm
it is not so good :-) isn`t it?
You can hide scrollbar using ROSHMON method but you need supply proper window handle to success
since HTML view is just WEB control holder  you have to get Web control window not HTMLView one
here is code how to do:
/////////////////////////////////////////////////////////////////////////////
// RetrieveBrowserWindow - Get the HWND of the browser
//
HRESULT CViewSource::RetrieveBrowserWindow()
{
     // To get the HWND of the browser we need to enumerate
     // all the windows belonging to this thread. We could
     // check for the window's class name if it wasn't changed
     // from Windows 95/NT 4.0 to Windows 98. With Windows 98
     // the class name is the same as any other open folder, so
     // there's no certainty of uniqueness.

     // Get the HWND of the browser's window
     EnumThreadWindows(
          GetCurrentThreadId(),
          WndEnumProc,
          reinterpret_cast<LPARAM>(&m_hwndBrowser) );

     if (!IsWindow(m_hwndBrowser))
          return E_POINTER;

     g_pThis = this;
     return S_OK;
}


/////////////////////////////////////////////////////////////////////////////
// WndEnumProc - Enumeration procedure for thread's windows
//
BOOL CALLBACK CViewSource::WndEnumProc(HWND hwnd, LPARAM lParam)
{
     TCHAR szClassName[MAX_PATH];
     GetClassName(hwnd, szClassName, MAX_PATH);

     // IEFrame was the window's class name under Win95. The
     // other is the title under Win98.
     if (!lstrcmpi(szClassName, _T("Internet Explorer_Server")))
     {
          // We need to return the HWND found if any. The lParam
          // is a pointer to the HWND to be used the return buffer
          HWND *phWnd = reinterpret_cast<HWND*>(lParam);
          *phWnd = hwnd;

          // Return FALSE to stop enumeration once we've found the
          // expected window
          return false;
     }

     // Return TRUE to continue enumerating windows
     return true;
}

where WndEnumProc  is the static method of the class
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:wanlop
ID: 7131409
Hi ,
    Can you give more detail  or sample ? I don't know how can I used your sample code. I understand the main idea that you
explain but when I put your sample to my program in CHtmlView derived class but ,I got some error like this when I compile
 error C2664: 'EnumThreadWindows' : cannot convert parameter 2 from 'int (struct HWND__ *,long)' to 'int (__stdcall *)(struct HWND__ *,long)'
        None of the functions with this name in scope match the target type

error C2065: 'g_pThis' : undeclared identifier

0
 
LVL 12

Expert Comment

by:migel
ID: 7131478
Hi g_pThis - just garbage - remain from working kode - remove IT!
NOTE!
CViewSource::WndEnumProc - must be STATIC in the class declaration
that is in the *.h file declare it as:
protected:
 static BOOL CALLBACK WndEnumProc(...);
0
 

Author Comment

by:wanlop
ID: 7131520
Hi
  I can compile right now ,but it seem I cann't get HWND from
 EnumThreadWindows(
         GetCurrentThreadId(),
         WndEnumProc,
         reinterpret_cast<LPARAM>(&m_hwndBrowser) );
.

because after when it pass EnumThrea...  it will return E_POINTER;
0
 
LVL 12

Expert Comment

by:migel
ID: 7131596
where you declare m_hwndBrowser?
0
 

Author Comment

by:wanlop
ID: 7131603
I declare in
HRESULT CViewSource::RetrieveBrowserWindow()
0
 
LVL 12

Expert Comment

by:migel
ID: 7131712
hmm
I check this code and sad to say that it doesn`t work at all :-(
with MSIE  v 6.0 method with ShowScrollBar not working even if proper HWND supplied.
So I think your method simples solution that can be applicated :-)
0
 

Author Comment

by:wanlop
ID: 7131722
ok thank you for your help , I'm really applicated.:)

Have a nice day
0
 
LVL 12

Accepted Solution

by:
migel earned 200 total points
ID: 7131781
Hi!
I found some tricks:

void CMfcieView::OnHideScroll()
{
     static bool bDesign = false;
     bDesign = !bDesign;
     if (m_pBrowserApp != NULL)
          {
          IHTMLDocument2* lpTarget = NULL;
          LPDISPATCH lpDisp = GetHtmlDocument();

          if (lpDisp != NULL)
               {
               // the control will handle all printing UI
               if (SUCCEEDED(lpDisp->QueryInterface(IID_IHTMLDocument2,
                         (LPVOID*) &lpTarget)))
                    {
                    IHTMLElement* elem  = NULL;
                    lpTarget->get_body(&elem);
                    if (elem)
                         {
                         IHTMLBodyElement* pElem;
                         if (SUCCEEDED(elem->QueryInterface(IID_IHTMLBodyElement,
                                   (LPVOID*) &pElem)))
                              {
                              BSTR bsString = SysAllocString(L"no");
                              pElem->put_scroll(bsString);
                              SysFreeString(bsString);
                              pElem->Release();
                              }
                         elem->Release();
                         }
                    /*
                    lpTarget->put_designMode(bDesign ? L"On" : L"Off");
                    */                    
                    lpTarget->Release();
                    }
               lpDisp->Release();
               }
          }
}

After this functiom scrollbars are disappeared but scrolling with keys also gone :-)
May be installing Keyboard hook  and translating key strokes to the view can help?
to scroll document programmatically you can use IHTMLElement2 method doScroll
0
 

Author Comment

by:wanlop
ID: 7142501
Hi
    sorry for late to reply. About scrollbar I think my solution is fine for me thank you sir.  
I just got the problem about how can I detect  history object of IE , I would like to disable or enable back and forward button.

Do you have any Idea?  pls suggest me
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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…
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 video discusses moving either the default database or any database to a new volume.

707 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

17 Experts available now in Live!

Get 1:1 Help Now