www.pudn.com > TabbedView.rar > View3.cpp


// View3.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "TabbedView.h" 
#include "View3.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CView3 
 
IMPLEMENT_DYNCREATE(CView3, CFormView) 
 
CView3::CView3() 
	: CFormView(CView3::IDD) 
{ 
	//{{AFX_DATA_INIT(CView3) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
CView3::~CView3() 
{ 
} 
 
void CView3::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CView3) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CView3, CFormView) 
	//{{AFX_MSG_MAP(CView3) 
	ON_WM_CONTEXTMENU() 
	ON_WM_WINDOWPOSCHANGING() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CView3 diagnostics 
 
#ifdef _DEBUG 
void CView3::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CView3::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CView3 message handlers 
 
void CView3::OnContextMenu(CWnd* pWnd, CPoint point)  
{ 
	theApp.ShowPopupMenu (IDR_CONTEXT_MENU, point, this); 
} 
 
void CView3::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)  
{ 
	CFormView::OnWindowPosChanging(lpwndpos); 
	 
	// Hide horizontal scrollbar: 
	ShowScrollBar (SB_HORZ, FALSE); 
	ModifyStyle (WS_HSCROLL, 0, SWP_DRAWFRAME); 
} 
 
BOOL CView3::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)  
{ 
	int xOrig, x; 
	int yOrig, y; 
 
	// don't scroll if there is no valid scroll range (ie. no scroll bar) 
	CScrollBar* pBar; 
	DWORD dwStyle = GetStyle(); 
	pBar = GetScrollBarCtrl(SB_VERT); 
	if ((pBar != NULL && !pBar->IsWindowEnabled()) || 
		(pBar == NULL && !(dwStyle & WS_VSCROLL))) 
	{ 
		// vertical scroll bar not enabled 
		sizeScroll.cy = 0; 
	} 
	 
	// adjust current x position 
	xOrig = x = GetScrollPos(SB_HORZ); 
	int xMax = GetScrollLimit(SB_HORZ); 
	x += sizeScroll.cx; 
	if (x < 0) 
		x = 0; 
	else if (x > xMax) 
		x = xMax; 
 
	// adjust current y position 
	yOrig = y = GetScrollPos(SB_VERT); 
	int yMax = GetScrollLimit(SB_VERT); 
	y += sizeScroll.cy; 
	if (y < 0) 
		y = 0; 
	else if (y > yMax) 
		y = yMax; 
 
	// did anything change? 
	if (x == xOrig && y == yOrig) 
		return FALSE; 
 
	if (bDoScroll) 
	{ 
		// do scroll and update scroll positions 
		ScrollWindow(-(x-xOrig), -(y-yOrig)); 
		if (x != xOrig) 
			SetScrollPos(SB_HORZ, x); 
		if (y != yOrig) 
			SetScrollPos(SB_VERT, y); 
	} 
 
	return TRUE; 
}