hide scrollbar in CHtmlView

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
wanlopAsked:
Who is Participating?
 
migelCommented:
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
 
migelCommented:
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
 
wanlopAuthor Commented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Roshan DavisCommented:
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
 
wanlopAuthor Commented:
Hi
  I used to try with ShowScrollBar too. And it not work too.  :(
0
 
Roshan DavisCommented:
wher u used that function,

In View,
Child Frame
or in Main Frame

Try in Child Frame and in View
0
 
wanlopAuthor Commented:
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
 
migelCommented:
Hi!
just for interest - what solution you found? (URL?)
0
 
wanlopAuthor Commented:
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
 
migelCommented:
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
 
wanlopAuthor Commented:
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
 
migelCommented:
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
 
wanlopAuthor Commented:
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
 
migelCommented:
where you declare m_hwndBrowser?
0
 
wanlopAuthor Commented:
I declare in
HRESULT CViewSource::RetrieveBrowserWindow()
0
 
migelCommented:
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
 
wanlopAuthor Commented:
ok thank you for your help , I'm really applicated.:)

Have a nice day
0
 
wanlopAuthor Commented:
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
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.