I've created a CMyHtmlView class and inherit from CHtmlView class to implement the WebBrowser Microsoft ActiveX control and it is working fine.
Now I am facing problem with scroll bar that I am not able to get the handle of Scroll bar of this view.
Actually I have two panes (LEFT PANE (Normal View) and RIGHT PANE (HTML View)) and I want to scroll right side view on Scrolling of Left View scroll.
I have used many functions like ScrollToPosition(), SetScrollSizes(CScrollView class) but there is not any impact on Web browser Scroll bar.
I have also added two more functions OnHScroll and OnVScroll and have added events under BEGIN_MESSAGE_MAP, but these functions never get called.
Please help me that how to get control on scroll bar of web browser.
My View class implementation(Header and Source file code) is mentioned below :
class CMyHtmlView : public CHtmlView
{
public:
CMyHtmlView();
DECLARE_DYNCREATE(CMyHtmlView)
virtual ~CMyHtmlView();
public:
void Navigate(LPCTSTR URL);
HRESULT OnShowContextMenu(DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
CPoint GetScrollPosition() const;
protected:
virtual void OnDraw(CDC* pDC);
virtual void OnInitialUpdate();
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "ctsmHTMLView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#ifndef __MAINFRM_H__
#include "MainFrm.h"
#endif //__MAINFRM_H__
#ifndef __CTSMDOC_H__
#include "ctsmDoc.h"
#endif //__CTSMDOC_H__
IMPLEMENT_DYNCREATE(CMyHtmlView, CHtmlView)
CMyHtmlView::CMyHtmlView()
{
}
CMyHtmlView::~CMyHtmlView()
{
}
BEGIN_MESSAGE_MAP(CMyHtmlView, CHtmlView)
ON_WM_HSCROLL()
ON_WM_VSCROLL()
END_MESSAGE_MAP()
void CMyHtmlView::Navigate(LPCTSTR URL)
{
CHtmlView::Navigate(URL);
}
void CMyHtmlView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
CctsmDoc* pDoc = (CctsmDoc*)GetDocument();
Navigate(LPCTSTR(pDoc->c_strHtmlTempName));
}
void CMyHtmlView::OnDraw(CDC* pDC)
{
CHtmlView::OnDraw(pDC);
}
HRESULT CMyHtmlView::OnShowContextMenu( DWORD dwID, LPPOINT ppt, LPUNKNOWN pcmdtReserved, LPDISPATCH pdispReserved )
{
dwID;
ppt;
pcmdtReserved;
pdispReserved;
return S_OK;
}
CPoint CMyHtmlView::GetScrollPosition() const
{
CPoint cpoint = CHtmlView::GetScrollPosition();
POINT point = POINT(cpoint);
int a = 10;
return cpoint;
}
void CMyHtmlView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CctsmDoc* pDoc = (CctsmDoc*)GetDocument();
ASSERT(pDoc);
CWnd::OnHScroll(nSBCode, nPos, pScrollBar);
CPoint ptScroll = GetScrollPosition();
UpdateTrackRectOnScroll(ptScroll);
pDoc->SetViewsScrollPrositions(ptScroll);
CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CMyHtmlView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CctsmDoc* pDoc = (CctsmDoc*)GetDocument();
ASSERT(pDoc);
CPoint ptScroll = GetScrollPosition();
UpdateTrackRectOnScroll(ptScroll);
pDoc->SetViewsScrollPrositions(ptScroll);
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
}