Click here to Skip to main content
15,897,273 members
Articles / Desktop Programming / MFC

A pager control wrapper class

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
15 Dec 1999 60K   1.4K   19  
This article presents a wrapper class for the pager control
// CJPagerCtrl.cpp : implementation file
//
// Pager control.
//
// Copyright � 1998 Written by Kirk Stowell   
//		mailto:kstowel@sprynet.com
//		http://www.geocities.com/SiliconValley/Haven/8230
//
// This code may be used in compiled form in any way you desire. This  
// file may be redistributed unmodified by any means PROVIDING it is   
// not sold for profit without the authors written consent, and   
// providing that this notice and the authors name and all copyright   
// notices remains intact. If the source code in this file is used in   
// any  commercial application then a statement along the lines of   
// "Portions Copyright � 1998 Kirk Stowell" must be included in   
// the startup banner, "About" box or printed documentation. An email   
// letting me know that you are using it would be nice as well. That's   
// not much to ask considering the amount of work that went into this.  
//  
// This file is provided "as is" with no expressed or implied warranty.  
// The author accepts no liability for any damage/loss of business that  
// this product may cause.  
//   
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CJPagerCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCJPagerCtrl

CCJPagerCtrl::CCJPagerCtrl()
{
    if (bInitialized==false) {
        INITCOMMONCONTROLSEX icex;
        icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
        icex.dwICC = ICC_PAGESCROLLER_CLASS|ICC_BAR_CLASSES;
        ::InitCommonControlsEx(&icex);
        bInitialized = true;
    }
}

CCJPagerCtrl::~CCJPagerCtrl()
{
}

BEGIN_MESSAGE_MAP(CCJPagerCtrl, CWnd)
	//{{AFX_MSG_MAP(CCJPagerCtrl)
	ON_NOTIFY_REFLECT_EX(PGN_SCROLL,	OnPagerScroll)
	ON_NOTIFY_REFLECT_EX(PGN_CALCSIZE,	OnPagerCalcSize)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

bool CCJPagerCtrl::bInitialized = false;

BOOL CCJPagerCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID) 
{
    return CWnd::Create(WC_PAGESCROLLER, _T(""),
		dwStyle, rect, pParentWnd, nID);
}

/////////////////////////////////////////////////////////////////////////////
// CCJPagerCtrl message handlers

void CCJPagerCtrl::SetChild(HWND hWnd)
{
	Pager_SetChild(m_hWnd, hWnd);
}

void CCJPagerCtrl::RecalcSize()
{
	Pager_RecalcSize(m_hWnd);
}

void CCJPagerCtrl::ForwardMouse(bool bForward)
{
	Pager_ForwardMouse(m_hWnd,bForward);
}

COLORREF CCJPagerCtrl::SetBkColor(COLORREF clr)
{
	return Pager_SetBkColor(m_hWnd,clr);
}

COLORREF CCJPagerCtrl::GetBkColor()
{
	return Pager_GetBkColor(m_hWnd);
}

int CCJPagerCtrl::SetBorder(int iBorder)
{
	return Pager_SetBorder(m_hWnd,iBorder);
}

int CCJPagerCtrl::GetBorder()
{
	return Pager_GetBorder(m_hWnd);
}

int CCJPagerCtrl::SetPos(int iPos)
{
	return Pager_SetPos(m_hWnd,iPos);
}

int CCJPagerCtrl::GetPos()
{
	return Pager_GetPos(m_hWnd);
}

int CCJPagerCtrl::SetButtonSize(int iSize)
{
	return Pager_SetButtonSize(m_hWnd,iSize);
}

int CCJPagerCtrl::GetButtonSize()
{
	return Pager_GetButtonSize(m_hWnd);
}

DWORD CCJPagerCtrl::GetButtonState(int iButton)
{
	return Pager_GetButtonState(m_hWnd,iButton);
}

BOOL CCJPagerCtrl::OnPagerCalcSize(NMPGCALCSIZE* pNMPGCalcSize, LRESULT* pResult)
{
    *pResult = 0;

	switch(pNMPGCalcSize->dwFlag)
    {
	case PGF_CALCWIDTH:
		pNMPGCalcSize->iWidth = m_nWidth;
		break;
		
	case PGF_CALCHEIGHT:
		pNMPGCalcSize->iHeight = m_nHeight;
        break;
	}
	
	return 0;
}

BOOL CCJPagerCtrl::OnPagerScroll(NMPGSCROLL* pNMPGScroll, LRESULT* pResult)
{
    *pResult = 0;
	
  	switch(pNMPGScroll->iDir)
	{
	case PGF_SCROLLLEFT:
	case PGF_SCROLLRIGHT:
	case PGF_SCROLLUP:
	case PGF_SCROLLDOWN:
        break;
	}
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Codejock Technologies, LLC
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation (No members)


Comments and Discussions